Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormkersten2006-01-11 23:25:18 +0000
committermkersten2006-01-11 23:25:18 +0000
commit1245a92f28a2990bae8373c09891556a69268c75 (patch)
tree1a6e87a2e69a2c9ef1052ec87537e7ebdd7469dd
parent1441655c4b2af42d0ccd37e2ea96278e7e0c9e83 (diff)
downloadorg.eclipse.mylyn.tasks-1245a92f28a2990bae8373c09891556a69268c75.tar.gz
org.eclipse.mylyn.tasks-1245a92f28a2990bae8373c09891556a69268c75.tar.xz
org.eclipse.mylyn.tasks-1245a92f28a2990bae8373c09891556a69268c75.zip
Progress on: Bug 121041: Support more than one Bugzilla account per Workspace
https://bugs.eclipse.org/bugs/show_bug.cgi?id=121041
-rw-r--r--org.eclipse.mylyn.bugzilla.core/META-INF/MANIFEST.MF5
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/BugReport.java6
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/BugzillaPlugin.java124
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/BugzillaPreferencePage.java657
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/BugzillaRepository.java428
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/BugzillaRepositoryUtil.java508
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/IBugzillaConstants.java58
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/internal/BugParser.java17
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/internal/Favorite.java (renamed from org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/favorites/Favorite.java)2
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/internal/FavoritesFile.java (renamed from org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/favorites/FavoritesFile.java)2
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/internal/OfflineReportsFile.java (renamed from org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/offline/OfflineReportsFile.java)2
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/internal/ProductParser.java6
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/search/BugzillaQueryPageParser.java323
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/search/BugzillaSearchEngine.java53
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/search/BugzillaSearchHit.java7
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/search/BugzillaSearchOperation.java64
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/META-INF/MANIFEST.MF3
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaProductParserTest.java25
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/RegularExpressionMatchTest.java5
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/BugzillaUITools.java15
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/BugzillaUiPlugin.java77
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/FavoritesView.java4
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/OfflineView.java2
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/ViewBugzillaAction.java2
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/AddBugzillaQueryAction.java7
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/AddFavoriteAction.java10
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/AddToFavoritesAction.java2
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/CreateBugzillaTaskAction.java6
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/CreateNewBugzillaTaskAction.java12
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/OpenBugsAction.java9
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/RefreshBugzillaReportsAction.java7
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/SynchronizeReportsAction.java3
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/editor/AbstractBugEditor.java21
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/editor/ExistingBugEditor.java19
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/editor/ExistingBugEditorInput.java21
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/editor/NewBugEditor.java5
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/search/BugzillaSearchPage.java139
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/search/BugzillaSearchResultView.java5
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaCategorySearchOperation.java179
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaCustomQueryCategory.java4
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaHit.java23
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaQueryCategory.java121
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaQueryDialog.java22
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaReportNode.java297
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTask.java79
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTaskEditor.java5
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTaskEditorInput.java7
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTaskExternalizer.java21
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTaskHandler.java7
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTaskListManager.java3
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTasksTools.java6
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/wizard/AbstractBugWizard.java32
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/wizard/NewBugWizard.java19
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/wizard/WizardProductPage.java14
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/bugs/BugzillaStructureBridge.java10
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/bugs/BugzillaUiBridge.java7
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/bugs/java/BugzillaHyperLink.java9
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/bugs/java/OpenBugzillaReportJob.java8
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/bugs/search/BugzillaMylarSearch.java9
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/bugs/search/BugzillaMylarSearchOperation.java840
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/bugs/search/BugzillaReferencesProvider.java7
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/bugs/search/Util.java43
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/bugs/ui/actions/OpenCorrespondingReportAction.java8
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasklist/tests/AllTasklistTests.java2
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasklist/tests/TaskListManagerTest.java68
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasklist/tests/TaskRepositoryManagerTest.java (renamed from org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasklist/tests/RepositoryManagerTest.java)32
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/IQueryHit.java2
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ITask.java11
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ITaskQuery.java4
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/MylarTaskListPlugin.java5
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/DelegatingLocalTaskExternalizer.java13
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/Task.java119
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/TaskListManager.java2
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/repositories/TaskRepository.java24
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/repositories/TaskRepositoryManager.java113
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/MylarTaskEditor.java5
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/TaskInfoEditor.java443
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/actions/MarkTaskCompleteAction.java1
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/actions/MarkTaskIncompleteAction.java1
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/views/TaskListView.java442
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/wizards/AddRepositoryWizard.java2
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/wizards/EditRepositoryWizard.java4
82 files changed, 3017 insertions, 2717 deletions
diff --git a/org.eclipse.mylyn.bugzilla.core/META-INF/MANIFEST.MF b/org.eclipse.mylyn.bugzilla.core/META-INF/MANIFEST.MF
index 79c9585c6..c58ebf3b5 100644
--- a/org.eclipse.mylyn.bugzilla.core/META-INF/MANIFEST.MF
+++ b/org.eclipse.mylyn.bugzilla.core/META-INF/MANIFEST.MF
@@ -12,14 +12,13 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.search,
org.eclipse.ui.ide,
org.eclipse.update.core,
- org.eclipse.update.ui
+ org.eclipse.update.ui,
+ org.eclipse.mylar.tasklist
Eclipse-AutoStart: true
Bundle-Vendor: Eclipse.org
Bundle-ClassPath: bugzilla-core.jar
Export-Package: org.eclipse.mylar.bugzilla.core,
org.eclipse.mylar.bugzilla.core.compare,
- org.eclipse.mylar.bugzilla.core.favorites,
org.eclipse.mylar.bugzilla.core.internal,
- org.eclipse.mylar.bugzilla.core.offline,
org.eclipse.mylar.bugzilla.core.search
Bundle-RequiredExecutionEnvironment: J2SE-1.5
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/BugReport.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/BugReport.java
index 727f4beb6..1b8076865 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/BugReport.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/BugReport.java
@@ -47,7 +47,7 @@ public class BugReport implements Serializable, IBugzillaBug {
protected final int id;
/** The bug's server */
- protected final String server;
+ protected final String repositoryUrl;
/** Description of the bug */
protected String description;
@@ -99,7 +99,7 @@ public class BugReport implements Serializable, IBugzillaBug {
*/
public BugReport(int id, String server) {
this.id = id;
- this.server = server;
+ this.repositoryUrl = server;
}
/**
@@ -112,7 +112,7 @@ public class BugReport implements Serializable, IBugzillaBug {
}
public String getServer() {
- return server;
+ return repositoryUrl;
}
public String getLabel() {
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/BugzillaPlugin.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/BugzillaPlugin.java
index ba49d0b18..0d7d8d8ba 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/BugzillaPlugin.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/BugzillaPlugin.java
@@ -20,7 +20,10 @@ import java.net.Proxy.Type;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
+import java.util.Set;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
@@ -34,29 +37,30 @@ import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.mylar.bugzilla.core.IOfflineBugListener.BugzillaOfflineStaus;
-import org.eclipse.mylar.bugzilla.core.favorites.FavoritesFile;
+import org.eclipse.mylar.bugzilla.core.internal.FavoritesFile;
+import org.eclipse.mylar.bugzilla.core.internal.OfflineReportsFile;
import org.eclipse.mylar.bugzilla.core.internal.ProductConfiguration;
import org.eclipse.mylar.bugzilla.core.internal.ProductConfigurationFactory;
-import org.eclipse.mylar.bugzilla.core.offline.OfflineReportsFile;
import org.eclipse.mylar.bugzilla.core.search.IBugzillaResultEditorMatchAdapter;
+import org.eclipse.mylar.tasklist.MylarTaskListPlugin;
+import org.eclipse.mylar.tasklist.repositories.TaskRepository;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.eclipse.update.internal.core.UpdateCore;
import org.eclipse.update.internal.ui.UpdateUI;
import org.osgi.framework.BundleContext;
-
-/**
- * @author kvesik
- *
- * Created on Mar 26, 2003
- */
-
/**
* The main plugin class to be used in the desktop.
+ *
+ * @author Mik Kersten (added support for multiple repositories)
*/
public class BugzillaPlugin extends AbstractUIPlugin {
+ public static final String REPOSITORY_KIND = "bugzilla";
+
+ public static final String ENCODING_UTF_8 = "UTF-8";
+
/** Singleton instance of the plug-in */
private static BugzillaPlugin plugin;
@@ -69,18 +73,17 @@ public class BugzillaPlugin extends AbstractUIPlugin {
private List<IOfflineBugListener> listeners = new ArrayList<IOfflineBugListener>();
/** Product configuration for the current server */
- private ProductConfiguration productConfiguration;
+ private Map<String, ProductConfiguration> productConfigurations = new HashMap<String, ProductConfiguration>();
+
+ private Authenticator authenticator = null;
/**
* Constructor
* @param descriptor passed in when the plugin is loaded
*/
- public BugzillaPlugin()
- {
+ public BugzillaPlugin() {
super();
}
-
- Authenticator authenticator = null;
/**
* Get the singleton instance for the plugin
@@ -96,16 +99,23 @@ public class BugzillaPlugin extends AbstractUIPlugin {
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
- plugin = this;
authenticator = UpdateUI.getDefault().getAuthenticator();
- if(authenticator == null)
+ if(authenticator == null) {
authenticator = new BugzillaAuthenticator();
+ }
Authenticator.setDefault(authenticator);
+ setDefaultQueryOptions();
+
readFavoritesFile();
readOfflineReportsFile();
- readCachedProductConfiguration();
+
+ Set<TaskRepository> repositories = MylarTaskListPlugin.getRepositoryManager().getRepositories(REPOSITORY_KIND);
+ System.err.println(">>>> should have repository: " + repositories);
+ for (TaskRepository repository : repositories) {
+ readCachedProductConfiguration(repository.getServerUrl().toExternalForm());
+ }
}
@Override
@@ -141,13 +151,13 @@ public class BugzillaPlugin extends AbstractUIPlugin {
}
/**
- * Get the name of the bugzilla server
- *
- * @return A string containing the prefered name of the bugzilla server
- */
- public String getServerName() {
- return plugin.getPreferenceStore().getString(IBugzillaConstants.BUGZILLA_SERVER);
- }
+// * Get the name of the bugzilla server
+// *
+// * @return A string containing the prefered name of the bugzilla server
+// */
+// public String getServerName() {
+// return plugin.getPreferenceStore().getString(IBugzillaConstants.BUGZILLA_SERVER);
+// }
public boolean isServerCompatability218(){
return IBugzillaConstants.SERVER_218.equals(getPreferenceStore().getString(IBugzillaConstants.SERVER_VERSION))
@@ -168,18 +178,13 @@ public class BugzillaPlugin extends AbstractUIPlugin {
return plugin.getPreferenceStore().getString(IBugzillaConstants.MOST_RECENT_QUERY);
}
- /**
- * Returns the current product configuration or <code>null</code> if it is unknown.
- */
- public ProductConfiguration getProductConfiguration() {
- return productConfiguration;
+ public ProductConfiguration getProductConfiguration(String serverUrl) {
+ return productConfigurations.get(serverUrl);
}
- /**
- * Sets the current product configuration.
- */
- protected void setProductConfiguration(ProductConfiguration productConfiguration) {
- this.productConfiguration = productConfiguration;
+ protected void setProductConfiguration(String serverUrl, ProductConfiguration productConfiguration) {
+ productConfigurations.put(serverUrl, productConfiguration);
+ // this.productConfiguration = productConfiguration;
}
/**
@@ -230,15 +235,17 @@ public class BugzillaPlugin extends AbstractUIPlugin {
/**
* Reads cached product configuration and stores it in the <code>productConfiguration</code> field.
*/
- private void readCachedProductConfiguration() {
- IPath configFile = getProductConfigurationCachePath();
+ private void readCachedProductConfiguration(String serverUrl) {
+ // XXX: removed cached product configurations
+
+ IPath configFile = getProductConfigurationCachePath(serverUrl);
try {
- productConfiguration = ProductConfigurationFactory.getInstance().readConfiguration(configFile.toFile());
+ productConfigurations.put(serverUrl, ProductConfigurationFactory.getInstance().readConfiguration(configFile.toFile()));
} catch (IOException ex) {
try {
log(ex);
- productConfiguration = ProductConfigurationFactory.getInstance().getConfiguration(getServerName());
+ productConfigurations.put(serverUrl, ProductConfigurationFactory.getInstance().getConfiguration(serverUrl));
} catch (IOException e) {
log(e);
MessageDialog.openInformation(null, "Bugzilla product attributes check",
@@ -255,9 +262,9 @@ public class BugzillaPlugin extends AbstractUIPlugin {
/**
* Returns the path to the file cacheing the product configuration.
*/
- protected IPath getProductConfigurationCachePath() {
+ protected IPath getProductConfigurationCachePath(String serverUrl) {
IPath stateLocation = Platform.getPluginStateLocation(BugzillaPlugin.getDefault());
- IPath configFile = stateLocation.append("productConfig");
+ IPath configFile = stateLocation.append("productConfig." + serverUrl.replace('/', '-'));
return configFile;
}
@@ -380,4 +387,41 @@ public class BugzillaPlugin extends AbstractUIPlugin {
}
});
}
+
+ private void setDefaultQueryOptions() {
+ // get the preferences store for the bugzilla preferences
+ IPreferenceStore prefs = getPreferenceStore();
+
+ prefs.setDefault(IBugzillaConstants.VALUES_STATUS,
+ BugzillaRepositoryUtil.queryOptionsToString(IBugzillaConstants.DEFAULT_STATUS_VALUES));
+
+ prefs.setDefault(IBugzillaConstants.VALUSE_STATUS_PRESELECTED,
+ BugzillaRepositoryUtil.queryOptionsToString(IBugzillaConstants.DEFAULT_PRESELECTED_STATUS_VALUES));
+
+ prefs.setDefault(IBugzillaConstants.VALUES_RESOLUTION,
+ BugzillaRepositoryUtil.queryOptionsToString(IBugzillaConstants.DEFAULT_RESOLUTION_VALUES));
+
+ prefs.setDefault(IBugzillaConstants.VALUES_SEVERITY,
+ BugzillaRepositoryUtil.queryOptionsToString(IBugzillaConstants.DEFAULT_SEVERITY_VALUES));
+
+ prefs.setDefault(IBugzillaConstants.VALUES_PRIORITY,
+ BugzillaRepositoryUtil.queryOptionsToString(IBugzillaConstants.DEFAULT_PRIORITY_VALUES));
+
+ prefs.setDefault(IBugzillaConstants.VALUES_HARDWARE,
+ BugzillaRepositoryUtil.queryOptionsToString(IBugzillaConstants.DEFAULT_HARDWARE_VALUES));
+
+ prefs.setDefault(IBugzillaConstants.VALUES_OS, BugzillaRepositoryUtil.queryOptionsToString(IBugzillaConstants.DEFAULT_OS_VALUES));
+
+ prefs.setDefault(IBugzillaConstants.VALUES_PRODUCT,
+ BugzillaRepositoryUtil.queryOptionsToString(IBugzillaConstants.DEFAULT_PRODUCT_VALUES));
+
+ prefs.setDefault(IBugzillaConstants.VALUES_COMPONENT,
+ BugzillaRepositoryUtil.queryOptionsToString(IBugzillaConstants.DEFAULT_COMPONENT_VALUES));
+
+ prefs.setDefault(IBugzillaConstants.VALUES_VERSION,
+ BugzillaRepositoryUtil.queryOptionsToString(IBugzillaConstants.DEFAULT_VERSION_VALUES));
+
+ prefs.setDefault(IBugzillaConstants.VALUES_TARGET,
+ BugzillaRepositoryUtil.queryOptionsToString(IBugzillaConstants.DEFAULT_TARGET_VALUES));
+ }
}
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/BugzillaPreferencePage.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/BugzillaPreferencePage.java
index 62fc3d8d2..45d132808 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/BugzillaPreferencePage.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/BugzillaPreferencePage.java
@@ -10,39 +10,19 @@
*******************************************************************************/
package org.eclipse.mylar.bugzilla.core;
-import java.io.IOException;
-import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
-import java.net.URLConnection;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import javax.security.auth.login.LoginException;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.preference.BooleanFieldEditor;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.IntegerFieldEditor;
import org.eclipse.jface.preference.RadioGroupFieldEditor;
-import org.eclipse.jface.preference.StringFieldEditor;
-import org.eclipse.mylar.bugzilla.core.internal.ProductConfiguration;
-import org.eclipse.mylar.bugzilla.core.internal.ProductConfigurationFactory;
-import org.eclipse.mylar.bugzilla.core.search.BugzillaQueryPageParser;
-import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
@@ -52,31 +32,31 @@ import org.eclipse.ui.IWorkbenchPreferencePage;
*/
public class BugzillaPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
- private static final String LABEL_WARNING = "Note: do not include index.cgi in URL (e.g. use https://bugs.eclipse.org/bugs)";
-
- /** Secure http server prefix */
- private static final String httpsPrefix = "https://";
+// private static final String LABEL_WARNING = "Note: do not include index.cgi in URL (e.g. use https://bugs.eclipse.org/bugs)";
- /** http prefix */
- private static final String httpPrefix = "http://";
+// /** Secure http server prefix */
+// private static final String httpsPrefix = "https://";
+//
+// /** http prefix */
+// private static final String httpPrefix = "http://";
/** The text to put into the label for the bugzilla server text box */
- private static final String bugzillaServerLabel = "Bugzilla Server: ";
+// private static final String bugzillaServerLabel = "Bugzilla Server: ";
/** Field editor for the bugzilla server in the preferences page */
- private StringFieldEditor bugzillaServer;
+// private StringFieldEditor bugzillaServer;
- private static final String bugzillaUserLabel = "Bugzilla User Name: ";
+// private static final String bugzillaUserLabel = "Bugzilla User Name: ";
- private static final String bugzillaPasswordLabel = "Bugzilla Password: ";
+// private static final String bugzillaPasswordLabel = "Bugzilla Password: ";
private RadioGroupFieldEditor bugzillaVersionEditor;
private static final String bugzillaMaxResultsLabel = "Maximum returned results: ";
- private StringFieldEditor bugzillaUser;
-
- private MyStringFieldEditor bugzillaPassword;
+// private StringFieldEditor bugzillaUser;
+//
+// private MyStringFieldEditor bugzillaPassword;
private IntegerFieldEditor maxResults;
@@ -97,8 +77,8 @@ public class BugzillaPreferencePage extends FieldEditorPreferencePage implements
// Composite container = new Composite(parent, SWT.NULL);
// GridLayout layout = new GridLayout(1, false);
// container.setLayout (layout);
- Label label = new Label(parent, SWT.NULL);
- label.setText(LABEL_WARNING);
+// Label label = new Label(parent, SWT.NULL);
+// label.setText(LABEL_WARNING);
return super.createContents(parent);
}
@@ -124,31 +104,31 @@ public class BugzillaPreferencePage extends FieldEditorPreferencePage implements
@Override
protected void createFieldEditors() {
// create a new field editor for the bugzilla server
- bugzillaServer = new StringFieldEditor(IBugzillaConstants.BUGZILLA_SERVER, bugzillaServerLabel,
- StringFieldEditor.UNLIMITED, getFieldEditorParent()) {
-
- @Override
- protected boolean doCheckState() {
- return checkServerName(getStringValue());
- }
- };
-
- // set the error message for if the server name check fails
- bugzillaServer.setErrorMessage("Server path must be a valid http(s):// url");
-
- bugzillaUser = new StringFieldEditor("", bugzillaUserLabel, StringFieldEditor.UNLIMITED, getFieldEditorParent());
- bugzillaPassword = new MyStringFieldEditor("", bugzillaPasswordLabel, StringFieldEditor.UNLIMITED,
- getFieldEditorParent());
- bugzillaPassword.getTextControl().setEchoChar('*');
+// bugzillaServer = new StringFieldEditor(IBugzillaConstants.BUGZILLA_SERVER, bugzillaServerLabel,
+// StringFieldEditor.UNLIMITED, getFieldEditorParent()) {
+//
+// @Override
+// protected boolean doCheckState() {
+// return checkServerName(getStringValue());
+// }
+// };
+//
+// // set the error message for if the server name check fails
+// bugzillaServer.setErrorMessage("Server path must be a valid http(s):// url");
+
+// bugzillaUser = new StringFieldEditor("", bugzillaUserLabel, StringFieldEditor.UNLIMITED, getFieldEditorParent());
+// bugzillaPassword = new MyStringFieldEditor("", bugzillaPasswordLabel, StringFieldEditor.UNLIMITED,
+// getFieldEditorParent());
+// bugzillaPassword.getTextControl().setEchoChar('*');
maxResults = new IntegerFieldEditor(IBugzillaConstants.MAX_RESULTS, bugzillaMaxResultsLabel,
getFieldEditorParent());
// bugzillaVersionEditor.setPreferenceStore(BugzillaPlugin.getDefault().getPreferenceStore());
- bugzillaVersionEditor = new RadioGroupFieldEditor(IBugzillaConstants.BUGZILLA_SERVER, "Bugzilla Version", 3,
- new String[][] { { IBugzillaConstants.SERVER_220, IBugzillaConstants.BUGZILLA_SERVER },
- { IBugzillaConstants.SERVER_218, IBugzillaConstants.BUGZILLA_SERVER },
- { IBugzillaConstants.SERVER_216, IBugzillaConstants.BUGZILLA_SERVER } }, getFieldEditorParent());
+ bugzillaVersionEditor = new RadioGroupFieldEditor(IBugzillaConstants.SERVER_VERSION, "Bugzilla Version", 3,
+ new String[][] { { IBugzillaConstants.SERVER_220, IBugzillaConstants.SERVER_VERSION },
+ { IBugzillaConstants.SERVER_218, IBugzillaConstants.SERVER_VERSION },
+ { IBugzillaConstants.SERVER_216, IBugzillaConstants.SERVER_VERSION } }, getFieldEditorParent());
// bugzillaVersionEditor.setPropertyChangeListener(new
// IPropertyChangeListener() {)
@@ -161,18 +141,18 @@ public class BugzillaPreferencePage extends FieldEditorPreferencePage implements
getFieldEditorParent());
// add the field editor to the preferences page
- addField(bugzillaServer);
- addField(bugzillaUser);
- addField(bugzillaPassword);
+// addField(bugzillaServer);
+// addField(bugzillaUser);
+// addField(bugzillaPassword);
addField(maxResults);
addField(bugzillaVersionEditor);
// addField(bugzilla218);
addField(refreshQueries);
// put the password and user name values into the field editors
- getCachedData();
- bugzillaUser.setStringValue(user);
- bugzillaPassword.setStringValue(password);
+// getCachedData();
+// bugzillaUser.setStringValue(user);
+// bugzillaPassword.setStringValue(password);
}
/**
@@ -185,9 +165,9 @@ public class BugzillaPreferencePage extends FieldEditorPreferencePage implements
public static void initDefaults(IPreferenceStore store) {
// set the default values for the bugzilla server and the
// most recent query
- getCachedData();
+// getCachedData();
- store.setDefault(IBugzillaConstants.BUGZILLA_SERVER, IBugzillaConstants.DEFAULT_BUGZILLA_SERVER);
+// store.setDefault(IBugzillaConstants.BUGZILLA_SERVER, IBugzillaConstants.ECLIPSE_BUGZILLA_URL);
store.setDefault(IBugzillaConstants.MOST_RECENT_QUERY, "");
store.setDefault(IBugzillaConstants.SERVER_VERSION, IBugzillaConstants.SERVER_220);
@@ -195,9 +175,6 @@ public class BugzillaPreferencePage extends FieldEditorPreferencePage implements
store.setDefault(IBugzillaConstants.REFRESH_QUERY, false);
store.setDefault(IBugzillaConstants.MAX_RESULTS, 100);
-
- // set the default query options for the bugzilla search
- setDefaultQueryOptions();
}
@Override
@@ -208,9 +185,9 @@ public class BugzillaPreferencePage extends FieldEditorPreferencePage implements
* set user and password to the new default values and then give these
* values to storeCache() to update the keyring
*/
- user = bugzillaUser.getStringValue();
- password = bugzillaPassword.getStringValue();
- storeCache(user, password, true);
+// user = bugzillaUser.getStringValue();
+// password = bugzillaPassword.getStringValue();
+// storeCache(user, password, true);
}
@Override
@@ -238,71 +215,61 @@ public class BugzillaPreferencePage extends FieldEditorPreferencePage implements
BugzillaPlugin.getDefault().getPreferenceStore().getDefaultInt(IBugzillaConstants.MAX_RESULTS));
}
- String oldBugzillaServer = BugzillaPlugin.getDefault().getServerName();
- ProductConfiguration configuration = null;
-
- try {
-
- // append "/show_bug.cgi" to url provided for cases where the
- // connection is successful,
- // but full path hasn't been specified (i.e.
- // http://hipikat.cs.ubc.ca:8081)
- URL serverURL = new URL(bugzillaServer.getStringValue() + "/show_bug.cgi");
-
- URLConnection cntx = BugzillaPlugin.getDefault().getUrlConnection(serverURL);
- if (cntx == null || !(cntx instanceof HttpURLConnection))
- return false;
-
- HttpURLConnection serverConnection = (HttpURLConnection) cntx;
-
- serverConnection.connect();
-
- int responseCode = serverConnection.getResponseCode();
-
- if (responseCode != HttpURLConnection.HTTP_OK)
- throw new BugzillaException("No Bugzilla server detected at " + bugzillaServer.getStringValue() + ".");
-
- try {
- configuration = ProductConfigurationFactory.getInstance().getConfiguration(
- bugzillaServer.getStringValue());
- } catch (IOException ex) {
- MessageDialog.openInformation(null, "Bugzilla query parameters check",
- "An error occurred while pre-fetching valid search attributes: \n\n" + ex.getClass().getName()
- + ": " + ex.getMessage() + "\n\nOffline submission of new bugs will be disabled.");
- }
- }
-
- catch (Exception e) {
- if (!MessageDialog.openQuestion(null, "Bugzilla Server Error", "Error validating Bugzilla Server.\n\n"
- + e.getMessage() + "\n\nKeep specified server location anyway?")) {
- bugzillaServer.setStringValue(oldBugzillaServer);
- return false;
- }
- }
-
+// ProductConfiguration configuration = null;
+// String urlString = bugzillaServer.getStringValue();
+// try {
+// URL serverURL = new URL(urlString + "/show_bug.cgi");
+// URLConnection cntx = BugzillaPlugin.getDefault().getUrlConnection(serverURL);
+// if (cntx == null || !(cntx instanceof HttpURLConnection))
+// return false;
+//
+// HttpURLConnection serverConnection = (HttpURLConnection) cntx;
+//
+// serverConnection.connect();
+//
+// int responseCode = serverConnection.getResponseCode();
+//
+// if (responseCode != HttpURLConnection.HTTP_OK)
+// throw new BugzillaException("No Bugzilla server detected at " + bugzillaServer.getStringValue() + ".");
+//
+// try {
+// configuration = ProductConfigurationFactory.getInstance().getConfiguration(
+// bugzillaServer.getStringValue());
+// } catch (IOException ex) {
+// MessageDialog.openInformation(null, "Bugzilla query parameters check",
+// "An error occurred while pre-fetching valid search attributes: \n\n" + ex.getClass().getName()
+// + ": " + ex.getMessage() + "\n\nOffline submission of new bugs will be disabled.");
+// }
+// } catch (Exception e) {
+// if (!MessageDialog.openQuestion(null, "Bugzilla Server Error", "Error validating Bugzilla Server.\n\n"
+// + e.getMessage() + "\n\nKeep specified server location anyway?")) {
+// return false;
+// }
+// }
+// BugzillaPlugin.getDefault().setProductConfiguration(urlString, configuration);
+// IPath configFile = BugzillaPlugin.getDefault().getProductConfigurationCachePath(urlString);
+// if (configuration != null) {
+//
+// try {
+// ProductConfigurationFactory.getInstance().writeConfiguration(configuration, configFile.toFile());
+// } catch (IOException e) {
+// BugzillaPlugin.log(e);
+// configFile.toFile().delete();
+// }
+// } else {
+// configFile.toFile().delete();
+// }
+
+
// save the preferences that were changed
// BugzillaPlugin.getDefault().savePluginPreferences();
- bugzillaServer.store();
+// bugzillaServer.store();
// store the username and password from the editor field
- user = bugzillaUser.getStringValue();
- password = bugzillaPassword.getStringValue();
- storeCache(user, password, true);
-
- BugzillaPlugin.getDefault().setProductConfiguration(configuration);
- IPath configFile = BugzillaPlugin.getDefault().getProductConfigurationCachePath();
- if (configuration != null) {
-
- try {
- ProductConfigurationFactory.getInstance().writeConfiguration(configuration, configFile.toFile());
- } catch (IOException e) {
- BugzillaPlugin.log(e);
- configFile.toFile().delete();
- }
- } else {
- configFile.toFile().delete();
- }
+// user = bugzillaUser.getStringValue();
+// password = bugzillaPassword.getStringValue();
+// storeCache(user, password, true);
return true;
}
@@ -312,342 +279,126 @@ public class BugzillaPreferencePage extends FieldEditorPreferencePage implements
return true;
}
- /**
- * Determine if the name starts with https:// or http://
- *
- * @param name
- * The string that needs to be checked
- * @return <code>true</code> if the name starts with https:// or http://,
- * otherwise <code>false</code>
- */
- private boolean checkServerName(String name) {
- if (name.startsWith(httpsPrefix) || name.startsWith(httpPrefix))
- return true;
- return false;
- }
+// private boolean checkServerName(String name) {
+// if (name.startsWith(httpsPrefix) || name.startsWith(httpPrefix))
+// return true;
+// return false;
+// }
@Override
protected void initialize() {
super.initialize();
// put the password and user name values into the field editors
- getCachedData();
- bugzillaUser.setStringValue(user);
- bugzillaPassword.setStringValue(password);
+// getCachedData();
+// bugzillaUser.setStringValue(user);
+// bugzillaPassword.setStringValue(password);
}
public void init(IWorkbench workbench) {
// Don't need to do anything here with the workbench
}
- /**
- * Hack private class to make StringFieldEditor.refreshValidState() a
- * publicly acessible method.
- *
- * @see org.eclipse.jface.preference.StringFieldEditor#refreshValidState()
- */
- private static class MyStringFieldEditor extends StringFieldEditor {
- public MyStringFieldEditor(String name, String labelText, int style, Composite parent) {
- super(name, labelText, style, parent);
- }
-
- @Override
- public void refreshValidState() {
- super.refreshValidState();
- }
-
- @Override
- public Text getTextControl() {
- return super.getTextControl();
- }
-
- }
-
- /**
- * Update all of the query options for the bugzilla search page
- *
- * @param monitor
- * A reference to a progress monitor
- */
- public static void updateQueryOptions(IProgressMonitor monitor) throws LoginException {
- // make a new page parser so that we can get the information from the
- // server
- BugzillaQueryPageParser parser = new BugzillaQueryPageParser(monitor);
- if (!parser.wasSuccessful())
- return;
-
- // get the preferences store so that we can change the data in it
- IPreferenceStore prefs = BugzillaPlugin.getDefault().getPreferenceStore();
-
- // get the new values for the status field and increment the status
- // monitor
- prefs.setValue(IBugzillaConstants.STATUS_VALUES, queryOptionsToString(parser.getStatusValues()));
- monitor.worked(1);
-
- // get the new values for the preselected status values and increment
- // the status monitor
- prefs.setValue(IBugzillaConstants.PRESELECTED_STATUS_VALUES, queryOptionsToString(parser
- .getPreselectedStatusValues()));
- monitor.worked(1);
-
- // get the new values for the resolution field and increment the status
- // monitor
- prefs.setValue(IBugzillaConstants.RESOLUTION_VALUES, queryOptionsToString(parser.getResolutionValues()));
- monitor.worked(1);
-
- // get the new values for the severity field and increment the status
- // monitor
- prefs.setValue(IBugzillaConstants.SEVERITY_VALUES, queryOptionsToString(parser.getSeverityValues()));
- monitor.worked(1);
-
- // get the new values for the priority field and increment the status
- // monitor
- prefs.setValue(IBugzillaConstants.PRIORITY_VALUES, queryOptionsToString(parser.getPriorityValues()));
- monitor.worked(1);
-
- // get the new values for the hardware field and increment the status
- // monitor
- prefs.setValue(IBugzillaConstants.HARDWARE_VALUES, queryOptionsToString(parser.getHardwareValues()));
- monitor.worked(1);
-
- // get the new values for the OS field and increment the status monitor
- prefs.setValue(IBugzillaConstants.OS_VALUES, queryOptionsToString(parser.getOSValues()));
- monitor.worked(1);
-
- // get the new values for the product field and increment the status
- // monitor
- prefs.setValue(IBugzillaConstants.PRODUCT_VALUES, queryOptionsToString(parser.getProductValues()));
- monitor.worked(1);
-
- // get the new values for the component field and increment the status
- // monitor
- prefs.setValue(IBugzillaConstants.COMPONENT_VALUES, queryOptionsToString(parser.getComponentValues()));
- monitor.worked(1);
-
- // get the new values for the version field and increment the status
- // monitor
- prefs.setValue(IBugzillaConstants.VERSION_VALUES, queryOptionsToString(parser.getVersionValues()));
- monitor.worked(1);
-
- // get the new values for the target field and increment the status
- // monitor
- prefs.setValue(IBugzillaConstants.TARGET_VALUES, queryOptionsToString(parser.getTargetValues()));
- monitor.worked(1);
- }
-
- /**
- * Set the default query options for the bugzilla search
- */
- private static void setDefaultQueryOptions() {
- // get the preferences store for the bugzilla preferences
- IPreferenceStore prefs = BugzillaPlugin.getDefault().getPreferenceStore();
-
- // get the default status values from the store and set them as the
- // default options
- prefs.setDefault(IBugzillaConstants.STATUS_VALUES,
- queryOptionsToString(IBugzillaConstants.DEFAULT_STATUS_VALUES));
-
- // get the default preselected status values from the store and set them
- // as the default options
- prefs.setDefault(IBugzillaConstants.PRESELECTED_STATUS_VALUES,
- queryOptionsToString(IBugzillaConstants.DEFAULT_PRESELECTED_STATUS_VALUES));
-
- // get the default resolution values from the store and set them as the
- // default options
- prefs.setDefault(IBugzillaConstants.RESOLUTION_VALUES,
- queryOptionsToString(IBugzillaConstants.DEFAULT_RESOLUTION_VALUES));
-
- // get the default severity values from the store and set them as the
- // default options
- prefs.setDefault(IBugzillaConstants.SEVERITY_VALUES,
- queryOptionsToString(IBugzillaConstants.DEFAULT_SEVERITY_VALUES));
-
- // get the default priority values from the store and set them as the
- // default options
- prefs.setDefault(IBugzillaConstants.PRIORITY_VALUES,
- queryOptionsToString(IBugzillaConstants.DEFAULT_PRIORITY_VALUES));
-
- // get the default hardware values from the store and set them as the
- // default options
- prefs.setDefault(IBugzillaConstants.HARDWARE_VALUES,
- queryOptionsToString(IBugzillaConstants.DEFAULT_HARDWARE_VALUES));
-
- // get the default os values from the store and set them as the default
- // options
- prefs.setDefault(IBugzillaConstants.OS_VALUES, queryOptionsToString(IBugzillaConstants.DEFAULT_OS_VALUES));
-
- // get the default product values from the store and set them as the
- // default options
- prefs.setDefault(IBugzillaConstants.PRODUCT_VALUES,
- queryOptionsToString(IBugzillaConstants.DEFAULT_PRODUCT_VALUES));
-
- // get the default component values from the store and set them as the
- // default options
- prefs.setDefault(IBugzillaConstants.COMPONENT_VALUES,
- queryOptionsToString(IBugzillaConstants.DEFAULT_COMPONENT_VALUES));
-
- // get the default version values from the store and set them as the
- // default options
- prefs.setDefault(IBugzillaConstants.VERSION_VALUES,
- queryOptionsToString(IBugzillaConstants.DEFAULT_VERSION_VALUES));
-
- // get the default target values from the store and set them as the
- // default options
- prefs.setDefault(IBugzillaConstants.TARGET_VALUES,
- queryOptionsToString(IBugzillaConstants.DEFAULT_TARGET_VALUES));
- }
-
- /**
- * Turn the array of query options into a string separated by a '!'
- *
- * @param array
- * A string array of query values to be turned into a string
- * @return The string containing the query options in the array
- */
- private static String queryOptionsToString(String[] array) {
- // make a new string buffer and go through each element in the array
- StringBuffer buffer = new StringBuffer();
- for (int i = 0; i < array.length; i++) {
- // append the new value to the end and add a '!' as a delimiter
- buffer.append(array[i]);
- buffer.append("!");
- }
-
- // return the buffer converted to a string
- return buffer.toString();
- }
-
- /**
- * Take a string of query options and convert it to an array
- *
- * @param values
- * A string of query options delimited by a '!'
- * @return A string array containing the query values
- */
- public static String[] queryOptionsToArray(String values) {
- // create a new string buffer and array list
- StringBuffer buffer = new StringBuffer();
- List<String> options = new ArrayList<String>();
-
- // make the string into a character array
- char[] chars = values.toCharArray();
-
- // go through each of the characters in the character array
- for (int i = 0; i < chars.length; i++) {
- if (chars[i] == '!') {
- // if the character is the delimiting value add the buffer to
- // the list
- // and reinitialize it
- options.add(buffer.toString());
- buffer = new StringBuffer();
- } else {
- // if it is a regular character, just add it to the string
- // buffer
- buffer.append(chars[i]);
- }
- }
-
- // create a new string array with the same size as the array list
- String[] array = new String[options.size()];
-
- // put each element from the list into the array
- for (int j = 0; j < options.size(); j++)
- array[j] = options.get(j);
- return array;
- }
-
- /**
- * Get the password and user name from the keyring
- *
- */
- @SuppressWarnings("unchecked")
- private static void getCachedData() {
- // get the map containing the password and username
- Map<String, String> map = Platform.getAuthorizationInfo(FAKE_URL, "Bugzilla", AUTH_SCHEME);
-
- // get the information from the map and save it
- if (map != null) {
- String username = map.get(INFO_USERNAME);
-
- if (username != null)
- user = username;
- else
- user = new String("");
-
- String pwd = map.get(INFO_PASSWORD);
-
- if (pwd != null)
- password = pwd;
- else
- password = new String("");
-
- return;
- }
-
- // if the map was null, set the username and password to be null
- user = new String("");
- password = new String("");
- }
-
- /**
- * Gets the bugzilla user name from the preferences
- *
- * @return The string containing the user name
- */
- public static String getUserName() {
- getCachedData();
- return user;
- }
-
- /**
- * Gets the bugzilla password from the preferences
- *
- * @return The string containing the password
- */
- public static String getPassword() {
- getCachedData();
- return password;
- }
-
- /**
- * store the password and username in the keyring
- *
- * @param username
- * The user name to store
- * @param storePassword
- * The password to store
- * @param createIfAbsent
- * Whether to create the map if it doesn't exist or not
- */
- @SuppressWarnings("unchecked")
- private static void storeCache(String username, String storePassword, boolean createIfAbsent) {
- // put the password into the Platform map
- Map<String, String> map = Platform.getAuthorizationInfo(FAKE_URL, "Bugzilla", AUTH_SCHEME);
-
- // if the map doesn't exist, see if we can create a new one
- if (map == null) {
- if (!createIfAbsent)
- return;
- map = new java.util.HashMap<String, String>(10);
- }
-
- // add the username and password to the map
- if (username != null)
- map.put(INFO_USERNAME, username);
- if (storePassword != null)
- map.put(INFO_PASSWORD, storePassword);
-
- try {
- // write the map to the keyring
- Platform.addAuthorizationInfo(FAKE_URL, "Bugzilla", AUTH_SCHEME, map);
- } catch (CoreException e) {
- BugzillaPlugin.log(e.getStatus());
- }
- }
-
- private static String user;
-
- private static String password;
+// /**
+// * Hack private class to make StringFieldEditor.refreshValidState() a
+// * publicly acessible method.
+// *
+// * @see org.eclipse.jface.preference.StringFieldEditor#refreshValidState()
+// */
+// private static class MyStringFieldEditor extends StringFieldEditor {
+// public MyStringFieldEditor(String name, String labelText, int style, Composite parent) {
+// super(name, labelText, style, parent);
+// }
+//
+// @Override
+// public void refreshValidState() {
+// super.refreshValidState();
+// }
+//
+// @Override
+// public Text getTextControl() {
+// return super.getTextControl();
+// }
+// }
+
+// @SuppressWarnings("unchecked")
+// private static void getCachedData() {
+// // get the map containing the password and username
+// Map<String, String> map = Platform.getAuthorizationInfo(FAKE_URL, "Bugzilla", AUTH_SCHEME);
+//
+// // get the information from the map and save it
+// if (map != null) {
+// String username = map.get(INFO_USERNAME);
+//
+// if (username != null)
+// user = username;
+// else
+// user = new String("");
+//
+// String pwd = map.get(INFO_PASSWORD);
+//
+// if (pwd != null)
+// password = pwd;
+// else
+// password = new String("");
+//
+// return;
+// }
+//
+// // if the map was null, set the username and password to be null
+// user = new String("");
+// password = new String("");
+// }
+
+// /**
+// * Gets the bugzilla user name from the preferences
+// *
+// * @return The string containing the user name
+// */
+// public static String getUserName() {
+// getCachedData();
+// return user;
+// }
+//
+// /**
+// * Gets the bugzilla password from the preferences
+// *
+// * @return The string containing the password
+// */
+// public static String getPassword() {
+// getCachedData();
+// return password;
+// }
+
+// @SuppressWarnings("unchecked")
+// private static void storeCache(String username, String storePassword, boolean createIfAbsent) {
+// // put the password into the Platform map
+// Map<String, String> map = Platform.getAuthorizationInfo(FAKE_URL, "Bugzilla", AUTH_SCHEME);
+//
+// // if the map doesn't exist, see if we can create a new one
+// if (map == null) {
+// if (!createIfAbsent)
+// return;
+// map = new java.util.HashMap<String, String>(10);
+// }
+//
+// // add the username and password to the map
+// if (username != null)
+// map.put(INFO_USERNAME, username);
+// if (storePassword != null)
+// map.put(INFO_PASSWORD, storePassword);
+//
+// try {
+// // write the map to the keyring
+// Platform.addAuthorizationInfo(FAKE_URL, "Bugzilla", AUTH_SCHEME, map);
+// } catch (CoreException e) {
+// BugzillaPlugin.log(e.getStatus());
+// }
+// }
+
+// private static String user;
+//
+// private static String password;
public static final String INFO_PASSWORD = "org.eclipse.team.cvs.core.password"; //$NON-NLS-1$
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/BugzillaRepository.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/BugzillaRepository.java
deleted file mode 100644
index 66b775894..000000000
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/BugzillaRepository.java
+++ /dev/null
@@ -1,428 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003 - 2005 University Of British Columbia and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * University Of British Columbia - initial API and implementation
- *******************************************************************************/
-package org.eclipse.mylar.bugzilla.core;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.UnsupportedEncodingException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLConnection;
-import java.net.URLEncoder;
-import java.security.KeyManagementException;
-import java.security.NoSuchAlgorithmException;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.security.auth.login.LoginException;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.mylar.bugzilla.core.internal.BugParser;
-import org.eclipse.mylar.bugzilla.core.internal.NewBugParser;
-import org.eclipse.mylar.bugzilla.core.internal.ProductParser;
-import org.eclipse.mylar.bugzilla.core.offline.OfflineReportsFile;
-
-/**
- * Singleton class that creates <code>BugReport</code> objects by fetching
- * bug's state and contents from the Bugzilla server.
- *
- * @author Mik Kersten (hardening of initial prototype)
- */
-public class BugzillaRepository {
-
- /**
- * Test method.
- */
- public static void main(String[] args) throws Exception {
- instance = new BugzillaRepository(BugzillaPlugin.getDefault().getServerName() + "/long_list.cgi?buglist=");
- BugReport bug = instance.getBug(16161);
- System.out.println("Bug " + bug.getId() + ": " + bug.getSummary());
- for (Iterator<Attribute> it = bug.getAttributes().iterator(); it.hasNext();) {
- Attribute attribute = it.next();
- System.out.println(attribute.getName() + ": " + attribute.getValue());
- }
- System.out.println(bug.getDescription());
- for (Iterator<Comment> it = bug.getComments().iterator(); it.hasNext();) {
- Comment comment = it.next();
- System.out
- .println(comment.getAuthorName() + "<" + comment.getAuthor() + "> (" + comment.getCreated() + ")");
- System.out.print(comment.getText());
- System.out.println();
- }
- }
-
- /** URL of the Bugzilla server */
- private static String bugzillaUrl;
-
- /** singleton instance */
- private static BugzillaRepository instance;
-
- /**
- * Constructor
- *
- * @param bugzillaUrl -
- * the url of the bugzilla repository
- */
- private BugzillaRepository(String bugzillaUrl) {
- BugzillaRepository.bugzillaUrl = bugzillaUrl;
- }
-
- /**
- * Get the singleton instance of the <code>BugzillaRepository</code>
- *
- * @return The instance of the repository
- */
- public synchronized static BugzillaRepository getInstance() {
- if (instance == null) {
- // if the instance hasn't been created yet, create one
- instance = new BugzillaRepository(BugzillaPlugin.getDefault().getServerName());
- }
-
- // fix bug 58 by updating url if it changes
- if (!BugzillaRepository.bugzillaUrl.equals(BugzillaPlugin.getDefault().getServerName())) {
- BugzillaRepository.bugzillaUrl = BugzillaPlugin.getDefault().getServerName();
- }
-
- return instance;
- }
-
- /**
- * Get a bug from the server
- *
- * @param id -
- * the id of the bug to get
- * @return - a <code>BugReport</code> for the selected bug or null if it
- * doesn't exist
- * @throws IOException
- */
- public BugReport getBug(int id) throws IOException, MalformedURLException, LoginException {
-
- BufferedReader in = null;
- try {
-
- // create a new input stream for getting the bug
-
- String url = bugzillaUrl + "/show_bug.cgi?id=" + id;
-
- // allow the use to only see the operations that they can do to a
- // bug if they have
- // their user name and password in the preferences
- if (BugzillaPreferencePage.getUserName() != null && !BugzillaPreferencePage.getUserName().equals("")
- && BugzillaPreferencePage.getPassword() != null && !BugzillaPreferencePage.getPassword().equals("")) {
- /*
- * The UnsupportedEncodingException exception for
- * URLEncoder.encode() should not be thrown, since every
- * implementation of the Java platform is required to support
- * the standard charset "UTF-8"
- */
- url += "&GoAheadAndLogIn=1&Bugzilla_login="
- + URLEncoder.encode(BugzillaPreferencePage.getUserName(), "UTF-8") + "&Bugzilla_password="
- + URLEncoder.encode(BugzillaPreferencePage.getPassword(), "UTF-8");
- }
-
- URL bugUrl = new URL(url);
- URLConnection connection = BugzillaPlugin.getDefault().getUrlConnection(bugUrl);
- if (connection != null) {
- InputStream input = connection.getInputStream();
- if (input != null) {
- in = new BufferedReader(new InputStreamReader(input));
-
- // get the actual bug fron the server and return it
- BugReport bug = BugParser.parseBug(in, id,
- BugzillaPlugin.getDefault().getServerName(),
- BugzillaPlugin.getDefault().isServerCompatability218(),
- BugzillaPreferencePage.getUserName(), BugzillaPreferencePage.getPassword(),
- connection.getContentType());
- return bug;
- }
- }
- // TODO handle the error
- return null;
- } catch (MalformedURLException e) {
- throw e;
- } catch (IOException e) {
- throw e;
- } catch (LoginException e) {
- throw e;
- } catch (Exception e) {
- // throw an exception if there is a problem reading the bug from the
- // server
- // e.printStackTrace();
- // throw new IOException(e.getMessage());
- BugzillaPlugin.log(new Status(IStatus.ERROR, IBugzillaConstants.PLUGIN_ID, IStatus.ERROR,
- "Problem getting report", e));
- return null;
- } finally {
- try {
- if (in != null)
- in.close();
- } catch (IOException e) {
- BugzillaPlugin.log(new Status(IStatus.ERROR, IBugzillaConstants.PLUGIN_ID, IStatus.ERROR,
- "Problem closing the stream", e));
- }
- }
- }
-
- /**
- * Get a bug from the server. If a bug with the given id is saved offline,
- * the offline version is returned instead.
- *
- * @param id -
- * the id of the bug to get
- * @return - a <code>BugReport</code> for the selected bug or null if it
- * doesn't exist
- * @throws IOException,
- * MalformedURLException, LoginException
- */
- public BugReport getCurrentBug(int id) throws MalformedURLException, LoginException, IOException {
- // Look among the offline reports for a bug with the given id.
- OfflineReportsFile reportsFile = BugzillaPlugin.getDefault().getOfflineReports();
- int offlineId = reportsFile.find(id);
-
- // If an offline bug was found, return it if possible.
- if (offlineId != -1) {
- IBugzillaBug bug = reportsFile.elements().get(offlineId);
- if (bug instanceof BugReport) {
- return (BugReport) bug;
- }
- }
-
- // If a suitable offline report was not found, try to get one from the
- // server.
- return getBug(id);
- }
-
- /**
- * Get the list of products when creating a new bug
- *
- * @return The list of valid products a bug can be logged against
- * @throws IOException
- */
- public List<String> getProductList() throws IOException, LoginException, Exception {
- BufferedReader in = null;
- try {
- // connect to the bugzilla server
- String urlText = "";
-
- // use the usename and password to get into bugzilla if we have it
- if (BugzillaPreferencePage.getUserName() != null && !BugzillaPreferencePage.getUserName().equals("")
- && BugzillaPreferencePage.getPassword() != null && !BugzillaPreferencePage.getPassword().equals("")) {
- /*
- * The UnsupportedEncodingException exception for
- * URLEncoder.encode() should not be thrown, since every
- * implementation of the Java platform is required to support
- * the standard charset "UTF-8"
- */
- urlText += "?GoAheadAndLogIn=1&Bugzilla_login="
- + URLEncoder.encode(BugzillaPreferencePage.getUserName(), "UTF-8") + "&Bugzilla_password="
- + URLEncoder.encode(BugzillaPreferencePage.getPassword(), "UTF-8");
- }
-
- URL url = new URL(bugzillaUrl + "/enter_bug.cgi" + urlText);
-
- URLConnection cntx = BugzillaPlugin.getDefault().getUrlConnection(url);
- if (cntx != null) {
- InputStream input = cntx.getInputStream();
- if (input != null) {
-
- // create a new input stream for getting the bug
- in = new BufferedReader(new InputStreamReader(input));
-
- return new ProductParser(in).getProducts();
- }
- }
- return null;
- } finally {
- try {
- if (in != null)
- in.close();
- } catch (IOException e) {
- BugzillaPlugin.log(new Status(IStatus.ERROR, IBugzillaConstants.PLUGIN_ID, IStatus.ERROR,
- "Problem closing the stream", e));
- }
- }
- }
-
- /**
- * Get the attribute values for a new bug
- *
- * @param nbm
- * A reference to a NewBugModel to store all of the data
- * @throws Exception
- */
- public void getnewBugAttributes(NewBugModel nbm, boolean getProd) throws Exception {
- BufferedReader in = null;
- try {
- // create a new input stream for getting the bug
- String prodname = URLEncoder.encode(nbm.getProduct(), "UTF-8");
-
- String url = bugzillaUrl + "/enter_bug.cgi";
-
- // use the proper url if we dont know the product yet
- if (!getProd)
- url += "?product=" + prodname + "&";
- else
- url += "?";
-
- // add the password and username to the url so that bugzilla logs us
- // in
- /*
- * The UnsupportedEncodingException exception for
- * URLEncoder.encode() should not be thrown, since every
- * implementation of the Java platform is required to support the
- * standard charset "UTF-8"
- */
- url += "&GoAheadAndLogIn=1&Bugzilla_login="
- + URLEncoder.encode(BugzillaPreferencePage.getUserName(), "UTF-8") + "&Bugzilla_password="
- + URLEncoder.encode(BugzillaPreferencePage.getPassword(), "UTF-8");
-
- URL bugUrl = new URL(url);
- URLConnection cntx = BugzillaPlugin.getDefault().getUrlConnection(bugUrl);
- if (cntx != null) {
- InputStream input = cntx.getInputStream();
- if (input != null) {
- in = new BufferedReader(new InputStreamReader(input));
-
- new NewBugParser(in).parseBugAttributes(nbm, getProd);
- }
- }
-
- } catch (Exception e) {
-
- if (e instanceof KeyManagementException || e instanceof NoSuchAlgorithmException
- || e instanceof IOException) {
- if (MessageDialog.openQuestion(null, "Bugzilla Connect Error",
- "Unable to connect to Bugzilla server.\n"
- + "Bug report will be created offline and saved for submission later.")) {
- nbm.setConnected(false);
- getProdConfigAttributes(nbm);
- } else
- throw new Exception("Bug report will not be created.");
- } else
- throw e;
- } finally {
- try {
- if (in != null)
- in.close();
- } catch (IOException e) {
- BugzillaPlugin.log(new Status(IStatus.ERROR, IBugzillaConstants.PLUGIN_ID, IStatus.ERROR,
- "Problem closing the stream", e));
- }
- }
- }
-
- /**
- * Get the bugzilla url that the repository is using
- *
- * @return A <code>String</code> containing the url of the bugzilla server
- */
- public static String getURL() {
- return bugzillaUrl;
- }
-
- /**
- * Method to get attributes from ProductConfiguration if unable to connect
- * to Bugzilla server
- *
- * @param model -
- * the NewBugModel to store the attributes
- */
- public void getProdConfigAttributes(NewBugModel model) {
-
- HashMap<String, Attribute> attributes = new HashMap<String, Attribute>();
-
- // ATTRIBUTE: Severity
- Attribute a = new Attribute("Severity");
- a.setParameterName("bug_severity");
- // get optionValues from ProductConfiguration
- String[] optionValues = BugzillaPlugin.getDefault().getProductConfiguration().getSeverities();
- // add option values from ProductConfiguration to Attribute optionValues
- for (int i = 0; i < optionValues.length; i++) {
- a.addOptionValue(optionValues[i], optionValues[i]);
- }
- // add Attribute to model
- attributes.put("severites", a);
-
- // ATTRIBUTE: OS
- a = new Attribute("OS");
- a.setParameterName("op_sys");
- optionValues = BugzillaPlugin.getDefault().getProductConfiguration().getOSs();
- for (int i = 0; i < optionValues.length; i++) {
- a.addOptionValue(optionValues[i], optionValues[i]);
- }
- attributes.put("OSs", a);
-
- // ATTRIBUTE: Platform
- a = new Attribute("Platform");
- a.setParameterName("rep_platform");
- optionValues = BugzillaPlugin.getDefault().getProductConfiguration().getPlatforms();
- for (int i = 0; i < optionValues.length; i++) {
- a.addOptionValue(optionValues[i], optionValues[i]);
- }
- attributes.put("platforms", a);
-
- // ATTRIBUTE: Version
- a = new Attribute("Version");
- a.setParameterName("version");
- optionValues = BugzillaPlugin.getDefault().getProductConfiguration().getVersions(model.getProduct());
- for (int i = 0; i < optionValues.length; i++) {
- a.addOptionValue(optionValues[i], optionValues[i]);
- }
- attributes.put("versions", a);
-
- // ATTRIBUTE: Component
- a = new Attribute("Component");
- a.setParameterName("component");
- optionValues = BugzillaPlugin.getDefault().getProductConfiguration().getComponents(model.getProduct());
- for (int i = 0; i < optionValues.length; i++) {
- a.addOptionValue(optionValues[i], optionValues[i]);
- }
- attributes.put("components", a);
-
- // ATTRIBUTE: Priority
- a = new Attribute("Priority");
- a.setParameterName("bug_severity");
- optionValues = BugzillaPlugin.getDefault().getProductConfiguration().getPriorities();
- for (int i = 0; i < optionValues.length; i++) {
- a.addOptionValue(optionValues[i], optionValues[i]);
- }
-
- // set NBM Attributes (after all Attributes have been created, and added
- // to attributes map)
- model.attributes = attributes;
- }
-
- public static String getBugUrl(int id) {
- String url = BugzillaPlugin.getDefault().getServerName() + "/show_bug.cgi?id=" + id;
- try {
- if (BugzillaPreferencePage.getUserName() != null && !BugzillaPreferencePage.getUserName().equals("")
- && BugzillaPreferencePage.getPassword() != null && !BugzillaPreferencePage.getPassword().equals("")) {
-
- url += "&GoAheadAndLogIn=1&Bugzilla_login="
- + URLEncoder.encode(BugzillaPreferencePage.getUserName(), "UTF-8") + "&Bugzilla_password="
- + URLEncoder.encode(BugzillaPreferencePage.getPassword(), "UTF-8");
- }
- } catch (UnsupportedEncodingException e) {
- return "";
- }
- return url;
- }
-
- public static String getBugUrlWithoutLogin(int id) {
- String url = BugzillaPlugin.getDefault().getServerName() + "/show_bug.cgi?id=" + id;
- return url;
- }
-}
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/BugzillaRepositoryUtil.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/BugzillaRepositoryUtil.java
new file mode 100644
index 000000000..d0d8e0d1c
--- /dev/null
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/BugzillaRepositoryUtil.java
@@ -0,0 +1,508 @@
+/*******************************************************************************
+ * Copyright (c) 2003 - 2005 University Of British Columbia and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * University Of British Columbia - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.mylar.bugzilla.core;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.UnsupportedEncodingException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.net.URLEncoder;
+import java.security.KeyManagementException;
+import java.security.NoSuchAlgorithmException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import javax.security.auth.login.LoginException;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.mylar.bugzilla.core.internal.BugParser;
+import org.eclipse.mylar.bugzilla.core.internal.NewBugParser;
+import org.eclipse.mylar.bugzilla.core.internal.OfflineReportsFile;
+import org.eclipse.mylar.bugzilla.core.internal.ProductParser;
+import org.eclipse.mylar.bugzilla.core.search.BugzillaQueryPageParser;
+import org.eclipse.mylar.tasklist.MylarTaskListPlugin;
+import org.eclipse.mylar.tasklist.repositories.TaskRepository;
+
+/**
+ * Singleton class that creates <code>BugReport</code> objects by fetching
+ * bug's state and contents from the Bugzilla server.
+ *
+ * @author Mik Kersten (hardening of initial prototype)
+ */
+public class BugzillaRepositoryUtil {
+
+// /**
+// * Test method.
+// */
+// public static void main(String[] args) throws Exception {
+// instance = new BugzillaRepositoryUtil(BugzillaPlugin.getDefault().getServerName() + "/long_list.cgi?buglist=");
+// BugReport bug = instance.getBug(16161);
+// System.out.println("Bug " + bug.getId() + ": " + bug.getSummary());
+// for (Iterator<Attribute> it = bug.getAttributes().iterator(); it.hasNext();) {
+// Attribute attribute = it.next();
+// System.out.println(attribute.getName() + ": " + attribute.getValue());
+// }
+// System.out.println(bug.getDescription());
+// for (Iterator<Comment> it = bug.getComments().iterator(); it.hasNext();) {
+// Comment comment = it.next();
+// System.out
+// .println(comment.getAuthorName() + "<" + comment.getAuthor() + "> (" + comment.getCreated() + ")");
+// System.out.print(comment.getText());
+// System.out.println();
+// }
+// }
+
+// /** URL of the Bugzilla server */
+// private static String bugzillaUrl;
+
+// private static BugzillaRepositoryUtil INSTANCE = new BugzillaRepositoryUtil();
+
+ private static final char PREF_DELIM_REPOSITORY = ':';
+ private static final String POST_ARGS_SHOW_BUG = "/show_bug.cgi?id=";
+ /**
+ * Constructor
+ *
+ * @param bugzillaUrl -
+ * the url of the bugzilla repository
+ */
+// private BugzillaRepositoryUtil(String bugzillaUrl) {
+// BugzillaRepositoryUtil.bugzillaUrl = bugzillaUrl;
+// }
+
+ private static final String POST_ARGS_LOGIN = "&GoAheadAndLogIn=1&Bugzilla_login=";
+
+ /**
+ * Get the singleton instance of the <code>BugzillaRepositoryUtil</code>
+ *
+ * @return The instance of the repository
+ */
+// public synchronized static BugzillaRepositoryUtil getInstance() {
+// if (instance == null) {
+// // if the instance hasn't been created yet, create one
+// instance = new BugzillaRepositoryUtil(BugzillaPlugin.getDefault().getServerName());
+// }
+//
+// if (!BugzillaRepositoryUtil.bugzillaUrl.equals(BugzillaPlugin.getDefault().getServerName())) {
+// BugzillaRepositoryUtil.bugzillaUrl = BugzillaPlugin.getDefault().getServerName();
+// }
+
+// return INSTANCE;
+// }
+
+ public static BugReport getBug(String repositoryUrl, int id) throws IOException, MalformedURLException, LoginException {
+
+ BufferedReader in = null;
+ try {
+
+ // create a new input stream for getting the bug
+ TaskRepository repository = MylarTaskListPlugin.getRepositoryManager().getRepository(BugzillaPlugin.REPOSITORY_KIND, repositoryUrl);
+
+ String url = repositoryUrl + POST_ARGS_SHOW_BUG + id;
+
+ // allow the use to only see the operations that they can do to a
+ // bug if they have their user name and password in the preferences
+// if (BugzillaPreferencePage.getUserName() != null && !BugzillaPreferencePage.getUserName().equals("")
+// && BugzillaPreferencePage.getPassword() != null && !BugzillaPreferencePage.getPassword().equals("")) {
+ if (repository.hasCredentials()) {
+ /*
+ * The UnsupportedEncodingException exception for
+ * URLEncoder.encode() should not be thrown, since every
+ * implementation of the Java platform is required to support
+ * the standard charset "UTF-8"
+ */
+ url += POST_ARGS_LOGIN
+ + URLEncoder.encode(repository.getUserName(), BugzillaPlugin.ENCODING_UTF_8) + "&Bugzilla_password="
+ + URLEncoder.encode(repository.getPassword(), BugzillaPlugin.ENCODING_UTF_8);
+ }
+
+ URL bugUrl = new URL(url);
+ URLConnection connection = BugzillaPlugin.getDefault().getUrlConnection(bugUrl);
+ if (connection != null) {
+ InputStream input = connection.getInputStream();
+ if (input != null) {
+ in = new BufferedReader(new InputStreamReader(input));
+
+ // get the actual bug fron the server and return it
+ BugReport bug = BugParser.parseBug(in, id,
+ repository.getServerUrl().toExternalForm(),
+ BugzillaPlugin.getDefault().isServerCompatability218(),
+ repository.getUserName(),
+ repository.getPassword(),
+ connection.getContentType());
+ return bug;
+ }
+ }
+ // TODO handle the error
+ return null;
+ } catch (MalformedURLException e) {
+ throw e;
+ } catch (IOException e) {
+ throw e;
+ } catch (LoginException e) {
+ throw e;
+ } catch (Exception e) {
+ // throw an exception if there is a problem reading the bug from the
+ // server
+ // e.printStackTrace();
+ // throw new IOException(e.getMessage());
+ BugzillaPlugin.log(new Status(IStatus.ERROR, IBugzillaConstants.PLUGIN_ID, IStatus.ERROR,
+ "Problem getting report", e));
+ return null;
+ } finally {
+ try {
+ if (in != null)
+ in.close();
+ } catch (IOException e) {
+ BugzillaPlugin.log(new Status(IStatus.ERROR, IBugzillaConstants.PLUGIN_ID, IStatus.ERROR,
+ "Problem closing the stream", e));
+ }
+ }
+ }
+
+ /**
+ * Get a bug from the server. If a bug with the given id is saved offline,
+ * the offline version is returned instead.
+ *
+ * @param id -
+ * the id of the bug to get
+ * @return - a <code>BugReport</code> for the selected bug or null if it
+ * doesn't exist
+ * @throws IOException,
+ * MalformedURLException, LoginException
+ */
+ public static BugReport getCurrentBug(String serverUrl, int id) throws MalformedURLException, LoginException, IOException {
+ // Look among the offline reports for a bug with the given id.
+ OfflineReportsFile reportsFile = BugzillaPlugin.getDefault().getOfflineReports();
+ int offlineId = reportsFile.find(id);
+
+ // If an offline bug was found, return it if possible.
+ if (offlineId != -1) {
+ IBugzillaBug bug = reportsFile.elements().get(offlineId);
+ if (bug instanceof BugReport) {
+ return (BugReport) bug;
+ }
+ }
+
+ // If a suitable offline report was not found, try to get one from the
+ // server.
+ return getBug(serverUrl, id);
+ }
+
+ /**
+ * Get the list of products when creating a new bug
+ *
+ * @return The list of valid products a bug can be logged against
+ * @throws IOException
+ */
+ public static List<String> getProductList(String repositoryUrl) throws IOException, LoginException, Exception {
+ BufferedReader in = null;
+ try {
+ TaskRepository repository = MylarTaskListPlugin.getRepositoryManager().getRepository(BugzillaPlugin.REPOSITORY_KIND, repositoryUrl);
+ String urlText = "";
+ if (repository.hasCredentials()) {
+ // use the usename and password to get into bugzilla if we have it
+// if (BugzillaPreferencePage.getUserName() != null && !BugzillaPreferencePage.getUserName().equals("")
+// && BugzillaPreferencePage.getPassword() != null && !BugzillaPreferencePage.getPassword().equals("")) {
+ /*
+ * The UnsupportedEncodingException exception for
+ * URLEncoder.encode() should not be thrown, since every
+ * implementation of the Java platform is required to support
+ * the standard charset "UTF-8"
+ */
+ urlText += "?GoAheadAndLogIn=1&Bugzilla_login="
+ + URLEncoder.encode(repository.getUserName(), BugzillaPlugin.ENCODING_UTF_8) + "&Bugzilla_password="
+ + URLEncoder.encode(repository.getPassword(), BugzillaPlugin.ENCODING_UTF_8);
+ }
+
+ URL url = new URL(repository.getServerUrl().toExternalForm() + "/enter_bug.cgi" + urlText);
+
+ URLConnection cntx = BugzillaPlugin.getDefault().getUrlConnection(url);
+ if (cntx != null) {
+ InputStream input = cntx.getInputStream();
+ if (input != null) {
+
+ // create a new input stream for getting the bug
+ in = new BufferedReader(new InputStreamReader(input));
+
+ return new ProductParser(in).getProducts(repository);
+ }
+ }
+ return null;
+ } finally {
+ try {
+ if (in != null)
+ in.close();
+ } catch (IOException e) {
+ BugzillaPlugin.log(new Status(IStatus.ERROR, IBugzillaConstants.PLUGIN_ID, IStatus.ERROR,
+ "Problem closing the stream", e));
+ }
+ }
+ }
+
+ /**
+ * Get the attribute values for a new bug
+ *
+ * @param nbm
+ * A reference to a NewBugModel to store all of the data
+ * @throws Exception
+ */
+ public static void getnewBugAttributes(String serverUrl, NewBugModel nbm, boolean getProd) throws Exception {
+ BufferedReader in = null;
+ try {
+ // create a new input stream for getting the bug
+ String prodname = URLEncoder.encode(nbm.getProduct(), BugzillaPlugin.ENCODING_UTF_8);
+
+ TaskRepository repository = MylarTaskListPlugin.getRepositoryManager().getRepository(BugzillaPlugin.REPOSITORY_KIND, serverUrl);
+ String url = repository.getServerUrl().toExternalForm() + "/enter_bug.cgi";
+
+ // use the proper url if we dont know the product yet
+ if (!getProd)
+ url += "?product=" + prodname + "&";
+ else
+ url += "?";
+
+ url += POST_ARGS_LOGIN
+ + URLEncoder.encode(repository.getUserName(), BugzillaPlugin.ENCODING_UTF_8) + "&Bugzilla_password="
+ + URLEncoder.encode(repository.getPassword(), BugzillaPlugin.ENCODING_UTF_8);
+
+ URL bugUrl = new URL(url);
+ URLConnection cntx = BugzillaPlugin.getDefault().getUrlConnection(bugUrl);
+ if (cntx != null) {
+ InputStream input = cntx.getInputStream();
+ if (input != null) {
+ in = new BufferedReader(new InputStreamReader(input));
+
+ new NewBugParser(in).parseBugAttributes(nbm, getProd);
+ }
+ }
+
+ } catch (Exception e) {
+
+ if (e instanceof KeyManagementException || e instanceof NoSuchAlgorithmException
+ || e instanceof IOException) {
+ if (MessageDialog.openQuestion(null, "Bugzilla Connect Error",
+ "Unable to connect to Bugzilla server.\n"
+ + "Bug report will be created offline and saved for submission later.")) {
+ nbm.setConnected(false);
+ getProdConfigAttributes(serverUrl, nbm);
+ } else
+ throw new Exception("Bug report will not be created.");
+ } else
+ throw e;
+ } finally {
+ try {
+ if (in != null)
+ in.close();
+ } catch (IOException e) {
+ BugzillaPlugin.log(new Status(IStatus.ERROR, IBugzillaConstants.PLUGIN_ID, IStatus.ERROR,
+ "Problem closing the stream", e));
+ }
+ }
+ }
+
+ /**
+ * Get the bugzilla url that the repository is using
+ *
+ * @return A <code>String</code> containing the url of the bugzilla server
+ */
+// public static String getURL() {
+// return bugzillaUrl;
+// }
+
+ /**
+ * Method to get attributes from ProductConfiguration if unable to connect
+ * to Bugzilla server
+ *
+ * @param model -
+ * the NewBugModel to store the attributes
+ */
+ public static void getProdConfigAttributes(String serverUrl, NewBugModel model) {
+
+ HashMap<String, Attribute> attributes = new HashMap<String, Attribute>();
+
+ // ATTRIBUTE: Severity
+ Attribute a = new Attribute("Severity");
+ a.setParameterName("bug_severity");
+ // get optionValues from ProductConfiguration
+ String[] optionValues = BugzillaPlugin.getDefault().getProductConfiguration(serverUrl).getSeverities();
+ // add option values from ProductConfiguration to Attribute optionValues
+ for (int i = 0; i < optionValues.length; i++) {
+ a.addOptionValue(optionValues[i], optionValues[i]);
+ }
+ // add Attribute to model
+ attributes.put("severites", a);
+
+ // ATTRIBUTE: OS
+ a = new Attribute("OS");
+ a.setParameterName("op_sys");
+ optionValues = BugzillaPlugin.getDefault().getProductConfiguration(serverUrl).getOSs();
+ for (int i = 0; i < optionValues.length; i++) {
+ a.addOptionValue(optionValues[i], optionValues[i]);
+ }
+ attributes.put("OSs", a);
+
+ // ATTRIBUTE: Platform
+ a = new Attribute("Platform");
+ a.setParameterName("rep_platform");
+ optionValues = BugzillaPlugin.getDefault().getProductConfiguration(serverUrl).getPlatforms();
+ for (int i = 0; i < optionValues.length; i++) {
+ a.addOptionValue(optionValues[i], optionValues[i]);
+ }
+ attributes.put("platforms", a);
+
+ // ATTRIBUTE: Version
+ a = new Attribute("Version");
+ a.setParameterName("version");
+ optionValues = BugzillaPlugin.getDefault().getProductConfiguration(serverUrl).getVersions(model.getProduct());
+ for (int i = 0; i < optionValues.length; i++) {
+ a.addOptionValue(optionValues[i], optionValues[i]);
+ }
+ attributes.put("versions", a);
+
+ // ATTRIBUTE: Component
+ a = new Attribute("Component");
+ a.setParameterName("component");
+ optionValues = BugzillaPlugin.getDefault().getProductConfiguration(serverUrl).getComponents(model.getProduct());
+ for (int i = 0; i < optionValues.length; i++) {
+ a.addOptionValue(optionValues[i], optionValues[i]);
+ }
+ attributes.put("components", a);
+
+ // ATTRIBUTE: Priority
+ a = new Attribute("Priority");
+ a.setParameterName("bug_severity");
+ optionValues = BugzillaPlugin.getDefault().getProductConfiguration(serverUrl).getPriorities();
+ for (int i = 0; i < optionValues.length; i++) {
+ a.addOptionValue(optionValues[i], optionValues[i]);
+ }
+
+ // set NBM Attributes (after all Attributes have been created, and added
+ // to attributes map)
+ model.attributes = attributes;
+ }
+
+ public static String getBugUrl(String repositoryUrl, int id) {
+ TaskRepository repository = MylarTaskListPlugin.getRepositoryManager().getRepository(BugzillaPlugin.REPOSITORY_KIND, repositoryUrl);
+ String url = repository.getServerUrl().toExternalForm() + POST_ARGS_SHOW_BUG + id;
+ try {
+ if (repository.hasCredentials()) {
+ url += POST_ARGS_LOGIN
+ + URLEncoder.encode(repository.getUserName(), BugzillaPlugin.ENCODING_UTF_8) + "&Bugzilla_password="
+ + URLEncoder.encode(repository.getPassword(), BugzillaPlugin.ENCODING_UTF_8);
+ }
+ } catch (UnsupportedEncodingException e) {
+ return "";
+ }
+ return url;
+ }
+
+ public static String getBugUrlWithoutLogin(String repositoryUrl, int id) {
+ String url = repositoryUrl + POST_ARGS_SHOW_BUG + id;
+ return url;
+ }
+
+ static String queryOptionsToString(String[] array) {
+ // make a new string buffer and go through each element in the array
+ StringBuffer buffer = new StringBuffer();
+ for (int i = 0; i < array.length; i++) {
+ // append the new value to the end and add a '!' as a delimiter
+ buffer.append(array[i]);
+ buffer.append("!");
+ }
+
+ // return the buffer converted to a string
+ return buffer.toString();
+ }
+
+ public static String[] queryOptionsToArray(String values) {
+ // create a new string buffer and array list
+ StringBuffer buffer = new StringBuffer();
+ List<String> options = new ArrayList<String>();
+
+ char[] chars = values.toCharArray();
+ for (int i = 0; i < chars.length; i++) {
+ if (chars[i] == '!') {
+ options.add(buffer.toString());
+ buffer = new StringBuffer();
+ } else {
+ buffer.append(chars[i]);
+ }
+ }
+
+ // create a new string array with the same size as the array list
+ String[] array = new String[options.size()];
+
+ // put each element from the list into the array
+ for (int j = 0; j < options.size(); j++)
+ array[j] = options.get(j);
+ return array;
+ }
+
+ /**
+ * Update all of the query options for the bugzilla search page
+ *
+ * @param monitor
+ * A reference to a progress monitor
+ */
+ public static void updateQueryOptions(TaskRepository repository, IProgressMonitor monitor) throws LoginException {
+
+ String repositoryUrl = repository.getServerUrl().toExternalForm();
+ BugzillaQueryPageParser parser = new BugzillaQueryPageParser(repository, monitor);
+ if (!parser.wasSuccessful())
+ return;
+
+ // get the preferences store so that we can change the data in it
+ IPreferenceStore prefs = BugzillaPlugin.getDefault().getPreferenceStore();
+
+ prefs.setValue(IBugzillaConstants.VALUES_STATUS + PREF_DELIM_REPOSITORY + repositoryUrl, queryOptionsToString(parser.getStatusValues()));
+ monitor.worked(1);
+
+ prefs.setValue(IBugzillaConstants.VALUSE_STATUS_PRESELECTED + PREF_DELIM_REPOSITORY + repositoryUrl, queryOptionsToString(parser
+ .getPreselectedStatusValues()));
+ monitor.worked(1);
+
+ prefs.setValue(IBugzillaConstants.VALUES_RESOLUTION + PREF_DELIM_REPOSITORY + repositoryUrl, queryOptionsToString(parser.getResolutionValues()));
+ monitor.worked(1);
+
+ prefs.setValue(IBugzillaConstants.VALUES_SEVERITY + PREF_DELIM_REPOSITORY + repositoryUrl, queryOptionsToString(parser.getSeverityValues()));
+ monitor.worked(1);
+
+ prefs.setValue(IBugzillaConstants.VALUES_PRIORITY + PREF_DELIM_REPOSITORY + repositoryUrl, queryOptionsToString(parser.getPriorityValues()));
+ monitor.worked(1);
+
+ prefs.setValue(IBugzillaConstants.VALUES_HARDWARE + PREF_DELIM_REPOSITORY + repositoryUrl, queryOptionsToString(parser.getHardwareValues()));
+ monitor.worked(1);
+
+ prefs.setValue(IBugzillaConstants.VALUES_OS + PREF_DELIM_REPOSITORY + repositoryUrl, queryOptionsToString(parser.getOSValues()));
+ monitor.worked(1);
+
+ prefs.setValue(IBugzillaConstants.VALUES_PRODUCT + PREF_DELIM_REPOSITORY + repositoryUrl, queryOptionsToString(parser.getProductValues()));
+ monitor.worked(1);
+
+ prefs.setValue(IBugzillaConstants.VALUES_COMPONENT + PREF_DELIM_REPOSITORY + repositoryUrl, queryOptionsToString(parser.getComponentValues()));
+ monitor.worked(1);
+
+ prefs.setValue(IBugzillaConstants.VALUES_VERSION + PREF_DELIM_REPOSITORY + repositoryUrl, queryOptionsToString(parser.getVersionValues()));
+ monitor.worked(1);
+
+ prefs.setValue(IBugzillaConstants.VALUES_TARGET + PREF_DELIM_REPOSITORY + repositoryUrl, queryOptionsToString(parser.getTargetValues()));
+ monitor.worked(1);
+ }
+}
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/IBugzillaConstants.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/IBugzillaConstants.java
index af4db68ff..3bc39d723 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/IBugzillaConstants.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/IBugzillaConstants.java
@@ -11,16 +11,9 @@
package org.eclipse.mylar.bugzilla.core;
/**
- * @author kvesik
- *
- * Created on Mar 26, 2003
- */
-
-/**
- * Interface for holding Bugzilla constants.
+ * @author Mik Kersten (hardening of prototype
*/
-public interface IBugzillaConstants
-{
+public interface IBugzillaConstants {
// The bugzilla plugin id
static final String PLUGIN_ID = "org.eclipse.mylar.bugzilla";
@@ -50,8 +43,9 @@ public interface IBugzillaConstants
static final int ERROR_CODE = 1;
// Bugzilla Preferences keys
- static final String BUGZILLA_SERVER = "BUGZILLA_SERVER";
- static final String MOST_RECENT_QUERY = "MOST_RECENT_QUERY";
+// static final String BUGZILLA_SERVER = "BUGZILLA_SERVER";
+// static final String BUGZILLA_SERVER = "BUGZILLA_SERVER";
+ static final String MOST_RECENT_QUERY = "org.eclipse.mylar.bugzilla.query.last";
static final String SERVER_VERSION = "org.eclipse.mylar.bugzilla.server.version";
static final String SERVER_220 = "2.20";
@@ -62,24 +56,24 @@ public interface IBugzillaConstants
// static final String IS_218 = "BUGZILLA_IS_218";
// static final String IS_220 = "BUGZILLA_IS_220";
- static final String REFRESH_QUERY = "REFRESH_QUERY";
- static final String MAX_RESULTS = "MAX_BUGZILLA_RESULTS";
+ static final String REFRESH_QUERY = "org.eclipse.mylar.bugzilla.query.refresh";
+ static final String MAX_RESULTS = "org.eclipse.mylar.bugzilla.search.results.max";
// names for the resources used to hold the different attributes of a bug
- static final String STATUS_VALUES = "STATUS_VALUES";
- static final String PRESELECTED_STATUS_VALUES = "PRESELECTED_STATUS_VALUES";
- static final String RESOLUTION_VALUES = "RESOLUTION_VALUES";
- static final String SEVERITY_VALUES = "SEVERITY_VALUES";
- static final String PRIORITY_VALUES = "PRIORITY_VALUES";
- static final String HARDWARE_VALUES = "HARDWARE_VALUES";
- static final String OS_VALUES = "OS_VALUES";
- static final String PRODUCT_VALUES = "PRODUCT_VALUES";
- static final String COMPONENT_VALUES = "COMPONENT_VALUES";
- static final String VERSION_VALUES = "VERSION_VALUES";
- static final String TARGET_VALUES = "TARGET_VALUES";
+ static final String VALUES_STATUS = "org.eclipse.mylar.bugzilla.values.status";
+ static final String VALUSE_STATUS_PRESELECTED = "org.eclipse.mylar.bugzilla.values.status.preselected";
+ static final String VALUES_RESOLUTION = "org.eclipse.mylar.bugzilla.values.resolution";
+ static final String VALUES_SEVERITY = "org.eclipse.mylar.bugzilla.values.severity";
+ static final String VALUES_PRIORITY = "org.eclipse.mylar.bugzilla.values.priority";
+ static final String VALUES_HARDWARE = "org.eclipse.mylar.bugzilla.values.hardware";
+ static final String VALUES_OS = "org.eclipse.mylar.bugzilla.values.os";
+ static final String VALUES_PRODUCT = "org.eclipse.mylar.bugzilla.values.product";
+ static final String VALUES_COMPONENT = "org.eclipse.mylar.bugzilla.values.component";
+ static final String VALUES_VERSION = "org.eclipse.mylar.bugzilla.values.version";
+ static final String VALUES_TARGET = "org.eclipse.mylar.bugzilla.values.target";
// Default values for keys
- static final String DEFAULT_BUGZILLA_SERVER = "https://bugs.eclipse.org/bugs";
+ static final String ECLIPSE_BUGZILLA_URL = "https://bugs.eclipse.org/bugs";
static final String[] DEFAULT_STATUS_VALUES = {"Unconfirmed", "New", "Assigned", "Reopened", "Resolved", "Verified", "Closed"};
static final String[] DEFAULT_PRESELECTED_STATUS_VALUES = {"New", "Assigned", "Reopened"};
@@ -90,14 +84,8 @@ public interface IBugzillaConstants
static final String[] DEFAULT_OS_VALUES = {"All", "AIX Motif", "Windows 95", "Windows 98", "Windows CE", "Windows ME", "Windows 2000",
"Windows NT", "Windows XP", "Windows All", "MacOS X", "Linux", "Linux-GTK", "Linux-Motif", "HP-UX", "Neutrino",
"QNX-Photon", "Solaris", "Unix All", "other"};
- static final String[] DEFAULT_PRODUCT_VALUES = {"AJDT", "AspectJ", "CDT", "EMF", "Equinox", "GEF", "JDT", "PDE", "Platform", "Stellation", "XSD"};
- static final String[] DEFAULT_COMPONENT_VALUES = {"Access Control", "Ant", "Commandline", "Compare", "Compiler", "Core", "Cpp-Extensions", "Debug",
- "Doc", "Docs", "draw2d", "Dynamic Plugins", "Fine-Grained", "GEF", "Generic-Extensions", "Help", "IDE", "Launcher", "LPEX", "Plugins",
- "Releng", "Repository", "Script Tests", "Scripting", "Search", "Server", "SWT", "Text", "UI", "Unit Tests", "Update", "VCM",
- "WebDAV", "Windows Support"};
- static final String[] DEFAULT_VERSION_VALUES = {"0.5", "1.0", "2.0", "2.0.1", "2.0.2", "2.1", "2.2", "unspecified"};
- static final String[] DEFAULT_TARGET_VALUES = {"2.0 M1", "Alpha1", "Alpha2", "Alpha3", "Alpha4", "1.0", "1.0 - 20020308", "1.0 - Release",
- "2.0 M2", "2.0 - 20020308", "2.0 M3", "2.0 - 20020408", "2.0 M4", "2.0 - 20020508", "2.0 M5", "2.0 - Release", "2.0 M6",
- "2.0 F1", "2.0 F2", "2.0 F3", "2.0 F4", "2.0.1", "2.0.2",
- "2.1", "2.1 M1", "2.1 M2", "2.1 M3", "2.1 M4", "2.1 M5", "2.1 RC1", "2.1 RC2", "2.1 RC3", "2.2", "Future"};
+ static final String[] DEFAULT_PRODUCT_VALUES = { };
+ static final String[] DEFAULT_COMPONENT_VALUES = { };
+ static final String[] DEFAULT_VERSION_VALUES = { };
+ static final String[] DEFAULT_TARGET_VALUES = { };
}
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/internal/BugParser.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/internal/BugParser.java
index d605e7e51..9b5cdac1d 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/internal/BugParser.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/internal/BugParser.java
@@ -32,7 +32,6 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.mylar.bugzilla.core.Attribute;
import org.eclipse.mylar.bugzilla.core.BugReport;
import org.eclipse.mylar.bugzilla.core.BugzillaPlugin;
-import org.eclipse.mylar.bugzilla.core.BugzillaRepository;
import org.eclipse.mylar.bugzilla.core.Comment;
import org.eclipse.mylar.bugzilla.core.IBugzillaConstants;
import org.eclipse.mylar.bugzilla.core.Operation;
@@ -85,7 +84,7 @@ public class BugParser {
* @throws IOException
*/
private static void parseAttributeValue(BugReport bug, String attributeName, HtmlStreamTokenizer tokenizer,
- String userName, String password) throws IOException, ParseException {
+ String serverUrl, String userName, String password) throws IOException, ParseException {
Token token = tokenizer.nextToken();
if (token.getType() == Token.TAG) {
@@ -110,7 +109,7 @@ public class BugParser {
String parameterName = tag.getAttribute("name");
parseSelect(bug, attributeName, parameterName, tokenizer);
} else if (tag.getTagType() == HtmlTag.Type.INPUT && !tag.isEndTag()) {
- parseInput(bug, attributeName, tag, userName, password);
+ parseInput(bug, attributeName, tag, serverUrl, userName, password);
} else if (!tag.isEndTag() || attributeName.equalsIgnoreCase("resolution")) {
if (tag.isEndTag() && attributeName.equalsIgnoreCase("resolution")) {
Attribute a = new Attribute(attributeName);
@@ -274,7 +273,7 @@ public class BugParser {
* The INPUT tag
* @throws IOException
*/
- private static void parseInput(BugReport bug, String attributeName, HtmlTag tag, String userName, String password)
+ private static void parseInput(BugReport bug, String attributeName, HtmlTag tag, String serverUrl, String userName, String password)
throws IOException {
Attribute a = new Attribute(attributeName);
@@ -298,7 +297,7 @@ public class BugParser {
a.setValue(value);
bug.addAttribute(a);
- if (attributeName.equalsIgnoreCase("keywords") && BugzillaRepository.getURL() != null) {
+ if (attributeName.equalsIgnoreCase("keywords") && serverUrl != null) {
BufferedReader input = null;
try {
@@ -319,7 +318,7 @@ public class BugParser {
}
// connect to the bugzilla server to get the keyword list
- URL url = new URL(BugzillaRepository.getURL() + "/" + keywordsUrl + urlText);
+ URL url = new URL(serverUrl + "/" + keywordsUrl + urlText);
URLConnection urlConnection = BugzillaPlugin.getDefault().getUrlConnection(url);
input = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
@@ -515,10 +514,10 @@ public class BugParser {
* @throws IOException
* @throws ParseException
*/
- public static BugReport parseBug(Reader in, int id, String serverName, boolean is218, String userName,
+ public static BugReport parseBug(Reader in, int id, String serverUrl, boolean is218, String userName,
String password, String contentType) throws IOException, ParseException, LoginException {
// create a new bug report and set the parser state to the start state
- BugReport bug = new BugReport(id, serverName);
+ BugReport bug = new BugReport(id, serverUrl);
boolean contentTypeResolved = false;
if (contentType != null) {
String charsetFromContentType = getCharsetFromString(contentType);
@@ -651,7 +650,7 @@ public class BugParser {
HtmlTag tag = (HtmlTag) token.getValue();
if (tag.getTagType() == HtmlTag.Type.TD) {
// parse the attribute values
- parseAttributeValue(bug, attribute, tokenizer, userName, password);
+ parseAttributeValue(bug, attribute, tokenizer, serverUrl, userName, password);
state = ParserState.ATT_NAME;
attribute = null;
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/favorites/Favorite.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/internal/Favorite.java
index b786f8dae..cb5acbf41 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/favorites/Favorite.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/internal/Favorite.java
@@ -8,7 +8,7 @@
* Contributors:
* University Of British Columbia - initial API and implementation
*******************************************************************************/
-package org.eclipse.mylar.bugzilla.core.favorites;
+package org.eclipse.mylar.bugzilla.core.internal;
import java.io.Serializable;
import java.util.Date;
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/favorites/FavoritesFile.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/internal/FavoritesFile.java
index 869d43a8c..bc14139b5 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/favorites/FavoritesFile.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/internal/FavoritesFile.java
@@ -8,7 +8,7 @@
* Contributors:
* University Of British Columbia - initial API and implementation
*******************************************************************************/
-package org.eclipse.mylar.bugzilla.core.favorites;
+package org.eclipse.mylar.bugzilla.core.internal;
import java.io.File;
import java.io.FileInputStream;
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/offline/OfflineReportsFile.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/internal/OfflineReportsFile.java
index 40ed4959b..14dcf8926 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/offline/OfflineReportsFile.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/internal/OfflineReportsFile.java
@@ -8,7 +8,7 @@
* Contributors:
* University Of British Columbia - initial API and implementation
*******************************************************************************/
-package org.eclipse.mylar.bugzilla.core.offline;
+package org.eclipse.mylar.bugzilla.core.internal;
import java.io.File;
import java.io.FileInputStream;
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/internal/ProductParser.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/internal/ProductParser.java
index fb8c5aae4..9dac65e12 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/internal/ProductParser.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/internal/ProductParser.java
@@ -21,6 +21,7 @@ import javax.security.auth.login.LoginException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.mylar.bugzilla.core.internal.HtmlStreamTokenizer.Token;
import org.eclipse.mylar.bugzilla.core.search.BugzillaQueryPageParser;
+import org.eclipse.mylar.tasklist.repositories.TaskRepository;
/**
* This class is used to parse the available products to log a bug for
@@ -39,14 +40,15 @@ public class ProductParser
/**
* Parse the product page for the valid products that a bug can be logged for
+ * @param repository
* @param in The input stream for the products page
* @return A list of the products that we can enter bugs for
* @throws IOException
* @throws ParseException
*/
- public List<String> getProducts() throws IOException, ParseException, LoginException
+ public List<String> getProducts(TaskRepository repository) throws IOException, ParseException, LoginException
{
- BugzillaQueryPageParser parser = new BugzillaQueryPageParser(new NullProgressMonitor());
+ BugzillaQueryPageParser parser = new BugzillaQueryPageParser(repository, new NullProgressMonitor());
if (!parser.wasSuccessful()) {
throw new RuntimeException("Couldn't get products");
} else {
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/search/BugzillaQueryPageParser.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/search/BugzillaQueryPageParser.java
index f3e1a8c15..264487786 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/search/BugzillaQueryPageParser.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/search/BugzillaQueryPageParser.java
@@ -31,12 +31,11 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.mylar.bugzilla.core.BugzillaPlugin;
-import org.eclipse.mylar.bugzilla.core.BugzillaPreferencePage;
import org.eclipse.mylar.bugzilla.core.IBugzillaConstants;
import org.eclipse.mylar.bugzilla.core.internal.HtmlStreamTokenizer;
import org.eclipse.mylar.bugzilla.core.internal.HtmlTag;
import org.eclipse.mylar.bugzilla.core.internal.HtmlStreamTokenizer.Token;
-
+import org.eclipse.mylar.tasklist.repositories.TaskRepository;
/**
* Class to parse the update data from the server
@@ -44,108 +43,111 @@ import org.eclipse.mylar.bugzilla.core.internal.HtmlStreamTokenizer.Token;
* author: kvesik
*
* created on: Feb 25, 2003
- *
+ *
*/
-public class BugzillaQueryPageParser
-{
+public class BugzillaQueryPageParser {
/** The name of the bugzilla server */
private String urlString;
-
+
/** The input stream */
private BufferedReader in = null;
-
+
/** True if the operation was successful */
private boolean successful;
-
- /** Exception to be displayed if there was an error*/
+
+ /** Exception to be displayed if there was an error */
private Exception exception;
-
+
/** The progress monitor for the update */
private IProgressMonitor monitor;
-
+
/** Selection lists as ArrayLists */
private ArrayList<String> statusValues = new ArrayList<String>();
+
private ArrayList<String> preselectedStatusValues = new ArrayList<String>();
+
private ArrayList<String> resolutionValues = new ArrayList<String>();
+
private ArrayList<String> severityValues = new ArrayList<String>();
+
private ArrayList<String> priorityValues = new ArrayList<String>();
+
private ArrayList<String> hardwareValues = new ArrayList<String>();
+
private ArrayList<String> osValues = new ArrayList<String>();
+
private ArrayList<String> productValues = new ArrayList<String>();
+
private ArrayList<String> componentValues = new ArrayList<String>();
+
private ArrayList<String> versionValues = new ArrayList<String>();
+
private ArrayList<String> targetValues = new ArrayList<String>();
-
- /**
- * Constructor
- * @param monitor The progress monitor for the update
- */
- public BugzillaQueryPageParser(IProgressMonitor monitor) throws LoginException
- {
+
+ public BugzillaQueryPageParser(TaskRepository repository, IProgressMonitor monitor) throws LoginException {
this.monitor = monitor;
-
// get the servers url
- urlString = BugzillaPlugin.getDefault().getServerName() + "/query.cgi";
+ urlString = repository.getServerUrl().toExternalForm() + "/query.cgi";
- // if we are dealing with 2.18 we need to use the folowing in the
+ // if we are dealing with 2.18 we need to use the folowing in the
// query string to get the right search page
- if(BugzillaPlugin.getDefault().isServerCompatability218()){
- urlString += "?format=advanced";
- }
-
+ if (BugzillaPlugin.getDefault().isServerCompatability218()) {
+ urlString += "?format=advanced";
+ }
+
// use the user name and password if we have it
- if(BugzillaPreferencePage.getUserName() != null && !BugzillaPreferencePage.getUserName().equals("") && BugzillaPreferencePage.getPassword() != null && !BugzillaPreferencePage.getPassword().equals(""))
- {
+ if (repository.hasCredentials()) {
try {
- // if we are dealing with 2.18 we already have the ? from before so we need
- // an & instead. If other version, still add ?
- if(BugzillaPlugin.getDefault().isServerCompatability218())
- urlString+="&";
- else
- urlString+="?";
-
- urlString += "GoAheadAndLogIn=1&Bugzilla_login=" + URLEncoder.encode(BugzillaPreferencePage.getUserName(), "UTF-8") + "&Bugzilla_password=" + URLEncoder.encode(BugzillaPreferencePage.getPassword(), "UTF-8");
- }
- catch (UnsupportedEncodingException e) {
+ // if we are dealing with 2.18 we already have the ? from before
+ // so we need
+ // an & instead. If other version, still add ?
+ if (BugzillaPlugin.getDefault().isServerCompatability218())
+ urlString += "&";
+ else
+ urlString += "?";
+
+ urlString += "GoAheadAndLogIn=1&Bugzilla_login="
+ + URLEncoder.encode(repository.getUserName(), BugzillaPlugin.ENCODING_UTF_8) + "&Bugzilla_password="
+ + URLEncoder.encode(repository.getPassword(), BugzillaPlugin.ENCODING_UTF_8);
+ } catch (UnsupportedEncodingException e) {
/*
- * Do nothing. Every implementation of the Java platform is required
- * to support the standard charset "UTF-8"
+ * Do nothing. Every implementation of the Java platform is
+ * required to support the standard charset BugzillaPlugin.ENCODING_UTF_8
*/
}
- }
-
+ }
+
successful = false;
-
+
// try to get the new options from the page
parseDocument();
if (!successful) {
if (exception instanceof MalformedURLException) {
- MessageDialog.openError(null, "Unsupported Protocol", "The server that was specified for Bugzilla is not supported by your JVM.\nPlease make sure that you are using a JDK that supports SSL.");
- }
- else {
- // if there was a problem with the operation, display an error message
- ErrorDialog.openError( null,
- "Incomplete operation",
- "Bugzilla could not complete the the update.",
- new Status( IStatus.ERROR,
- IBugzillaConstants.PLUGIN_ID,
- IStatus.OK,
- exception.getMessage(),
- exception));
+ MessageDialog
+ .openError(
+ null,
+ "Unsupported Protocol",
+ "The server that was specified for Bugzilla is not supported by your JVM.\nPlease make sure that you are using a JDK that supports SSL.");
+ } else {
+ // if there was a problem with the operation, display an error
+ // message
+ ErrorDialog.openError(null, "Incomplete operation", "Bugzilla could not complete the the update.",
+ new Status(IStatus.ERROR, IBugzillaConstants.PLUGIN_ID, IStatus.OK, exception.getMessage(),
+ exception));
}
}
}
-
+
/**
* Get whether the update was successful
+ *
* @return <code>true</code> if the update was successful
*/
- public boolean wasSuccessful()
- {
+ public boolean wasSuccessful() {
return successful;
}
-
+
/**
* Parse the data from the server for the query options
*/
@@ -156,55 +158,51 @@ public class BugzillaQueryPageParser
monitor.done();
return;
}
-
+
// try to connect to the server
monitor.subTask("Connecting to server");
-
- URL url = new URL(this.urlString);
+
+ URL url = new URL(this.urlString);
URLConnection cntx = BugzillaPlugin.getDefault().getUrlConnection(url);
-
- if(cntx != null){
+
+ if (cntx != null) {
InputStream input = cntx.getInputStream();
- if(input != null) {
-
+ if (input != null) {
+
monitor.worked(1);
-
+
// initialize the input stream
in = new BufferedReader(new InputStreamReader(input));
-
+
// increment the position of the status monitor
monitor.worked(2);
-
- // check if the operation has been cancelled so we can end if it has been
+
+ // check if the operation has been cancelled so we can end
+ // if it has been
if (monitor.isCanceled())
monitor.done();
else
monitor.subTask("Reading values from server");
-
+
// parse the data from the server
parseQueryPage(in);
-
+
// set the operation to being successful
successful = true;
}
}
-
- }
- catch (LoginException e) {
+
+ } catch (LoginException e) {
throw e;
- }
- catch (Exception e) {
- // if we can't connect, log the problem and save the exception to handle later
+ } catch (Exception e) {
+ // if we can't connect, log the problem and save the exception to
+ // handle later
monitor.done();
exception = e;
- BugzillaPlugin.log(new Status( IStatus.ERROR,
- IBugzillaConstants.PLUGIN_ID,
- IStatus.OK,
- "Failed to create URL and open input stream: " + urlString,
- e));
+ BugzillaPlugin.log(new Status(IStatus.ERROR, IBugzillaConstants.PLUGIN_ID, IStatus.OK,
+ "Failed to create URL and open input stream: " + urlString, e));
return;
- }
- finally {
+ } finally {
try {
if (in != null)
in.close();
@@ -213,195 +211,212 @@ public class BugzillaQueryPageParser
}
}
}
-
+
/**
* Check if all of the lists of options are empty
+ *
* @return true if all of the options lists are empty
*/
private boolean allListsEmpty() {
- return statusValues.isEmpty() && preselectedStatusValues.isEmpty()
- && resolutionValues.isEmpty() && severityValues.isEmpty()
- && priorityValues.isEmpty() && hardwareValues.isEmpty()
- && osValues.isEmpty() && productValues.isEmpty()
- && componentValues.isEmpty() && versionValues.isEmpty()
- && targetValues.isEmpty();
+ return statusValues.isEmpty() && preselectedStatusValues.isEmpty() && resolutionValues.isEmpty()
+ && severityValues.isEmpty() && priorityValues.isEmpty() && hardwareValues.isEmpty()
+ && osValues.isEmpty() && productValues.isEmpty() && componentValues.isEmpty()
+ && versionValues.isEmpty() && targetValues.isEmpty();
}
-
+
/**
* Get the new status values
+ *
* @return An array of the new status values
*/
public String[] getStatusValues() {
String[] array = new String[statusValues.size()];
-
+
// create the array and return it
for (int i = 0; i < statusValues.size(); i++)
array[i] = statusValues.get(i);
return array;
}
-
+
/**
* Get the new preselected status values
+ *
* @return An array of the new preselected status values
*/
public String[] getPreselectedStatusValues() {
String[] array = new String[preselectedStatusValues.size()];
-
+
// create the array and return it
for (int i = 0; i < preselectedStatusValues.size(); i++)
array[i] = preselectedStatusValues.get(i);
return array;
}
-
+
/**
* Get the new resolution values
+ *
* @return An array of the new resolution values
*/
public String[] getResolutionValues() {
String[] array = new String[resolutionValues.size()];
-
+
// create the array and return it
for (int i = 0; i < resolutionValues.size(); i++)
array[i] = resolutionValues.get(i);
return array;
}
-
+
/**
* Get the new severity values
+ *
* @return An array of the new severity values
*/
public String[] getSeverityValues() {
String[] array = new String[severityValues.size()];
-
+
// create the array and return it
for (int i = 0; i < severityValues.size(); i++)
array[i] = severityValues.get(i);
return array;
}
-
+
/**
* Get the new priority values
+ *
* @return An array of the new priority values
*/
public String[] getPriorityValues() {
String[] array = new String[priorityValues.size()];
-
+
// create the array and return it
for (int i = 0; i < priorityValues.size(); i++)
array[i] = priorityValues.get(i);
return array;
}
-
+
/**
* Get the new hardware values
+ *
* @return An array of the new hardware values
*/
public String[] getHardwareValues() {
String[] array = new String[hardwareValues.size()];
-
+
// create the array and return it
for (int i = 0; i < hardwareValues.size(); i++)
array[i] = hardwareValues.get(i);
return array;
}
-
+
/**
* Get the new OS values
+ *
* @return An array of the new OS values
*/
public String[] getOSValues() {
String[] array = new String[osValues.size()];
-
+
// create the array and return it
for (int i = 0; i < osValues.size(); i++)
array[i] = osValues.get(i);
return array;
}
-
+
/**
* Get the new product values
+ *
* @return An array of the new product values
*/
public String[] getProductValues() {
String[] array = new String[productValues.size()];
-
+
// create the array and return it
for (int i = 0; i < productValues.size(); i++)
array[i] = productValues.get(i);
return array;
}
-
+
/**
* Get the new component values
+ *
* @return An array of the new component values
*/
public String[] getComponentValues() {
String[] array = new String[componentValues.size()];
-
+
// create the array and return it
for (int i = 0; i < componentValues.size(); i++)
array[i] = componentValues.get(i);
return array;
}
-
+
/**
* Get the new version values
+ *
* @return An array of the new version values
*/
public String[] getVersionValues() {
String[] array = new String[versionValues.size()];
-
+
// create the array and return it
for (int i = 0; i < versionValues.size(); i++)
array[i] = versionValues.get(i);
return array;
}
-
+
/**
* Get the new milestone values
+ *
* @return An array of the new milestone values
*/
public String[] getTargetValues() {
String[] array = new String[targetValues.size()];
-
+
// create the array and return it
for (int i = 0; i < targetValues.size(); i++)
array[i] = targetValues.get(i);
return array;
}
-
+
/**
- * Parse the bugzilla query.cgi page for some seach options
- * @param inputReader The input stream for the page
+ * Parse the bugzilla query.cgi page for some seach options
+ *
+ * @param inputReader
+ * The input stream for the page
* @throws LoginException
* @throws ParseException
* @throws IOException
*/
- private void parseQueryPage(Reader inputReader) throws LoginException, ParseException, IOException
- {
+ private void parseQueryPage(Reader inputReader) throws LoginException, ParseException, IOException {
HtmlStreamTokenizer tokenizer = new HtmlStreamTokenizer(inputReader, null);
boolean isTitle = false;
boolean possibleBadLogin = false;
String title = "";
- for (HtmlStreamTokenizer.Token token = tokenizer.nextToken(); token.getType() != Token.EOF; token = tokenizer.nextToken()) {
-
- // make sure that bugzilla doesn't want us to login
- if(token.getType() == Token.TAG && ((HtmlTag)(token.getValue())).getTagType() == HtmlTag.Type.TITLE && !((HtmlTag)(token.getValue())).isEndTag()) {
- isTitle = true;
- continue;
+ for (HtmlStreamTokenizer.Token token = tokenizer.nextToken(); token.getType() != Token.EOF; token = tokenizer
+ .nextToken()) {
+
+ // make sure that bugzilla doesn't want us to login
+ if (token.getType() == Token.TAG && ((HtmlTag) (token.getValue())).getTagType() == HtmlTag.Type.TITLE
+ && !((HtmlTag) (token.getValue())).isEndTag()) {
+ isTitle = true;
+ continue;
}
-
+
if (isTitle) {
// get all of the data in the title tag to compare with
if (token.getType() != Token.TAG) {
- title += ((StringBuffer)token.getValue()).toString().toLowerCase() + " ";
+ title += ((StringBuffer) token.getValue()).toString().toLowerCase() + " ";
continue;
- }
- else if (token.getType() == Token.TAG && ((HtmlTag)token.getValue()).getTagType() == HtmlTag.Type.TITLE && ((HtmlTag)token.getValue()).isEndTag()) {
- // check if the title looks like we may have a problem with login
- if ((title.indexOf("login") != -1 || (title.indexOf("invalid") != -1 && title.indexOf("password") != -1) || title.indexOf("check e-mail") != -1 || title.indexOf("error") != -1))
+ } else if (token.getType() == Token.TAG
+ && ((HtmlTag) token.getValue()).getTagType() == HtmlTag.Type.TITLE
+ && ((HtmlTag) token.getValue()).isEndTag()) {
+ // check if the title looks like we may have a problem with
+ // login
+ if ((title.indexOf("login") != -1
+ || (title.indexOf("invalid") != -1 && title.indexOf("password") != -1)
+ || title.indexOf("check e-mail") != -1 || title.indexOf("error") != -1))
possibleBadLogin = true;
isTitle = false;
title = "";
@@ -419,29 +434,31 @@ public class BugzillaQueryPageParser
}
}
}
-
- // if all of the lists are empty and we suspect bad login info, assume that it was a bad login
+
+ // if all of the lists are empty and we suspect bad login info, assume
+ // that it was a bad login
if (possibleBadLogin && allListsEmpty())
throw new LoginException("Bugzilla login information incorrect");
}
-
+
/**
* Parse the case where the attribute value is an option
- * @param parameterName The name of the attribute value
- * @param tokenizer The tokenizer to get data from the stream
+ *
+ * @param parameterName
+ * The name of the attribute value
+ * @param tokenizer
+ * The tokenizer to get data from the stream
* @throws IOException
* @throws ParseException
*/
- private void parseSelect(
- String parameterName,
- HtmlStreamTokenizer tokenizer)
- throws IOException, ParseException {
-
+ private void parseSelect(String parameterName, HtmlStreamTokenizer tokenizer) throws IOException, ParseException {
+
HtmlStreamTokenizer.Token token = tokenizer.nextToken();
while (token.getType() != Token.EOF) {
if (token.getType() == Token.TAG) {
HtmlTag tag = (HtmlTag) token.getValue();
- if (tag.getTagType() == HtmlTag.Type.SELECT && tag.isEndTag()) break;
+ if (tag.getTagType() == HtmlTag.Type.SELECT && tag.isEndTag())
+ break;
if (tag.getTagType() == HtmlTag.Type.OPTION && !tag.isEndTag()) {
String optionName = tag.getAttribute("value");
boolean selected = tag.hasAttribute("selected");
@@ -455,12 +472,11 @@ public class BugzillaQueryPageParser
// add the value to the appropriate list of attributes
if (parameterName.equals("bug_status")) {
statusValues.add(optionName);
-
+
// check if the status is to be preselected or not
if (selected)
preselectedStatusValues.add(optionName);
- }
- else if (parameterName.equals("resolution"))
+ } else if (parameterName.equals("resolution"))
resolutionValues.add(optionName);
else if (parameterName.equals("bug_severity"))
severityValues.add(optionName);
@@ -478,26 +494,24 @@ public class BugzillaQueryPageParser
versionValues.add(optionName);
else if (parameterName.equals("target_milestone"))
targetValues.add(optionName);
- }
- else {
+ } else {
token = tokenizer.nextToken();
}
- }
- else {
+ } else {
token = tokenizer.nextToken();
}
}
}
-
+
/**
* Parse the case where we think we found an attribute value
- * @param tokenizer The tokenizer to get the data from the stream
+ *
+ * @param tokenizer
+ * The tokenizer to get the data from the stream
* @throws IOException
* @throws ParseException
*/
- private void parseAttributeValue(
- HtmlStreamTokenizer tokenizer)
- throws IOException, ParseException {
+ private void parseAttributeValue(HtmlStreamTokenizer tokenizer) throws IOException, ParseException {
HtmlStreamTokenizer.Token token = tokenizer.nextToken();
if (token.getType() == Token.TAG) {
@@ -505,8 +519,7 @@ public class BugzillaQueryPageParser
if (tag.getTagType() == HtmlTag.Type.SELECT && !tag.isEndTag()) {
String parameterName = tag.getAttribute("name");
parseSelect(parameterName, tokenizer);
- }
- else if (tag.getTagType() == HtmlTag.Type.LABEL && !tag.isEndTag()) {
+ } else if (tag.getTagType() == HtmlTag.Type.LABEL && !tag.isEndTag()) {
parseAttributeValue(tokenizer);
}
}
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/search/BugzillaSearchEngine.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/search/BugzillaSearchEngine.java
index 542b4467b..fa4a920fd 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/search/BugzillaSearchEngine.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/search/BugzillaSearchEngine.java
@@ -29,8 +29,8 @@ import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Status;
import org.eclipse.mylar.bugzilla.core.BugzillaException;
import org.eclipse.mylar.bugzilla.core.BugzillaPlugin;
-import org.eclipse.mylar.bugzilla.core.BugzillaPreferencePage;
import org.eclipse.mylar.bugzilla.core.IBugzillaConstants;
+import org.eclipse.mylar.tasklist.repositories.TaskRepository;
import org.eclipse.search.ui.NewSearchUI;
import com.sun.org.apache.xerces.internal.impl.xpath.regex.Match;
@@ -57,17 +57,21 @@ public class BugzillaSearchEngine {
protected static final RegularExpression reOld = new RegularExpression("<a href=\"show_bug.cgi\\?id=(\\d+)\">\\d+</a>\\s*<td class=severity><nobr>([^>]+)</nobr><td class=priority><nobr>([^>]+)</nobr><td class=platform><nobr>([^>]*)</nobr><td class=owner><nobr>([^>]*)</nobr><td class=status><nobr>([^>]*)</nobr><td class=resolution><nobr>([^>]*)</nobr><td class=summary>(.*)$", "i");
private String urlString;
+
+ private TaskRepository repository;
private boolean maxReached = false;
- public BugzillaSearchEngine(String url) {
- this.urlString = url;
+ public BugzillaSearchEngine(TaskRepository repository, String queryUrl) {
+ urlString = queryUrl;
+ this.repository = repository;
- // use the username and password if we have it to log into bugzilla
- if(BugzillaPreferencePage.getUserName() != null && !BugzillaPreferencePage.getUserName().equals("") && BugzillaPreferencePage.getPassword() != null && !BugzillaPreferencePage.getPassword().equals(""))
- {
+ if (repository.hasCredentials()) {
try {
- url += "&GoAheadAndLogIn=1&Bugzilla_login=" + URLEncoder.encode(BugzillaPreferencePage.getUserName(), "UTF-8") + "&Bugzilla_password=" + URLEncoder.encode(BugzillaPreferencePage.getPassword(), "UTF-8");
+ urlString += "&GoAheadAndLogIn=1&Bugzilla_login="
+ + URLEncoder.encode(repository.getUserName(), BugzillaPlugin.ENCODING_UTF_8)
+ + "&Bugzilla_password="
+ + URLEncoder.encode(repository.getPassword(), BugzillaPlugin.ENCODING_UTF_8);
} catch (UnsupportedEncodingException e) {
/*
* Do nothing. Every implementation of the Java platform is required
@@ -75,6 +79,18 @@ public class BugzillaSearchEngine {
*/
}
}
+ // use the username and password if we have it to log into bugzilla
+// if(BugzillaPreferencePage.getUserName() != null && !BugzillaPreferencePage.getUserName().equals("") && BugzillaPreferencePage.getPassword() != null && !BugzillaPreferencePage.getPassword().equals(""))
+// {
+// try {
+// url += "&GoAheadAndLogIn=1&Bugzilla_login=" + URLEncoder.encode(BugzillaPreferencePage.getUserName(), "UTF-8") + "&Bugzilla_password=" + URLEncoder.encode(BugzillaPreferencePage.getPassword(), "UTF-8");
+// } catch (UnsupportedEncodingException e) {
+// /*
+// * Do nothing. Every implementation of the Java platform is required
+// * to support the standard charset "UTF-8"
+// */
+// }
+// }
}
/**
@@ -156,7 +172,7 @@ public class BugzillaSearchEngine {
if(responseCode != HttpURLConnection.HTTP_OK) {
String msg;
if(responseCode == -1 || responseCode == HttpURLConnection.HTTP_FORBIDDEN)
- msg = BugzillaPlugin.getDefault().getServerName() + " does not seem to be a valid Bugzilla server. Check Bugzilla preferences.";
+ msg = repository.getServerUrl().toExternalForm() + " does not seem to be a valid Bugzilla server. Check Bugzilla preferences.";
else
msg = "HTTP Error " + responseCode + " (" + connect.getResponseMessage() + ") while querying Bugzilla Server. Check Bugzilla preferences.";
@@ -211,9 +227,10 @@ public class BugzillaSearchEngine {
if (query == null)
query = "";
- String server = BugzillaPlugin.getDefault().getServerName();
+// String server = BugzillaPlugin.getDefault().getServerName();
+ String server = repository.getServerUrl().toExternalForm();
- BugzillaSearchHit hit = new BugzillaSearchHit(id, description, severity, priority, platform, state, result, owner, query, server);
+ BugzillaSearchHit hit = new BugzillaSearchHit(server, id, description, severity, priority, platform, state, result, owner, query);
collector.accept(hit);
numCollected++;
@@ -226,7 +243,7 @@ public class BugzillaSearchEngine {
}
int id = Integer.parseInt(match.getCapturedText(1));
- BugzillaSearchHit hit = createHit(regularExpression, monitor, in, match, id);
+ BugzillaSearchHit hit = createHit(regularExpression, monitor, in, match, repository.getServerUrl().toExternalForm(), id);
collector.accept(hit);
numCollected++;
}
@@ -235,7 +252,8 @@ public class BugzillaSearchEngine {
}
}
}catch (CoreException e) {
- status = new MultiStatus( IBugzillaConstants.PLUGIN_ID, IStatus.ERROR, "Core Exception occurred while querying Bugzilla Server " + BugzillaPlugin.getDefault().getServerName() + ".\n"
+ status = new MultiStatus( IBugzillaConstants.PLUGIN_ID, IStatus.ERROR, "Core Exception occurred while querying Bugzilla Server "
+ + repository.getServerUrl().toExternalForm() + ".\n"
+ "\nClick Details for more information.", e);
((MultiStatus)status).add(e.getStatus());
@@ -245,7 +263,8 @@ public class BugzillaSearchEngine {
status = new Status(IStatus.CANCEL, IBugzillaConstants.PLUGIN_ID,
IStatus.CANCEL, "", null);
} catch (Exception e) {
- status = new MultiStatus( IBugzillaConstants.PLUGIN_ID, IStatus.ERROR, e.getClass().toString() + " occurred while querying Bugzilla Server " + BugzillaPlugin.getDefault().getServerName() + ".\n"
+ status = new MultiStatus( IBugzillaConstants.PLUGIN_ID, IStatus.ERROR, e.getClass().toString() + " occurred while querying Bugzilla Server "
+ + repository.getServerUrl().toExternalForm() + ".\n"
+ "\nClick Details or see log for more information.", e);
IStatus s = new Status(IStatus.ERROR, IBugzillaConstants.PLUGIN_ID, IStatus.ERROR, e.getClass().toString() + ": ", e);
@@ -282,7 +301,7 @@ public class BugzillaSearchEngine {
return status;
}
- public static BugzillaSearchHit createHit(RegularExpression regularExpression, IProgressMonitor monitor, BufferedReader in, Match match, int id) throws IOException {
+ public static BugzillaSearchHit createHit(RegularExpression regularExpression, IProgressMonitor monitor, BufferedReader in, Match match, String serverUrl, int id) throws IOException {
String line;
String severity = null;
String priority = null;
@@ -329,16 +348,16 @@ public class BugzillaSearchEngine {
if (line != null) description = line.substring(8);
String query = "";
- String server = "<unknown server>";
+// String server = "<unknown server>";
try {
String recentQuery = BugzillaPlugin.getMostRecentQuery();
if (recentQuery != null) query = recentQuery;
- server = BugzillaPlugin.getDefault().getServerName();
+// server = BugzillaPlugin.getDefault().getServerName();
} catch (Exception e) {
// ignore, for testing
}
- BugzillaSearchHit hit = new BugzillaSearchHit(id, description, severity, priority, platform, state, result, owner, query, server);
+ BugzillaSearchHit hit = new BugzillaSearchHit(serverUrl, id, description, severity, priority, platform, state, result, owner, query);
return hit;
}
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/search/BugzillaSearchHit.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/search/BugzillaSearchHit.java
index 9f35d5c0d..2a6c1e0d8 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/search/BugzillaSearchHit.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/search/BugzillaSearchHit.java
@@ -46,7 +46,7 @@ public class BugzillaSearchHit
/** The query that the bug was a result of */
private String query;
-
+
/**
* Constructor
* @param id The id of the bug
@@ -59,8 +59,8 @@ public class BugzillaSearchHit
* @param owner The owner of the bug
* @param query the query that the bug was a result of
*/
- public BugzillaSearchHit(int id, String description, String severity, String priority, String platform, String state, String result, String owner, String query, String server)
- {
+ public BugzillaSearchHit(String server, int id, String description, String severity, String priority, String platform, String state, String result, String owner, String query) {
+ this.server = server;
this.id = id;
this.description = description;
this.severity = severity;
@@ -70,7 +70,6 @@ public class BugzillaSearchHit
this.result = result;
this.owner = owner;
this.query = query;
- this.server = server;
}
/**
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/search/BugzillaSearchOperation.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/search/BugzillaSearchOperation.java
index 36f900ef5..bae4a3119 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/search/BugzillaSearchOperation.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/search/BugzillaSearchOperation.java
@@ -15,80 +15,78 @@ import javax.security.auth.login.LoginException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.mylar.tasklist.repositories.TaskRepository;
import org.eclipse.ui.actions.WorkspaceModifyOperation;
/**
* An operation to perform Bugzilla search query.
+ *
+ * @author Mik Kersten (hardening of prototype
*/
-public class BugzillaSearchOperation extends WorkspaceModifyOperation implements IBugzillaSearchOperation
-{
- /** The url of the bugzilla server */
- private String url;
-
+public class BugzillaSearchOperation extends WorkspaceModifyOperation implements IBugzillaSearchOperation {
+ private String queryUrl;
+
/** The bugzilla collector for the search */
private IBugzillaSearchResultCollector collector;
-
+
/** The bugzilla search query */
private BugzillaSearchQuery query;
-
+
/** The status of the search operation */
private IStatus status;
-
+
/** The LoginException that was thrown when trying to do the search */
private LoginException loginException = null;
-
+
private int maxHits;
-
- /**
- * Constructor
- * @param url The url of the bugzilla server
- * @param collector The bugzilla search collector to use for this search
- */
- public BugzillaSearchOperation(String url, IBugzillaSearchResultCollector collector, String maxHits)
- {
- this.url = url;
+
+ private TaskRepository repository;
+
+ public BugzillaSearchOperation(TaskRepository repository, String queryUrl,
+ IBugzillaSearchResultCollector collector, String maxHits) {
+ this.repository = repository;
+ this.queryUrl = queryUrl;
this.collector = collector;
collector.setOperation(this);
- try{
+ try {
this.maxHits = Integer.parseInt(maxHits);
- } catch (Exception e){
+ } catch (Exception e) {
this.maxHits = -1;
}
}
@Override
public void execute(IProgressMonitor monitor) {
- // set the progress monitor for the search collector and start the search
+ // set the progress monitor for the search collector and start the
+ // search
collector.setProgressMonitor(monitor);
- BugzillaSearchEngine engine = new BugzillaSearchEngine(url);
- try
- {
- status = engine.search(collector, 0 , maxHits);
- }
- catch(LoginException e) {
- //save this exception to throw later
+ BugzillaSearchEngine engine = new BugzillaSearchEngine(repository, queryUrl);
+ try {
+ status = engine.search(collector, 0, maxHits);
+ } catch (LoginException e) {
+ // save this exception to throw later
this.loginException = e;
}
}
-
+
/**
* @see org.eclipse.mylar.bugzilla.core.search.IBugzillaSearchOperation#getImageDescriptor()
*/
- public ImageDescriptor getImageDescriptor() {
+ public ImageDescriptor getImageDescriptor() {
return null;
}
-
+
/**
* @see org.eclipse.mylar.bugzilla.core.search.IBugzillaSearchOperation#getStatus()
*/
- public IStatus getStatus() throws LoginException {
+ public IStatus getStatus() throws LoginException {
// if a LoginException was thrown while trying to search, throw this
if (loginException == null)
return status;
else
throw loginException;
}
-
+
/**
* @see org.eclipse.mylar.bugzilla.core.search.IBugzillaSearchOperation#getQuery()
*/
diff --git a/org.eclipse.mylyn.bugzilla.tests/META-INF/MANIFEST.MF b/org.eclipse.mylyn.bugzilla.tests/META-INF/MANIFEST.MF
index a8b903c23..6a4d97e51 100644
--- a/org.eclipse.mylyn.bugzilla.tests/META-INF/MANIFEST.MF
+++ b/org.eclipse.mylyn.bugzilla.tests/META-INF/MANIFEST.MF
@@ -13,7 +13,8 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.ui.editors,
org.eclipse.ui.workbench.texteditor,
org.eclipse.mylar.bugzilla.core,
- org.eclipse.mylar.bugzilla.ui
+ org.eclipse.mylar.bugzilla.ui,
+ org.eclipse.mylar.tasklist
Eclipse-AutoStart: true
Bundle-Vendor: Eclipse.org
Bundle-ClassPath: bugzilla-test.jar
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaProductParserTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaProductParserTest.java
index a608d65a8..16bd5a0ab 100644
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaProductParserTest.java
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaProductParserTest.java
@@ -14,6 +14,7 @@ import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;
+import java.net.URL;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Iterator;
@@ -27,6 +28,8 @@ import org.eclipse.core.runtime.Path;
import org.eclipse.mylar.bugzilla.core.BugzillaPlugin;
import org.eclipse.mylar.bugzilla.core.IBugzillaConstants;
import org.eclipse.mylar.bugzilla.core.internal.ProductParser;
+import org.eclipse.mylar.tasklist.MylarTaskListPlugin;
+import org.eclipse.mylar.tasklist.repositories.TaskRepository;
/**
* Tests for parsing Product Page for new Bugzilla reports
@@ -35,10 +38,21 @@ import org.eclipse.mylar.bugzilla.core.internal.ProductParser;
*/
public class BugzillaProductParserTest extends TestCase {
- public BugzillaProductParserTest() {
- super();
+ private TaskRepository repository;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ repository = new TaskRepository(BugzillaPlugin.REPOSITORY_KIND, new URL(IBugzillaConstants.ECLIPSE_BUGZILLA_URL));
+ MylarTaskListPlugin.getRepositoryManager().addRepository(repository);
}
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ MylarTaskListPlugin.getRepositoryManager().removeRepository(repository);
+ }
+
public BugzillaProductParserTest(String arg0) {
super(arg0);
}
@@ -51,7 +65,8 @@ public class BugzillaProductParserTest extends TestCase {
File file = FileTool.getFileInPlugin(BugzillaTestPlugin.getDefault(), new Path("testdata/pages/test-products-220.html"));
Reader in = new FileReader(file);
List<String> productList = new ArrayList<String>();
- productList = new ProductParser(in).getProducts();
+ System.err.println(">>>> " + repository.getServerUrl());
+ productList = new ProductParser(in).getProducts(repository);
Iterator<String> itr = productList.iterator();
assertTrue(itr.hasNext());
@@ -69,7 +84,7 @@ public class BugzillaProductParserTest extends TestCase {
File file = FileTool.getFileInPlugin(BugzillaTestPlugin.getDefault(), new Path("testdata/pages/test-products-218.html"));
Reader in = new FileReader(file);
List<String> productList = new ArrayList<String>();
- productList = new ProductParser(in).getProducts();
+ productList = new ProductParser(in).getProducts(repository);
Iterator<String> itr = productList.iterator();
assertTrue(itr.hasNext());
@@ -88,7 +103,7 @@ public class BugzillaProductParserTest extends TestCase {
File file = FileTool.getFileInPlugin(BugzillaTestPlugin.getDefault(), new Path("testdata/pages/product-page.html"));
Reader in = new FileReader(file);
List<String> productList = new ArrayList<String>();
- productList = new ProductParser(in).getProducts();
+ productList = new ProductParser(in).getProducts(repository);
Iterator<String> itr = productList.iterator();
assertTrue(itr.hasNext());
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/RegularExpressionMatchTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/RegularExpressionMatchTest.java
index e658dd207..5c57f0b31 100644
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/RegularExpressionMatchTest.java
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/RegularExpressionMatchTest.java
@@ -18,6 +18,7 @@ import java.io.StringReader;
import junit.framework.TestCase;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.mylar.bugzilla.core.IBugzillaConstants;
import org.eclipse.mylar.bugzilla.core.search.BugzillaSearchEngine;
import org.eclipse.mylar.bugzilla.core.search.BugzillaSearchHit;
@@ -28,7 +29,7 @@ public class RegularExpressionMatchTest extends TestCase {
public void testMatchV218() throws IOException {
BufferedReader in = new BufferedReader(new StringReader(BUGZILLA_218));
Match match = new Match();
- BugzillaSearchHit hit = BugzillaSearchEngine.createHit(BugzillaSearchEngine.reValue, new NullProgressMonitor(), in, match, 123);
+ BugzillaSearchHit hit = BugzillaSearchEngine.createHit(BugzillaSearchEngine.reValue, new NullProgressMonitor(), in, match, IBugzillaConstants.ECLIPSE_BUGZILLA_URL, 123);
assertEquals("nor", hit.getSeverity());
assertEquals("P2", hit.getPriority());
}
@@ -36,7 +37,7 @@ public class RegularExpressionMatchTest extends TestCase {
public void testMatchV220() throws IOException {
BufferedReader in = new BufferedReader(new StringReader(BUGZILLA_220));
Match match = new Match();
- BugzillaSearchHit hit = BugzillaSearchEngine.createHit(BugzillaSearchEngine.reValueBugzilla220, new NullProgressMonitor(), in, match, 123);
+ BugzillaSearchHit hit = BugzillaSearchEngine.createHit(BugzillaSearchEngine.reValueBugzilla220, new NullProgressMonitor(), in, match, IBugzillaConstants.ECLIPSE_BUGZILLA_URL, 123);
assertEquals("nor", hit.getSeverity());
assertEquals("P2", hit.getPriority());
}
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/BugzillaUITools.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/BugzillaUITools.java
index b141ee85e..a9b2a9058 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/BugzillaUITools.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/BugzillaUITools.java
@@ -50,21 +50,21 @@ public class BugzillaUITools {
* Convenience method for opening a bug in an editor.
* @param id The bug id of the bug to open in the editor
*/
- public static boolean show(int id)
+ public static boolean show(String repositoryUrl, int id)
{
// determine if the editor is to be reused or not and call the appropriate
// function to show the bug
if (NewSearchUI.reuseEditor())
- return showWithReuse(id);
+ return showWithReuse(repositoryUrl, id);
else
- return showWithoutReuse(id);
+ return showWithoutReuse(repositoryUrl, id);
}
/**
* Show the bug in the same editor window
* @param id The id of the bug to show
*/
- private static boolean showWithReuse(int id)
+ private static boolean showWithReuse(String repositoryUrl, int id)
{
// get the active page so that we can reuse it
IWorkbenchPage page = SearchPlugin.getActivePage();
@@ -77,7 +77,7 @@ public class BugzillaUITools {
IEditorInput input = null;
// try to get an editor input on the bug
- input = new ExistingBugEditorInput(id);
+ input = new ExistingBugEditorInput(repositoryUrl, id);
// check if we found a valid bug
if(((ExistingBugEditorInput)input).getBug() == null)
@@ -148,8 +148,7 @@ public class BugzillaUITools {
* Show the bug in a new editor window
* @param id The id of the bug to show
*/
- private static boolean showWithoutReuse(int id)
- {
+ private static boolean showWithoutReuse(String repositoryUrl, int id) {
// get the active workbench page
IWorkbenchPage page = SearchPlugin.getActivePage();
try
@@ -162,7 +161,7 @@ public class BugzillaUITools {
String editorId = IBugzillaConstants.EXISTING_BUG_EDITOR_ID;
// get a new editor input on the bug that we want to open
- input = new ExistingBugEditorInput(id);
+ input = new ExistingBugEditorInput(repositoryUrl, id);
// check if we found a valid bug
if(((ExistingBugEditorInput)input).getBug() == null)
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/BugzillaUiPlugin.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/BugzillaUiPlugin.java
index fd9ccfba5..28b834979 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/BugzillaUiPlugin.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/BugzillaUiPlugin.java
@@ -10,10 +10,21 @@
*******************************************************************************/
package org.eclipse.mylar.bugzilla.ui;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.mylar.bugzilla.core.BugzillaPlugin;
+import org.eclipse.mylar.bugzilla.core.BugzillaPreferencePage;
import org.eclipse.mylar.bugzilla.ui.tasklist.BugzillaRefreshManager;
import org.eclipse.mylar.bugzilla.ui.tasklist.BugzillaTaskListManager;
+import org.eclipse.mylar.core.util.MylarStatusHandler;
+import org.eclipse.mylar.tasklist.MylarTaskListPlugin;
+import org.eclipse.mylar.tasklist.repositories.TaskRepository;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
@@ -41,36 +52,42 @@ public class BugzillaUiPlugin extends AbstractUIPlugin {
bugzillaRefreshManager = new BugzillaRefreshManager();
BugzillaPlugin.getDefault().addOfflineStatusListener(bugzillaTaskListManager);
-// migrateDefaultAuthenticationData();
+ migrateDefaultAuthenticationData();
}
-// @SuppressWarnings("unchecked")
-// private void migrateDefaultAuthenticationData() {
-// String serverUrl = BugzillaPlugin.getDefault().getPreferenceStore().getString(IBugzillaConstants.BUGZILLA_SERVER);
-// String user = "";
-// String password = "";
-// Map<String, String> map = Platform.getAuthorizationInfo(BugzillaPreferencePage.FAKE_URL, "Bugzilla", BugzillaPreferencePage.AUTH_SCHEME);
-//
-// // get the information from the map and save it
-// if (map != null) {
-// String username = map.get(BugzillaPreferencePage.INFO_USERNAME);
-// if (username != null) user = username;
-//
-// String pwd = map.get(BugzillaPreferencePage.INFO_PASSWORD);
-// if (pwd != null) password = pwd;
-// }
-//
-// if (serverUrl != null && serverUrl.trim() != "") {
-// TaskRepository repository;
-// try {
-// repository = new TaskRepository(new URL(serverUrl));
-// repository.setAuthenticationCredentials(user, password);
-// MylarTaskListPlugin.getRepositoryManager().addRepository(repository);
-// } catch (MalformedURLException e) {
-// MylarStatusHandler.fail(e, "could not create default repository", true);
-// }
-// }
-// }
+ @SuppressWarnings("unchecked")
+ private void migrateDefaultAuthenticationData() {
+ String serverUrl = BugzillaPlugin.getDefault().getPreferenceStore().getString("BUGZILLA_SERVER");
+ String user = "";
+ String password = "";
+ Map<String, String> map = Platform.getAuthorizationInfo(BugzillaPreferencePage.FAKE_URL, "Bugzilla", BugzillaPreferencePage.AUTH_SCHEME);
+
+ // get the information from the map and save it
+ if (map != null && !map.isEmpty()) {
+ String username = map.get(BugzillaPreferencePage.INFO_USERNAME);
+ if (username != null) user = username;
+
+ String pwd = map.get(BugzillaPreferencePage.INFO_PASSWORD);
+ if (pwd != null) password = pwd;
+ }
+
+ if (serverUrl != null && serverUrl.trim() != "") {
+ TaskRepository repository;
+ try {
+ repository = new TaskRepository(BugzillaPlugin.REPOSITORY_KIND, new URL(serverUrl));
+ repository.setAuthenticationCredentials(user, password);
+ MylarTaskListPlugin.getRepositoryManager().addRepository(repository);
+ } catch (MalformedURLException e) {
+ MylarStatusHandler.fail(e, "could not create default repository", true);
+ }
+ }
+ try {
+ // reset the authorization
+ Platform.addAuthorizationInfo(BugzillaPreferencePage.FAKE_URL, "Bugzilla", BugzillaPreferencePage.AUTH_SCHEME, new HashMap<String, String>());
+ } catch (CoreException e) {
+ // ignore
+ }
+ }
/**
* This method is called when the plug-in is stopped
@@ -107,8 +124,4 @@ public class BugzillaUiPlugin extends AbstractUIPlugin {
public BugzillaRefreshManager getBugzillaRefreshManager() {
return bugzillaRefreshManager;
}
-
- public String createBugHandleIdentifier(int bugId) {
- return "Bugzilla-" + bugId;
- }
}
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/FavoritesView.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/FavoritesView.java
index ae83b9a0e..f1243b434 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/FavoritesView.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/FavoritesView.java
@@ -36,8 +36,8 @@ import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.mylar.bugzilla.core.BugzillaPlugin;
import org.eclipse.mylar.bugzilla.core.IBugzillaConstants;
-import org.eclipse.mylar.bugzilla.core.favorites.Favorite;
-import org.eclipse.mylar.bugzilla.core.favorites.FavoritesFile;
+import org.eclipse.mylar.bugzilla.core.internal.Favorite;
+import org.eclipse.mylar.bugzilla.core.internal.FavoritesFile;
import org.eclipse.mylar.bugzilla.ui.actions.AbstractFavoritesAction;
import org.eclipse.mylar.bugzilla.ui.actions.DeleteFavoriteAction;
import org.eclipse.mylar.bugzilla.ui.actions.ViewFavoriteAction;
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/OfflineView.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/OfflineView.java
index 2e29323bd..b80e1eef7 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/OfflineView.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/OfflineView.java
@@ -38,7 +38,7 @@ import org.eclipse.mylar.bugzilla.core.BugzillaPlugin;
import org.eclipse.mylar.bugzilla.core.IBugzillaBug;
import org.eclipse.mylar.bugzilla.core.IBugzillaConstants;
import org.eclipse.mylar.bugzilla.core.IOfflineBugListener.BugzillaOfflineStaus;
-import org.eclipse.mylar.bugzilla.core.offline.OfflineReportsFile;
+import org.eclipse.mylar.bugzilla.core.internal.OfflineReportsFile;
import org.eclipse.mylar.bugzilla.ui.actions.AbstractOfflineReportsAction;
import org.eclipse.mylar.bugzilla.ui.actions.DeleteOfflineReportAction;
import org.eclipse.mylar.bugzilla.ui.actions.ViewOfflineReportAction;
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/ViewBugzillaAction.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/ViewBugzillaAction.java
index e2e100f5e..6370e3328 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/ViewBugzillaAction.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/ViewBugzillaAction.java
@@ -62,7 +62,7 @@ public class ViewBugzillaAction extends UIJob {
try {
// try to open a new editor on the bug
- ExistingBugEditorInput editorInput = new ExistingBugEditorInput(bugId.intValue());
+ ExistingBugEditorInput editorInput = new ExistingBugEditorInput(bos.getServer(), bugId.intValue());
// if the bug could not be found, then tell the user that the
// server settings are wrong
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/AddBugzillaQueryAction.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/AddBugzillaQueryAction.java
index 4b0262e3c..349738b41 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/AddBugzillaQueryAction.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/AddBugzillaQueryAction.java
@@ -17,6 +17,7 @@ import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.mylar.bugzilla.core.BugzillaPlugin;
import org.eclipse.mylar.bugzilla.ui.BugzillaImages;
import org.eclipse.mylar.bugzilla.ui.tasklist.BugzillaCustomQueryCategory;
import org.eclipse.mylar.bugzilla.ui.tasklist.BugzillaQueryCategory;
@@ -24,6 +25,7 @@ import org.eclipse.mylar.bugzilla.ui.tasklist.BugzillaQueryDialog;
import org.eclipse.mylar.core.util.MylarStatusHandler;
import org.eclipse.mylar.tasklist.MylarTaskListPlugin;
import org.eclipse.mylar.tasklist.MylarTaskListPrefConstants;
+import org.eclipse.mylar.tasklist.repositories.TaskRepository;
import org.eclipse.mylar.tasklist.ui.views.TaskListView;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IViewActionDelegate;
@@ -49,15 +51,16 @@ public class AddBugzillaQueryAction extends Action implements IViewActionDelegat
@Override
public void run() {
+ TaskRepository repository = MylarTaskListPlugin.getRepositoryManager().getDefaultRepository(BugzillaPlugin.REPOSITORY_KIND);
BugzillaQueryDialog sqd = new BugzillaQueryDialog(Display.getCurrent().getActiveShell());
if(sqd.open() == Dialog.OK){
final BugzillaQueryCategory queryCategory;
if(!sqd.isCustom()){
- queryCategory = new BugzillaQueryCategory(sqd.getName(), sqd.getUrl(), sqd.getMaxHits());
+ queryCategory = new BugzillaQueryCategory(repository.getServerUrl().toExternalForm(), sqd.getUrl(), sqd.getName(), sqd.getMaxHits());
} else {
- queryCategory = new BugzillaCustomQueryCategory(sqd.getName(), sqd.getUrl(), sqd.getMaxHits());
+ queryCategory = new BugzillaCustomQueryCategory(repository.getServerUrl().toExternalForm(), sqd.getName(), sqd.getUrl(), sqd.getMaxHits());
}
MylarTaskListPlugin.getTaskListManager().addQuery(queryCategory);
boolean offline = MylarTaskListPlugin.getPrefs().getBoolean(MylarTaskListPrefConstants.WORK_OFFLINE);
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/AddFavoriteAction.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/AddFavoriteAction.java
index a9944e557..8649c71ca 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/AddFavoriteAction.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/AddFavoriteAction.java
@@ -22,10 +22,12 @@ import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.mylar.bugzilla.core.BugzillaPlugin;
import org.eclipse.mylar.bugzilla.core.IBugzillaConstants;
-import org.eclipse.mylar.bugzilla.core.favorites.Favorite;
+import org.eclipse.mylar.bugzilla.core.internal.Favorite;
import org.eclipse.mylar.bugzilla.ui.BugzillaImages;
import org.eclipse.mylar.bugzilla.ui.FavoritesView;
import org.eclipse.mylar.bugzilla.ui.search.BugzillaSearchResultView;
+import org.eclipse.mylar.tasklist.MylarTaskListPlugin;
+import org.eclipse.mylar.tasklist.repositories.TaskRepository;
/**
@@ -99,8 +101,10 @@ public class AddFavoriteAction extends AbstractFavoritesAction {
attributes.put(IBugzillaConstants.HIT_MARKER_ATTR_SEVERITY, marker.getAttribute(IBugzillaConstants.HIT_MARKER_ATTR_SEVERITY));
attributes.put(IBugzillaConstants.HIT_MARKER_ATTR_STATE, marker.getAttribute(IBugzillaConstants.HIT_MARKER_ATTR_STATE));
attributes.put(IBugzillaConstants.HIT_MARKER_ATTR_RESULT, marker.getAttribute(IBugzillaConstants.HIT_MARKER_ATTR_RESULT));
-
- Favorite favorite = new Favorite(BugzillaPlugin.getDefault().getServerName(), attributeId.intValue(), description, query, attributes);
+
+
+ TaskRepository repository = MylarTaskListPlugin.getRepositoryManager().getDefaultRepository(BugzillaPlugin.REPOSITORY_KIND);
+ Favorite favorite = new Favorite(repository.getServerUrl().toExternalForm(), attributeId.intValue(), description, query, attributes);
selected.add(favorite);
}
catch (CoreException ignored)
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/AddToFavoritesAction.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/AddToFavoritesAction.java
index 77d82fdf3..366c6ca4c 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/AddToFavoritesAction.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/AddToFavoritesAction.java
@@ -12,7 +12,7 @@ package org.eclipse.mylar.bugzilla.ui.actions;
import org.eclipse.jface.action.Action;
import org.eclipse.mylar.bugzilla.core.BugzillaPlugin;
-import org.eclipse.mylar.bugzilla.core.favorites.Favorite;
+import org.eclipse.mylar.bugzilla.core.internal.Favorite;
import org.eclipse.mylar.bugzilla.ui.BugzillaImages;
import org.eclipse.mylar.bugzilla.ui.FavoritesView;
import org.eclipse.mylar.bugzilla.ui.editor.ExistingBugEditorInput;
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/CreateBugzillaTaskAction.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/CreateBugzillaTaskAction.java
index 969313145..72bf30868 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/CreateBugzillaTaskAction.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/CreateBugzillaTaskAction.java
@@ -15,6 +15,7 @@ import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.mylar.bugzilla.core.BugzillaPlugin;
import org.eclipse.mylar.bugzilla.ui.BugzillaImages;
import org.eclipse.mylar.bugzilla.ui.BugzillaUiPlugin;
import org.eclipse.mylar.bugzilla.ui.tasklist.BugzillaTask;
@@ -22,6 +23,8 @@ import org.eclipse.mylar.tasklist.ITask;
import org.eclipse.mylar.tasklist.ITaskHandler;
import org.eclipse.mylar.tasklist.MylarTaskListPlugin;
import org.eclipse.mylar.tasklist.internal.TaskCategory;
+import org.eclipse.mylar.tasklist.repositories.TaskRepository;
+import org.eclipse.mylar.tasklist.repositories.TaskRepositoryManager;
import org.eclipse.mylar.tasklist.ui.views.TaskListView;
import org.eclipse.ui.IViewActionDelegate;
import org.eclipse.ui.IViewPart;
@@ -61,8 +64,9 @@ public class CreateBugzillaTaskAction extends Action implements IViewActionDeleg
return;
}
+ TaskRepository repository = MylarTaskListPlugin.getRepositoryManager().getDefaultRepository(BugzillaPlugin.REPOSITORY_KIND);
ITask newTask = new BugzillaTask(
- BugzillaUiPlugin.getDefault().createBugHandleIdentifier(bugId),
+ TaskRepositoryManager.getHandle(repository.getServerUrl().toExternalForm(), bugId),
"<bugzilla info>", true, true);
Object selectedObject = ((IStructuredSelection)TaskListView.getDefault().getViewer().getSelection()).getFirstElement();
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/CreateNewBugzillaTaskAction.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/CreateNewBugzillaTaskAction.java
index cba352629..882add3f0 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/CreateNewBugzillaTaskAction.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/CreateNewBugzillaTaskAction.java
@@ -18,6 +18,7 @@ import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.mylar.bugzilla.core.BugzillaPlugin;
import org.eclipse.mylar.bugzilla.ui.BugzillaUiPlugin;
import org.eclipse.mylar.bugzilla.ui.tasklist.BugzillaTask;
import org.eclipse.mylar.bugzilla.ui.wizard.NewBugWizard;
@@ -26,6 +27,8 @@ import org.eclipse.mylar.tasklist.ITaskHandler;
import org.eclipse.mylar.tasklist.MylarTaskListPlugin;
import org.eclipse.mylar.tasklist.MylarTaskListPrefConstants;
import org.eclipse.mylar.tasklist.internal.TaskCategory;
+import org.eclipse.mylar.tasklist.repositories.TaskRepository;
+import org.eclipse.mylar.tasklist.repositories.TaskRepositoryManager;
import org.eclipse.mylar.tasklist.ui.views.TaskListView;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IViewActionDelegate;
@@ -56,7 +59,9 @@ public class CreateNewBugzillaTaskAction extends Action implements IViewActionDe
}
// MylarPlugin.getDefault().actionObserved(this);
- NewBugWizard wizard= new NewBugWizard(true);
+ TaskRepository repository = MylarTaskListPlugin.getRepositoryManager().getDefaultRepository(BugzillaPlugin.REPOSITORY_KIND);
+
+ NewBugWizard wizard= new NewBugWizard(repository, true);
Shell shell = Workbench.getInstance().getActiveWorkbenchWindow().getShell();
if (wizard != null && shell != null && !shell.isDisposed()) {
@@ -83,9 +88,10 @@ public class CreateNewBugzillaTaskAction extends Action implements IViewActionDe
return;
}
-
+// TaskRepository repository = MylarTaskListPlugin.getRepositoryManager().getDefaultRepository(BugzillaPlugin.REPOSITORY_KIND);
BugzillaTask newTask = new BugzillaTask(
- BugzillaUiPlugin.getDefault().createBugHandleIdentifier(bugId),
+ TaskRepositoryManager.getHandle(
+ repository.getServerUrl().toExternalForm(), bugId),
"<bugzilla info>", true, true);
Object selectedObject = null;
if(TaskListView.getDefault() != null)
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/OpenBugsAction.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/OpenBugsAction.java
index b427d413e..f7dae8601 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/OpenBugsAction.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/OpenBugsAction.java
@@ -21,10 +21,11 @@ import org.eclipse.mylar.bugzilla.core.BugzillaPlugin;
import org.eclipse.mylar.bugzilla.core.IBugzillaConstants;
import org.eclipse.mylar.bugzilla.ui.BugzillaUITools;
import org.eclipse.mylar.bugzilla.ui.search.BugzillaSearchResultView;
+import org.eclipse.mylar.tasklist.MylarTaskListPlugin;
+import org.eclipse.mylar.tasklist.repositories.TaskRepository;
import org.eclipse.search.internal.ui.SearchMessages;
import org.eclipse.search.internal.ui.util.ExceptionHandler;
-
/**
* This class is used to open a bug report in an editor.
*/
@@ -47,7 +48,7 @@ public class OpenBugsAction extends Action {
* Open the selected bug reports in their own editors.
*/
@SuppressWarnings("unchecked")
- @Override
+ @Override
public void run() {
// Get the selected items
@@ -59,8 +60,10 @@ public class OpenBugsAction extends Action {
for (Iterator<IMarker> it = selection.iterator(); it.hasNext();) {
IMarker marker = it.next();
try {
+
+ TaskRepository repository = MylarTaskListPlugin.getRepositoryManager().getDefaultRepository(BugzillaPlugin.REPOSITORY_KIND);
Integer id = (Integer) marker.getAttribute(IBugzillaConstants.HIT_MARKER_ATTR_ID);
- BugzillaUITools.show(id.intValue());
+ BugzillaUITools.show(repository.getServerUrl().toExternalForm(), id.intValue());
}
catch (CoreException e) {
// if an error occurs, handle and log it
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/RefreshBugzillaReportsAction.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/RefreshBugzillaReportsAction.java
index 9ac775a99..097c83ec8 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/RefreshBugzillaReportsAction.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/RefreshBugzillaReportsAction.java
@@ -25,13 +25,14 @@ import org.eclipse.mylar.bugzilla.ui.BugzillaImages;
import org.eclipse.mylar.bugzilla.ui.BugzillaUiPlugin;
import org.eclipse.mylar.bugzilla.ui.tasklist.BugzillaQueryCategory;
import org.eclipse.mylar.bugzilla.ui.tasklist.BugzillaTask;
-import org.eclipse.mylar.tasklist.ITaskQuery;
import org.eclipse.mylar.tasklist.IQueryHit;
import org.eclipse.mylar.tasklist.ITask;
import org.eclipse.mylar.tasklist.ITaskCategory;
+import org.eclipse.mylar.tasklist.ITaskQuery;
import org.eclipse.mylar.tasklist.MylarTaskListPlugin;
import org.eclipse.mylar.tasklist.MylarTaskListPrefConstants;
import org.eclipse.mylar.tasklist.internal.TaskCategory;
+import org.eclipse.mylar.tasklist.repositories.TaskRepositoryManager;
import org.eclipse.mylar.tasklist.ui.views.TaskListView;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IViewActionDelegate;
@@ -75,7 +76,7 @@ public class RefreshBugzillaReportsAction extends Action implements IViewActionD
if(found == null){
MylarTaskListPlugin.getTaskListManager().moveToRoot(task);
MessageDialog.openInformation(Display.getCurrent().getActiveShell(), "Bugzilla Task Moved To Root", "Bugzilla Task " +
- BugzillaTask.getBugId(task.getHandleIdentifier()) +
+ TaskRepositoryManager.getTaskIdAsInt(task.getHandleIdentifier()) +
" has been moved to the root since it is activated and has disappeared from a query.");
}
}
@@ -111,7 +112,7 @@ public class RefreshBugzillaReportsAction extends Action implements IViewActionD
//// try {
//// String[] parts = key.split(";");
//// final int id = Integer.parseInt(parts[1]);
-//// BugReport bug = BugzillaRepository.getInstance().getCurrentBug(id);
+//// BugReport bug = BugzillaRepositoryUtil.getInstance().getCurrentBug(id);
//// if (bug != null) {
//// bridge.cache(key, bug);
//// }
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/SynchronizeReportsAction.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/SynchronizeReportsAction.java
index d2b73583d..4cf41913a 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/SynchronizeReportsAction.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/SynchronizeReportsAction.java
@@ -30,6 +30,7 @@ import org.eclipse.mylar.tasklist.ITask;
import org.eclipse.mylar.tasklist.MylarTaskListPlugin;
import org.eclipse.mylar.tasklist.MylarTaskListPrefConstants;
import org.eclipse.mylar.tasklist.internal.TaskCategory;
+import org.eclipse.mylar.tasklist.repositories.TaskRepositoryManager;
import org.eclipse.mylar.tasklist.ui.views.TaskListView;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IViewActionDelegate;
@@ -136,7 +137,7 @@ public class SynchronizeReportsAction extends Action implements IViewActionDeleg
Display.getCurrent().getActiveShell(),
"Bugzilla Task Moved To Root",
"Bugzilla Task "
- + BugzillaTask.getBugId(task.getHandleIdentifier())
+ + TaskRepositoryManager.getTaskIdAsInt(task.getHandleIdentifier())
+ " has been moved to the root since it is activated and has disappeared from a query.");
}
}
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/editor/AbstractBugEditor.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/editor/AbstractBugEditor.java
index e96013f6c..335e842b0 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/editor/AbstractBugEditor.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/editor/AbstractBugEditor.java
@@ -28,6 +28,7 @@ import org.eclipse.jface.action.Separator;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.resource.JFaceColors;
import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.*;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
@@ -37,8 +38,7 @@ import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.mylar.bugzilla.core.Attribute;
import org.eclipse.mylar.bugzilla.core.BugReportPostHandler;
import org.eclipse.mylar.bugzilla.core.BugzillaPlugin;
-import org.eclipse.mylar.bugzilla.core.BugzillaPreferencePage;
-import org.eclipse.mylar.bugzilla.core.BugzillaRepository;
+import org.eclipse.mylar.bugzilla.core.BugzillaRepositoryUtil;
import org.eclipse.mylar.bugzilla.core.BugzillaTools;
import org.eclipse.mylar.bugzilla.core.Comment;
import org.eclipse.mylar.bugzilla.core.IBugzillaAttributeListener;
@@ -50,6 +50,7 @@ import org.eclipse.mylar.bugzilla.ui.BugzillaUITools;
import org.eclipse.mylar.bugzilla.ui.OfflineView;
import org.eclipse.mylar.bugzilla.ui.tasklist.BugzillaTaskEditor;
import org.eclipse.mylar.core.util.MylarStatusHandler;
+import org.eclipse.mylar.tasklist.repositories.TaskRepository;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CLabel;
import org.eclipse.swt.custom.ScrolledComposite;
@@ -101,6 +102,8 @@ import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
@SuppressWarnings("deprecation")
public abstract class AbstractBugEditor extends EditorPart implements Listener {
+ protected TaskRepository repository;
+
public static final int WRAP_LENGTH = 90;
protected Display display;
@@ -270,8 +273,9 @@ public abstract class AbstractBugEditor extends EditorPart implements Listener {
* Creates a new <code>AbstractBugEditor</code>. Sets up the default fonts and
* cut/copy/paste actions.
*/
- public AbstractBugEditor() {
-
+ public AbstractBugEditor(TaskRepository repository) {
+ this.repository = repository;
+
// set the scroll increments so the editor scrolls normally with the scroll wheel
FontData[] fd = TEXT_FONT.getFontData();
int cushion = 4;
@@ -1128,7 +1132,7 @@ public abstract class AbstractBugEditor extends EditorPart implements Listener {
}
public void mouseDown(MouseEvent e) {
- BugzillaUITools.openUrl(getTitle(), getTitleToolTip(), BugzillaRepository.getBugUrlWithoutLogin(bugzillaInput.getBug().getId()));
+ BugzillaUITools.openUrl(getTitle(), getTitleToolTip(), BugzillaRepositoryUtil.getBugUrlWithoutLogin(bugzillaInput.getBug().getServer(), bugzillaInput.getBug().getId()));
if (e.stateMask == SWT.MOD3) {
// XXX come back to look at this ui
close();
@@ -1277,7 +1281,8 @@ public abstract class AbstractBugEditor extends EditorPart implements Listener {
* @param formName The form that we wish to use to submit the bug
*/
protected void setURL(BugReportPostHandler form, String formName) {
- String baseURL = BugzillaPlugin.getDefault().getServerName();
+// String baseURL = BugzillaPlugin.getDefault().getServerName();
+ String baseURL = repository.getServerUrl().toExternalForm();
if (!baseURL.endsWith("/"))
baseURL += "/";
try {
@@ -1287,8 +1292,8 @@ public abstract class AbstractBugEditor extends EditorPart implements Listener {
}
// add the login information to the bug post
- form.add("Bugzilla_login", BugzillaPreferencePage.getUserName());
- form.add("Bugzilla_password", BugzillaPreferencePage.getPassword());
+ form.add("Bugzilla_login", repository.getUserName());
+ form.add("Bugzilla_password", repository.getPassword());
}
@Override
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/editor/ExistingBugEditor.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/editor/ExistingBugEditor.java
index bf428f913..b398f2d52 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/editor/ExistingBugEditor.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/editor/ExistingBugEditor.java
@@ -37,12 +37,11 @@ import org.eclipse.jface.resource.JFaceColors;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.mylar.bugzilla.core.Attribute;
-import org.eclipse.mylar.bugzilla.core.BugReportPostHandler;
import org.eclipse.mylar.bugzilla.core.BugReport;
+import org.eclipse.mylar.bugzilla.core.BugReportPostHandler;
import org.eclipse.mylar.bugzilla.core.BugzillaException;
import org.eclipse.mylar.bugzilla.core.BugzillaPlugin;
-import org.eclipse.mylar.bugzilla.core.BugzillaPreferencePage;
-import org.eclipse.mylar.bugzilla.core.BugzillaRepository;
+import org.eclipse.mylar.bugzilla.core.BugzillaRepositoryUtil;
import org.eclipse.mylar.bugzilla.core.Comment;
import org.eclipse.mylar.bugzilla.core.IBugzillaBug;
import org.eclipse.mylar.bugzilla.core.IBugzillaConstants;
@@ -57,6 +56,8 @@ import org.eclipse.mylar.bugzilla.ui.tasklist.BugzillaTask;
import org.eclipse.mylar.core.util.MylarStatusHandler;
import org.eclipse.mylar.tasklist.ITask;
import org.eclipse.mylar.tasklist.MylarTaskListPlugin;
+import org.eclipse.mylar.tasklist.repositories.TaskRepository;
+import org.eclipse.mylar.tasklist.repositories.TaskRepositoryManager;
import org.eclipse.mylar.tasklist.ui.views.TaskListView;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyledText;
@@ -120,8 +121,8 @@ public class ExistingBugEditor extends AbstractBugEditor {
/**
* Creates a new <code>ExistingBugEditor</code>.
*/
- public ExistingBugEditor() {
- super();
+ public ExistingBugEditor(TaskRepository repository) {
+ super(repository);
// Set up the input for comparing the bug report to the server
CompareConfiguration config = new CompareConfiguration();
@@ -441,7 +442,7 @@ public class ExistingBugEditor extends AbstractBugEditor {
PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
public void run() {
if (TaskListView.getDefault() != null && TaskListView.getDefault().getViewer() != null) {
- String handle = BugzillaUiPlugin.getDefault().createBugHandleIdentifier(bug.getId());
+ String handle = TaskRepositoryManager.getHandle(bug.getServer(), bug.getId());
ITask task = MylarTaskListPlugin.getTaskListManager().getTaskForHandle(handle, false);
if (task instanceof BugzillaTask) {
BugzillaUiPlugin.getDefault().getBugzillaRefreshManager().requestRefresh(
@@ -731,7 +732,7 @@ public class ExistingBugEditor extends AbstractBugEditor {
protected IStatus run(IProgressMonitor monitor) {
final BugReport serverBug;
try {
- serverBug = BugzillaRepository.getInstance().getBug(bug.getId());
+ serverBug = BugzillaRepositoryUtil.getBug(bug.getServer(), bug.getId());
// If no bug was found on the server, throw an exception so that the
// user gets the same message that appears when there is a problem reading the server.
if (serverBug == null)
@@ -954,14 +955,14 @@ public class ExistingBugEditor extends AbstractBugEditor {
Attribute owner = bug.getAttribute("Assigned To");
//Don't add the cc if the user is the bug owner
- if (owner != null && owner.getValue().indexOf(BugzillaPreferencePage.getUserName()) > -1) {
+ if (owner != null && owner.getValue().indexOf(repository.getUserName()) > -1) {
return;
}
//Add the user to the cc list
if (newCCattr != null) {
if (newCCattr.getNewValue().equals("")) {
- newCCattr.setNewValue(BugzillaPreferencePage.getUserName());
+ newCCattr.setNewValue(repository.getUserName());
}
}
}
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/editor/ExistingBugEditorInput.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/editor/ExistingBugEditorInput.java
index 578c7153b..559a95cc1 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/editor/ExistingBugEditorInput.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/editor/ExistingBugEditorInput.java
@@ -15,7 +15,7 @@ import java.io.IOException;
import javax.security.auth.login.LoginException;
import org.eclipse.mylar.bugzilla.core.BugReport;
-import org.eclipse.mylar.bugzilla.core.BugzillaRepository;
+import org.eclipse.mylar.bugzilla.core.BugzillaRepositoryUtil;
/**
@@ -23,8 +23,8 @@ import org.eclipse.mylar.bugzilla.core.BugzillaRepository;
*
* @author Mik Kersten (some hardening of initial prototype)
*/
-public class ExistingBugEditorInput extends AbstractBugEditorInput
-{
+public class ExistingBugEditorInput extends AbstractBugEditorInput {
+
protected int bugId;
protected BugReport bug;
@@ -47,20 +47,20 @@ public class ExistingBugEditorInput extends AbstractBugEditorInput
* @throws LoginException
* @throws IOException
*/
- public ExistingBugEditorInput(int bugId) throws LoginException, IOException {
+ public ExistingBugEditorInput(String repositoryUrl, int bugId) throws LoginException, IOException {
this.bugId = bugId;
// get the bug from the server if it exists
- bug = BugzillaRepository.getInstance().getBug(bugId);
+ bug = BugzillaRepositoryUtil.getBug(repositoryUrl, bugId);
}
- public ExistingBugEditorInput(int bugId, boolean offline) throws LoginException, IOException {
+ public ExistingBugEditorInput(String repositoryUrl, int bugId, boolean offline) throws LoginException, IOException {
this.bugId = bugId;
if(!offline){
try {
- bug = BugzillaRepository.getInstance().getBug(bugId);
+ bug = BugzillaRepositoryUtil.getBug(repositoryUrl, bugId);
} catch (IOException e) {
- bug = BugzillaRepository.getInstance().getCurrentBug(bugId);
+ bug = BugzillaRepositoryUtil.getCurrentBug(repositoryUrl, bugId);
// IWorkbench workbench = PlatformUI.getWorkbench();
// workbench.getDisplay().asyncExec(new Runnable() {
// public void run() {
@@ -73,13 +73,10 @@ public class ExistingBugEditorInput extends AbstractBugEditorInput
// });
}
} else {
- bug = BugzillaRepository.getInstance().getCurrentBug(bugId);
+ bug = BugzillaRepositoryUtil.getCurrentBug(repositoryUrl, bugId);
}
}
- /*
- * @see IEditorInput#getName()
- */
public String getName() {
return bug.getLabel();
}
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/editor/NewBugEditor.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/editor/NewBugEditor.java
index 23c59812a..f14487185 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/editor/NewBugEditor.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/editor/NewBugEditor.java
@@ -33,6 +33,7 @@ import org.eclipse.mylar.bugzilla.ui.OfflineView;
import org.eclipse.mylar.bugzilla.ui.WebBrowserDialog;
import org.eclipse.mylar.bugzilla.ui.actions.RefreshBugzillaReportsAction;
import org.eclipse.mylar.core.util.MylarStatusHandler;
+import org.eclipse.mylar.tasklist.repositories.TaskRepository;
import org.eclipse.mylar.tasklist.ui.views.TaskListView;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
@@ -62,8 +63,8 @@ public class NewBugEditor extends AbstractBugEditor {
/**
* Creates a new <code>NewBugEditor</code>.
*/
- public NewBugEditor() {
- super();
+ public NewBugEditor(TaskRepository repository) {
+ super(repository);
}
@Override
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/search/BugzillaSearchPage.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/search/BugzillaSearchPage.java
index ca96d7cd0..50fd83a5e 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/search/BugzillaSearchPage.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/search/BugzillaSearchPage.java
@@ -23,7 +23,7 @@ import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.mylar.bugzilla.core.BugzillaPlugin;
-import org.eclipse.mylar.bugzilla.core.BugzillaPreferencePage;
+import org.eclipse.mylar.bugzilla.core.BugzillaRepositoryUtil;
import org.eclipse.mylar.bugzilla.core.IBugzillaConstants;
import org.eclipse.mylar.bugzilla.core.search.BugzillaSearchOperation;
import org.eclipse.mylar.bugzilla.core.search.BugzillaSearchQuery;
@@ -31,6 +31,9 @@ import org.eclipse.mylar.bugzilla.core.search.BugzillaSearchResultCollector;
import org.eclipse.mylar.bugzilla.core.search.IBugzillaSearchOperation;
import org.eclipse.mylar.bugzilla.core.search.IBugzillaSearchResultCollector;
import org.eclipse.mylar.bugzilla.ui.BugzillaUITools;
+import org.eclipse.mylar.core.util.MylarStatusHandler;
+import org.eclipse.mylar.tasklist.MylarTaskListPlugin;
+import org.eclipse.mylar.tasklist.repositories.TaskRepository;
import org.eclipse.search.ui.ISearchPage;
import org.eclipse.search.ui.ISearchPageContainer;
import org.eclipse.search.ui.NewSearchUI;
@@ -47,6 +50,7 @@ import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.List;
@@ -89,38 +93,38 @@ public class BugzillaSearchPage extends DialogPage implements ISearchPage {
protected IPreferenceStore prefs = BugzillaPlugin.getDefault().getPreferenceStore();
- private String[] statusValues = BugzillaPreferencePage.queryOptionsToArray(prefs
- .getString(IBugzillaConstants.STATUS_VALUES));
+ private String[] statusValues = BugzillaRepositoryUtil.queryOptionsToArray(prefs
+ .getString(IBugzillaConstants.VALUES_STATUS));
- protected String[] preselectedStatusValues = BugzillaPreferencePage.queryOptionsToArray(prefs
- .getString(IBugzillaConstants.PRESELECTED_STATUS_VALUES));
+ protected String[] preselectedStatusValues = BugzillaRepositoryUtil.queryOptionsToArray(prefs
+ .getString(IBugzillaConstants.VALUSE_STATUS_PRESELECTED));
- private String[] resolutionValues = BugzillaPreferencePage.queryOptionsToArray(prefs
- .getString(IBugzillaConstants.RESOLUTION_VALUES));
+ private String[] resolutionValues = BugzillaRepositoryUtil.queryOptionsToArray(prefs
+ .getString(IBugzillaConstants.VALUES_RESOLUTION));
- private String[] severityValues = BugzillaPreferencePage.queryOptionsToArray(prefs
- .getString(IBugzillaConstants.SEVERITY_VALUES));
+ private String[] severityValues = BugzillaRepositoryUtil.queryOptionsToArray(prefs
+ .getString(IBugzillaConstants.VALUES_SEVERITY));
- private String[] priorityValues = BugzillaPreferencePage.queryOptionsToArray(prefs
- .getString(IBugzillaConstants.PRIORITY_VALUES));
+ private String[] priorityValues = BugzillaRepositoryUtil.queryOptionsToArray(prefs
+ .getString(IBugzillaConstants.VALUES_PRIORITY));
- private String[] hardwareValues = BugzillaPreferencePage.queryOptionsToArray(prefs
- .getString(IBugzillaConstants.HARDWARE_VALUES));
+ private String[] hardwareValues = BugzillaRepositoryUtil.queryOptionsToArray(prefs
+ .getString(IBugzillaConstants.VALUES_HARDWARE));
- private String[] osValues = BugzillaPreferencePage.queryOptionsToArray(prefs
- .getString(IBugzillaConstants.OS_VALUES));
+ private String[] osValues = BugzillaRepositoryUtil.queryOptionsToArray(prefs
+ .getString(IBugzillaConstants.VALUES_OS));
- private String[] productValues = BugzillaPreferencePage.queryOptionsToArray(prefs
- .getString(IBugzillaConstants.PRODUCT_VALUES));
+ private String[] productValues = BugzillaRepositoryUtil.queryOptionsToArray(prefs
+ .getString(IBugzillaConstants.VALUES_PRODUCT));
- private String[] componentValues = BugzillaPreferencePage.queryOptionsToArray(prefs
- .getString(IBugzillaConstants.COMPONENT_VALUES));
+ private String[] componentValues = BugzillaRepositoryUtil.queryOptionsToArray(prefs
+ .getString(IBugzillaConstants.VALUES_COMPONENT));
- private String[] versionValues = BugzillaPreferencePage.queryOptionsToArray(prefs
- .getString(IBugzillaConstants.VERSION_VALUES));
+ private String[] versionValues = BugzillaRepositoryUtil.queryOptionsToArray(prefs
+ .getString(IBugzillaConstants.VALUES_VERSION));
- private String[] targetValues = BugzillaPreferencePage.queryOptionsToArray(prefs
- .getString(IBugzillaConstants.TARGET_VALUES));
+ private String[] targetValues = BugzillaRepositoryUtil.queryOptionsToArray(prefs
+ .getString(IBugzillaConstants.VALUES_TARGET));
private static class BugzillaSearchData {
/** Pattern to match on */
@@ -728,40 +732,41 @@ public class BugzillaSearchPage extends DialogPage implements ISearchPage {
monitor.beginTask("Updating search options...", 55);
try {
- BugzillaPreferencePage.updateQueryOptions(monitor);
+ TaskRepository repository = MylarTaskListPlugin.getRepositoryManager().getDefaultRepository(BugzillaPlugin.REPOSITORY_KIND);
+ BugzillaRepositoryUtil.updateQueryOptions(repository, monitor);
- product.setItems(BugzillaPreferencePage.queryOptionsToArray(prefs
- .getString(IBugzillaConstants.PRODUCT_VALUES)));
+ product.setItems(BugzillaRepositoryUtil.queryOptionsToArray(prefs
+ .getString(IBugzillaConstants.VALUES_PRODUCT)));
monitor.worked(1);
- component.setItems(BugzillaPreferencePage.queryOptionsToArray(prefs
- .getString(IBugzillaConstants.COMPONENT_VALUES)));
+ component.setItems(BugzillaRepositoryUtil.queryOptionsToArray(prefs
+ .getString(IBugzillaConstants.VALUES_COMPONENT)));
monitor.worked(1);
- version.setItems(BugzillaPreferencePage.queryOptionsToArray(prefs
- .getString(IBugzillaConstants.VERSION_VALUES)));
+ version.setItems(BugzillaRepositoryUtil.queryOptionsToArray(prefs
+ .getString(IBugzillaConstants.VALUES_VERSION)));
monitor.worked(1);
- target.setItems(BugzillaPreferencePage.queryOptionsToArray(prefs
- .getString(IBugzillaConstants.TARGET_VALUES)));
+ target.setItems(BugzillaRepositoryUtil.queryOptionsToArray(prefs
+ .getString(IBugzillaConstants.VALUES_TARGET)));
monitor.worked(1);
- status.setItems(BugzillaPreferencePage.queryOptionsToArray(prefs
- .getString(IBugzillaConstants.STATUS_VALUES)));
+ status.setItems(BugzillaRepositoryUtil.queryOptionsToArray(prefs
+ .getString(IBugzillaConstants.VALUES_STATUS)));
monitor.worked(1);
- status.setSelection(BugzillaPreferencePage.queryOptionsToArray(prefs
- .getString(IBugzillaConstants.PRESELECTED_STATUS_VALUES)));
+ status.setSelection(BugzillaRepositoryUtil.queryOptionsToArray(prefs
+ .getString(IBugzillaConstants.VALUSE_STATUS_PRESELECTED)));
monitor.worked(1);
- resolution.setItems(BugzillaPreferencePage.queryOptionsToArray(prefs
- .getString(IBugzillaConstants.RESOLUTION_VALUES)));
+ resolution.setItems(BugzillaRepositoryUtil.queryOptionsToArray(prefs
+ .getString(IBugzillaConstants.VALUES_RESOLUTION)));
monitor.worked(1);
- severity.setItems(BugzillaPreferencePage.queryOptionsToArray(prefs
- .getString(IBugzillaConstants.SEVERITY_VALUES)));
+ severity.setItems(BugzillaRepositoryUtil.queryOptionsToArray(prefs
+ .getString(IBugzillaConstants.VALUES_SEVERITY)));
monitor.worked(1);
- priority.setItems(BugzillaPreferencePage.queryOptionsToArray(prefs
- .getString(IBugzillaConstants.PRIORITY_VALUES)));
+ priority.setItems(BugzillaRepositoryUtil.queryOptionsToArray(prefs
+ .getString(IBugzillaConstants.VALUES_PRIORITY)));
monitor.worked(1);
- hardware.setItems(BugzillaPreferencePage.queryOptionsToArray(prefs
- .getString(IBugzillaConstants.HARDWARE_VALUES)));
+ hardware.setItems(BugzillaRepositoryUtil.queryOptionsToArray(prefs
+ .getString(IBugzillaConstants.VALUES_HARDWARE)));
monitor.worked(1);
- os.setItems(BugzillaPreferencePage.queryOptionsToArray(prefs
- .getString(IBugzillaConstants.OS_VALUES)));
+ os.setItems(BugzillaRepositoryUtil.queryOptionsToArray(prefs
+ .getString(IBugzillaConstants.VALUES_OS)));
monitor.worked(1);
} catch (LoginException exception) {
// we had a problem that seems to have been caused from bad
@@ -793,23 +798,26 @@ public class BugzillaSearchPage extends DialogPage implements ISearchPage {
operation.setText(operation.getItem(patternData.operation));
}
- /**
- * @see ISearchPage#performAction()
- */
public boolean performAction() {
+ TaskRepository repository = MylarTaskListPlugin.getRepositoryManager().getDefaultRepository(BugzillaPlugin.REPOSITORY_KIND);
+ if (repository == null) {
+ MessageDialog.openInformation(Display.getCurrent().getActiveShell(), "Bugzilla Client Information", "No repository available, please add one.");
+ return false;
+ }
+
getPatternData(summaryPattern, summaryOperation, previousSummaryPatterns);
getPatternData(commentPattern, commentOperation, previousCommentPatterns);
getPatternData(this.emailPattern, emailOperation, previousEmailPatterns);
String summaryText;
- String url;
+ String queryUrl;
if (rememberedQuery == true) {
- url = getQueryURL(new StringBuffer(input.getQueryParameters(selIndex)));
+ queryUrl = getQueryURL(repository, new StringBuffer(input.getQueryParameters(selIndex)));
summaryText = input.getSummaryText(selIndex);
} else {
try {
StringBuffer params = getQueryParameters();
- url = getQueryURL(params);
+ queryUrl = getQueryURL(repository, params);
summaryText = summaryPattern.getText();
} catch (UnsupportedEncodingException e) {
/*
@@ -817,7 +825,7 @@ public class BugzillaSearchPage extends DialogPage implements ISearchPage {
* implementation of the Java platform is required to support
* the standard charset "UTF-8"
*/
- url = "";
+ queryUrl = "";
summaryText = "";
}
}
@@ -825,7 +833,7 @@ public class BugzillaSearchPage extends DialogPage implements ISearchPage {
try {
// if the summary contains a single bug id, open the bug directly
int id = Integer.parseInt(summaryText);
- return BugzillaUITools.show(id);
+ return BugzillaUITools.show(repository.getServerUrl().toExternalForm(), id);
} catch (NumberFormatException ignored) {
// ignore this since this means that the text is not a bug id
}
@@ -839,7 +847,7 @@ public class BugzillaSearchPage extends DialogPage implements ISearchPage {
IBugzillaSearchResultCollector collector = new BugzillaSearchResultCollector();
- IBugzillaSearchOperation op = new BugzillaSearchOperation(url, collector, maxHits);
+ IBugzillaSearchOperation op = new BugzillaSearchOperation(repository, queryUrl, collector, maxHits);
BugzillaSearchQuery searchQuery = new BugzillaSearchQuery(op);
NewSearchUI.runQueryInBackground(searchQuery);
@@ -937,8 +945,8 @@ public class BugzillaSearchPage extends DialogPage implements ISearchPage {
return patterns;
}
- protected String getQueryURL(StringBuffer params) {
- StringBuffer url = new StringBuffer(getQueryURLStart().toString());
+ protected String getQueryURL(TaskRepository repository, StringBuffer params) {
+ StringBuffer url = new StringBuffer(getQueryURLStart(repository).toString());
url.append(params);
// HACK make sure that the searches come back sorted by priority. This
@@ -952,8 +960,9 @@ public class BugzillaSearchPage extends DialogPage implements ISearchPage {
*
* Example: https://bugs.eclipse.org/bugs/buglist.cgi?
*/
- private StringBuffer getQueryURLStart() {
- StringBuffer sb = new StringBuffer(BugzillaPlugin.getDefault().getServerName());
+ private StringBuffer getQueryURLStart(TaskRepository repository) {
+// StringBuffer sb = new StringBuffer(BugzillaPlugin.getDefault().getServerName());
+ StringBuffer sb = new StringBuffer(repository.getServerUrl().toExternalForm());
if (sb.charAt(sb.length() - 1) != '/') {
sb.append('/');
@@ -961,17 +970,13 @@ public class BugzillaSearchPage extends DialogPage implements ISearchPage {
sb.append("buglist.cgi?");
// use the username and password if we have it
- if (BugzillaPreferencePage.getUserName() != null && !BugzillaPreferencePage.getUserName().equals("")
- && BugzillaPreferencePage.getPassword() != null && !BugzillaPreferencePage.getPassword().equals("")) {
+ if (repository.hasCredentials()) {
try {
sb.append("GoAheadAndLogIn=1&Bugzilla_login="
- + URLEncoder.encode(BugzillaPreferencePage.getUserName(), "UTF-8") + "&Bugzilla_password="
- + URLEncoder.encode(BugzillaPreferencePage.getPassword(), "UTF-8") + "&");
+ + URLEncoder.encode(repository.getUserName(), BugzillaPlugin.ENCODING_UTF_8) + "&Bugzilla_password="
+ + URLEncoder.encode(repository.getPassword(), BugzillaPlugin.ENCODING_UTF_8) + "&");
} catch (UnsupportedEncodingException e) {
- /*
- * Do nothing. Every implementation of the Java platform is
- * required to support the standard charset "UTF-8"
- */
+ MylarStatusHandler.fail(e, "unsupported encoding", false);
}
}
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/search/BugzillaSearchResultView.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/search/BugzillaSearchResultView.java
index 123be4682..b7b99cea7 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/search/BugzillaSearchResultView.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/search/BugzillaSearchResultView.java
@@ -34,6 +34,8 @@ import org.eclipse.mylar.bugzilla.ui.BugzillaUITools;
import org.eclipse.mylar.bugzilla.ui.actions.AddFavoriteAction;
import org.eclipse.mylar.bugzilla.ui.actions.BugzillaSortAction;
import org.eclipse.mylar.bugzilla.ui.actions.OpenBugsAction;
+import org.eclipse.mylar.tasklist.MylarTaskListPlugin;
+import org.eclipse.mylar.tasklist.repositories.TaskRepository;
import org.eclipse.search.internal.ui.SearchMessages;
import org.eclipse.search.internal.ui.SearchPlugin;
import org.eclipse.search.internal.ui.SearchPreferencePage;
@@ -194,7 +196,8 @@ public class BugzillaSearchResultView extends AbstractTextSearchViewPage impleme
Object element = getCurrentMatch().getElement();
if (element instanceof IMarker) {
Integer id = (Integer) ((IMarker)element).getAttribute(IBugzillaConstants.HIT_MARKER_ATTR_ID);
- BugzillaUITools.show(id.intValue());
+ TaskRepository repository = MylarTaskListPlugin.getRepositoryManager().getDefaultRepository(BugzillaPlugin.REPOSITORY_KIND);
+ BugzillaUITools.show(repository.getServerUrl().toExternalForm(), id.intValue());
}
}
catch (CoreException e) {
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaCategorySearchOperation.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaCategorySearchOperation.java
index 0922f7bf3..6d0c7a6eb 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaCategorySearchOperation.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaCategorySearchOperation.java
@@ -26,104 +26,112 @@ import org.eclipse.mylar.bugzilla.core.search.BugzillaSearchQuery;
import org.eclipse.mylar.bugzilla.core.search.IBugzillaSearchOperation;
import org.eclipse.mylar.bugzilla.ui.search.BugzillaResultCollector;
import org.eclipse.mylar.core.util.MylarStatusHandler;
+import org.eclipse.mylar.tasklist.repositories.TaskRepository;
import org.eclipse.ui.actions.WorkspaceModifyOperation;
-
/**
* Bugzilla search operation for Mylar
*
* @author Shawn Minto
*/
-public class BugzillaCategorySearchOperation extends WorkspaceModifyOperation
- implements IBugzillaSearchOperation {
- /** The IMember we are doing the search for */
+public class BugzillaCategorySearchOperation extends WorkspaceModifyOperation implements IBugzillaSearchOperation {
+ /** The IMember we are doing the search for */
public interface ICategorySearchListener {
public void searchCompleted(BugzillaResultCollector collector);
}
/** The bugzilla collector for the search */
- private BugzillaResultCollector collector = null;
-
- /** The status of the search operation */
- private IStatus status;
-
- /** The LoginException that was thrown when trying to do the search */
- private LoginException loginException = null;
-
- private String url;
- private int maxHits;
- private boolean isMaxReached;
-
- /**
- * Constructor
- *
- * @param m
- * The member that we are doing the search for
- */
- public BugzillaCategorySearchOperation(String url, int maxHits) {
- this.url = url;
- this.maxHits = maxHits;
- }
-
- @Override
- public void execute(IProgressMonitor monitor) {
- collector = new BugzillaResultCollector();
- collector.setOperation(this);
- collector.setProgressMonitor(monitor);
- search(url, monitor);
- for(ICategorySearchListener listener: listeners)
- listener.searchCompleted(collector);
- }
-
- /**
- * Perform the actual search on the Bugzilla server
- * @param url The url to use for the search
- * @param searchCollector The collector to put the search results into
- * @param monitor The progress monitor to use for the search
- * @return The BugzillaResultCollector with the search results
- */
- private BugzillaResultCollector search(String url, IProgressMonitor monitor){
-
- // set the initial number of matches to 0
- int matches = 0;
- // setup the progress monitor and start the search
+ private BugzillaResultCollector collector = null;
+
+ /** The status of the search operation */
+ private IStatus status;
+
+ /** The LoginException that was thrown when trying to do the search */
+ private LoginException loginException = null;
+
+ private String queryUrl;
+
+ private TaskRepository repository;
+
+ private int maxHits;
+
+ private boolean isMaxReached;
+
+ /**
+ * Constructor
+ *
+ * @param m
+ * The member that we are doing the search for
+ */
+ public BugzillaCategorySearchOperation(TaskRepository repository, String queryUrl, int maxHits) {
+ this.queryUrl = queryUrl;
+ this.maxHits = maxHits;
+ this.repository = repository;
+ }
+
+ @Override
+ public void execute(IProgressMonitor monitor) {
+ collector = new BugzillaResultCollector();
+ collector.setOperation(this);
+ collector.setProgressMonitor(monitor);
+ search(queryUrl, monitor);
+ for (ICategorySearchListener listener : listeners)
+ listener.searchCompleted(collector);
+ }
+
+ /**
+ * Perform the actual search on the Bugzilla server
+ *
+ * @param queryUrl
+ * The queryUrl to use for the search
+ * @param searchCollector
+ * The collector to put the search results into
+ * @param monitor
+ * The progress monitor to use for the search
+ * @return The BugzillaResultCollector with the search results
+ */
+ private BugzillaResultCollector search(String queryUrl, IProgressMonitor monitor) {
+
+ // set the initial number of matches to 0
+ int matches = 0;
+ // setup the progress monitor and start the search
collector.setProgressMonitor(monitor);
- BugzillaSearchEngine engine = new BugzillaSearchEngine(url);
+ BugzillaSearchEngine engine = new BugzillaSearchEngine(repository, queryUrl);
try {
-
- // perform the search
- status = engine.search(collector, matches, maxHits);
-
- // check the status so that we don't keep searching if there
- // is a problem
- if (status.getCode() == IStatus.CANCEL) {
- MylarStatusHandler.log("search cancelled", this);
- return null;
- } else if (!status.isOK()) {
- MylarStatusHandler.log("search error", this);
- MylarStatusHandler.log(status);
- return null;
- }
- isMaxReached = engine.isMaxReached();
- return collector;
- } catch (LoginException e) {
- //save this exception to throw later
- this.loginException = e;
- }
- return null;
+
+ // perform the search
+ status = engine.search(collector, matches, maxHits);
+
+ // check the status so that we don't keep searching if there
+ // is a problem
+ if (status.getCode() == IStatus.CANCEL) {
+ MylarStatusHandler.log("search cancelled", this);
+ return null;
+ } else if (!status.isOK()) {
+ MylarStatusHandler.log("search error", this);
+ MylarStatusHandler.log(status);
+ return null;
+ }
+ isMaxReached = engine.isMaxReached();
+ return collector;
+ } catch (LoginException e) {
+ // save this exception to throw later
+ this.loginException = e;
+ }
+ return null;
}
- /**
- * @see org.eclipse.mylar.bugzilla.core.search.IBugzillaSearchOperation#getStatus()
- */
- public IStatus getStatus() throws LoginException {
- // if a LoginException was thrown while trying to search, throw this
- if (loginException == null)
- return status;
- else
- throw loginException;
- }
+ /**
+ * @see org.eclipse.mylar.bugzilla.core.search.IBugzillaSearchOperation#getStatus()
+ */
+ public IStatus getStatus() throws LoginException {
+ // if a LoginException was thrown while trying to search, throw this
+ if (loginException == null)
+ return status;
+ else
+ throw loginException;
+ }
public ImageDescriptor getImageDescriptor() {
return null;
@@ -133,11 +141,12 @@ public class BugzillaCategorySearchOperation extends WorkspaceModifyOperation
return null;
}
- public void setQuery(BugzillaSearchQuery newQuery) {}
-
+ public void setQuery(BugzillaSearchQuery newQuery) {
+ }
+
private List<ICategorySearchListener> listeners = new ArrayList<ICategorySearchListener>();
-
- public void addResultsListener(ICategorySearchListener listener){
+
+ public void addResultsListener(ICategorySearchListener listener) {
listeners.add(listener);
}
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaCustomQueryCategory.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaCustomQueryCategory.java
index 16006b407..ee9f12b63 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaCustomQueryCategory.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaCustomQueryCategory.java
@@ -16,7 +16,7 @@ package org.eclipse.mylar.bugzilla.ui.tasklist;
*/
public class BugzillaCustomQueryCategory extends BugzillaQueryCategory {
- public BugzillaCustomQueryCategory(String description, String maxHits, String queryString) {
- super(description, maxHits, queryString);
+ public BugzillaCustomQueryCategory(String repositoryUrl, String description, String maxHits, String queryString) {
+ super(repositoryUrl, maxHits, description, queryString);
}
}
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaHit.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaHit.java
index 064a00c51..318eca04e 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaHit.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaHit.java
@@ -11,7 +11,7 @@
package org.eclipse.mylar.bugzilla.ui.tasklist;
-import org.eclipse.mylar.bugzilla.core.BugzillaRepository;
+import org.eclipse.mylar.bugzilla.core.BugzillaRepositoryUtil;
import org.eclipse.mylar.bugzilla.core.internal.HtmlStreamTokenizer;
import org.eclipse.mylar.bugzilla.ui.BugzillaImages;
import org.eclipse.mylar.bugzilla.ui.BugzillaUiPlugin;
@@ -28,6 +28,8 @@ import org.eclipse.swt.graphics.Image;
*/
public class BugzillaHit implements IQueryHit {
+ private String repositoryUrl;
+
private String description;
private String priority;
@@ -38,9 +40,10 @@ public class BugzillaHit implements IQueryHit {
private String status;
- public BugzillaHit(String description, String priority, int id, BugzillaTask task, String status) {
+ public BugzillaHit(String description, String priority, String repositoryUrl, int id, BugzillaTask task, String status) {
this.description = description;
this.priority = priority;
+ this.repositoryUrl = repositoryUrl;
this.id = id;
this.task = task;
this.status = status;
@@ -100,20 +103,20 @@ public class BugzillaHit implements IQueryHit {
}
public String getHandleIdentifier() {
- return getServerName() + "-" + getId();
+ return "Bugzilla" + "-" + getId();
}
- public String getServerName() {
- // TODO need the right server name - get from the handle
- return "Bugzilla";
- }
+// public String getServerName() {
+// // TODO need the right server name - get from the handle
+// return "Bugzilla";
+// }
public int getId() {
return id;
}
public String getBugUrl() {
- return BugzillaRepository.getBugUrlWithoutLogin(id);
+ return BugzillaRepositoryUtil.getBugUrlWithoutLogin(repositoryUrl, id);
}
public boolean isLocal() {
@@ -182,4 +185,8 @@ public class BugzillaHit implements IQueryHit {
public void setHandle(String id) {
// can't change the handle
}
+
+ public String getRepositoryUrl() {
+ return repositoryUrl;
+ }
}
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaQueryCategory.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaQueryCategory.java
index 5398791c9..279b852da 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaQueryCategory.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaQueryCategory.java
@@ -31,9 +31,11 @@ import org.eclipse.mylar.bugzilla.ui.BugzillaImages;
import org.eclipse.mylar.bugzilla.ui.BugzillaUiPlugin;
import org.eclipse.mylar.bugzilla.ui.search.BugzillaResultCollector;
import org.eclipse.mylar.bugzilla.ui.tasklist.BugzillaCategorySearchOperation.ICategorySearchListener;
-import org.eclipse.mylar.tasklist.ITaskQuery;
+import org.eclipse.mylar.core.util.MylarStatusHandler;
import org.eclipse.mylar.tasklist.IQueryHit;
+import org.eclipse.mylar.tasklist.ITaskQuery;
import org.eclipse.mylar.tasklist.MylarTaskListPlugin;
+import org.eclipse.mylar.tasklist.repositories.TaskRepository;
import org.eclipse.mylar.tasklist.ui.ITaskListElement;
import org.eclipse.mylar.tasklist.ui.TaskListImages;
import org.eclipse.mylar.tasklist.ui.views.TaskListView;
@@ -44,10 +46,13 @@ import org.eclipse.ui.PlatformUI;
/**
* @author Shawn Minto
+ * @author Mik Kersten
*/
public class BugzillaQueryCategory implements ITaskQuery {
- private String queryString;
+ private String repositoryUrl;
+
+ private String queryUrl;
private int maxHits;
@@ -72,16 +77,22 @@ public class BugzillaQueryCategory implements ITaskQuery {
public void searchCompleted(BugzillaResultCollector collector) {
for (BugzillaSearchHit hit : collector.getResults()) {
- // HACK need the server name and handle properly
- addHit(new BugzillaHit(hit.getId() + ": " + hit.getDescription(), hit.getPriority(), hit.getId(), null, hit.getState()));
+ addHit(new BugzillaHit(
+ hit.getId() + ": " + hit.getDescription(),
+ hit.getPriority(),
+ repositoryUrl,
+ hit.getId(),
+ null,
+ hit.getState()));
}
}
}
- public BugzillaQueryCategory(String label, String url, String maxHits) {
+ public BugzillaQueryCategory(String repositoryUrl, String queryUrl, String label, String maxHits) {
this.description = label;
- this.queryString = url;
+ this.queryUrl = queryUrl;
+ this.repositoryUrl = repositoryUrl;
try {
this.maxHits = Integer.parseInt(maxHits);
} catch (Exception e) {
@@ -110,7 +121,7 @@ public class BugzillaQueryCategory implements ITaskQuery {
}
public String getQueryUrl() {
- return queryString;
+ return queryUrl;
}
public List<IQueryHit> getHits() {
@@ -118,7 +129,8 @@ public class BugzillaQueryCategory implements ITaskQuery {
}
public void addHit(IQueryHit hit) {
- BugzillaTask task = BugzillaUiPlugin.getDefault().getBugzillaTaskListManager().getFromBugzillaTaskRegistry(hit.getHandleIdentifier());
+ BugzillaTask task = BugzillaUiPlugin.getDefault().getBugzillaTaskListManager().getFromBugzillaTaskRegistry(
+ hit.getHandleIdentifier());
hit.setCorrespondingTask(task);
hits.add(hit);
}
@@ -136,53 +148,56 @@ public class BugzillaQueryCategory implements ITaskQuery {
TaskListView.getDefault().getViewer().refresh();
}
});
- final BugzillaCategorySearchOperation catSearch = new BugzillaCategorySearchOperation(getQueryUrl(), maxHits);
- catSearch.addResultsListener(listener);
- final IStatus[] status = new IStatus[1];
- try {
- // execute the search operation
- catSearch.execute(new NullProgressMonitor());
- isMaxReached = catSearch.isMaxReached();
- hasBeenRefreshed = true;
- lastRefresh = new Date();
-
- // get the status of the search operation
- status[0] = catSearch.getStatus();
-
- // determine if there was an error, if it was cancelled, or if it is
- // ok
- if (status[0].getCode() == IStatus.CANCEL) {
- // it was cancelled, so just return
- status[0] = Status.OK_STATUS;
- // return status[0];
- return;
- } else if (!status[0].isOK()) {
- // there was an error, so display an error message
- PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
- public void run() {
- ErrorDialog.openError(null, "Bugzilla Search Error", null, status[0]);
- }
- });
- status[0] = Status.OK_STATUS;
- return;
- // return status[0];
+ TaskRepository repository = MylarTaskListPlugin.getRepositoryManager().getRepository(BugzillaPlugin.REPOSITORY_KIND, repositoryUrl);
+ if (repository == null) {
+ MylarStatusHandler.fail(null, "could not find repository for url: " + repositoryUrl, true);
+ } else {
+ final BugzillaCategorySearchOperation catSearch = new BugzillaCategorySearchOperation(
+ repository, getQueryUrl(), maxHits);
+ catSearch.addResultsListener(listener);
+ final IStatus[] status = new IStatus[1];
+
+ try {
+ // execute the search operation
+ catSearch.execute(new NullProgressMonitor());
+ isMaxReached = catSearch.isMaxReached();
+ hasBeenRefreshed = true;
+ lastRefresh = new Date();
+
+ // get the status of the search operation
+ status[0] = catSearch.getStatus();
+
+ // determine if there was an error, if it was cancelled, or if it is
+ // ok
+ if (status[0].getCode() == IStatus.CANCEL) {
+ // it was cancelled, so just return
+ status[0] = Status.OK_STATUS;
+ } else if (!status[0].isOK()) {
+ // there was an error, so display an error message
+ PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ ErrorDialog.openError(null, "Bugzilla Search Error", null, status[0]);
+ }
+ });
+ status[0] = Status.OK_STATUS;
+ }
+ } catch (LoginException e) {
+ // we had a problem while searching that seems like a login info
+ // problem
+ // thrown in BugzillaSearchOperation
+ MessageDialog
+ .openError(
+ Display.getDefault().getActiveShell(),
+ "Login Error",
+ "Bugzilla could not log you in to get the information you requested since login name or password is incorrect.\nPlease check your settings in the bugzilla preferences. ");
+ BugzillaPlugin.log(new Status(IStatus.ERROR, IBugzillaConstants.PLUGIN_ID, IStatus.OK, "", e));
}
- } catch (LoginException e) {
- // we had a problem while searching that seems like a login info
- // problem
- // thrown in BugzillaSearchOperation
- MessageDialog
- .openError(Display.getDefault().getActiveShell(),
- "Login Error",
- "Bugzilla could not log you in to get the information you requested since login name or password is incorrect.\nPlease check your settings in the bugzilla preferences. ");
- BugzillaPlugin.log(new Status(IStatus.ERROR, IBugzillaConstants.PLUGIN_ID, IStatus.OK, "", e));
}
- return;
}
public void setQueryUrl(String url) {
- this.queryString = url;
+ this.queryUrl = url;
}
public String getPriority() {
@@ -265,4 +280,12 @@ public class BugzillaQueryCategory implements ITaskQuery {
public void setHandle(String id) {
this.handle = id;
}
+
+ public String getRepositoryUrl() {
+ return repositoryUrl;
+ }
+
+ public void setRepositoryUrl(String repositoryUrl) {
+ this.repositoryUrl = repositoryUrl;
+ }
}
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaQueryDialog.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaQueryDialog.java
index fc605466e..e966a7faf 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaQueryDialog.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaQueryDialog.java
@@ -19,9 +19,13 @@ import java.util.List;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IInputValidator;
import org.eclipse.jface.dialogs.InputDialog;
+import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.operation.IRunnableContext;
import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.mylar.bugzilla.core.BugzillaPlugin;
import org.eclipse.mylar.bugzilla.ui.search.BugzillaSearchPage;
+import org.eclipse.mylar.tasklist.MylarTaskListPlugin;
+import org.eclipse.mylar.tasklist.repositories.TaskRepository;
import org.eclipse.search.ui.ISearchPageContainer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
@@ -162,11 +166,17 @@ public class BugzillaQueryDialog extends Dialog {
}
@Override
- protected void okPressed(){
+ protected void okPressed() {
+ TaskRepository repository = MylarTaskListPlugin.getRepositoryManager().getDefaultRepository(BugzillaPlugin.REPOSITORY_KIND);
+ if (repository == null) {
+ MessageDialog.openInformation(Display.getCurrent().getActiveShell(), "Bugzilla Client Information", "No repository available, please add one.");
+ return;
+ }
+
if(customButton != null && customButton.getSelection()){
url = queryText.getText();
} else {
- url = searchOptionPage.getSearchURL();
+ url = searchOptionPage.getSearchURL(repository);
}
if(url == null || url.equals("")){
/*
@@ -425,12 +435,12 @@ public class BugzillaQueryDialog extends Dialog {
}
- public String getSearchURL() {
- try{
+ public String getSearchURL(TaskRepository repository) {
+ try {
if(rememberedQuery){
- return getQueryURL(new StringBuffer(input.getQueryParameters(selIndex)));
+ return getQueryURL(repository, new StringBuffer(input.getQueryParameters(selIndex)));
} else {
- return getQueryURL(getQueryParameters());
+ return getQueryURL(repository, getQueryParameters());
}
} catch (UnsupportedEncodingException e){
/*
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaReportNode.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaReportNode.java
index 616460a9b..e59560b3c 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaReportNode.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaReportNode.java
@@ -19,10 +19,9 @@ import java.util.List;
import javax.security.auth.login.LoginException;
import org.eclipse.mylar.bugzilla.core.BugReport;
-import org.eclipse.mylar.bugzilla.core.BugzillaRepository;
+import org.eclipse.mylar.bugzilla.core.BugzillaRepositoryUtil;
import org.eclipse.mylar.bugzilla.core.search.BugzillaSearchHit;
-
/**
* Class to store the DoiInfo of a BugzillaSearchHit
*
@@ -30,154 +29,156 @@ import org.eclipse.mylar.bugzilla.core.search.BugzillaSearchHit;
*/
public class BugzillaReportNode {
- private static final int MAX_LABEL_LENGTH = 150;
+ private static final int MAX_LABEL_LENGTH = 150;
private static final long serialVersionUID = 3257004367222419506L;
- /** The BugzillaSearchHit associated with this DoiInfo */
- private BugzillaSearchHit hit;
-
- /** Whether this search hit was from an exact search like a stack trace */
- private boolean isExact = false;
-
- /** List of all of the StackTrace's in the given bug */
- private List<StackTrace> stackTraces;
-
- /** The bug report associated with this DoiInfo */
- private BugReport bug;
-
- /**
- * Constructor
- *
- * @param initialValue
- * The initial Doi value
- * @param hit
- * The BugzillaSearchHit associated with this DoiInfo
- * @param isExact
- * Whether the search was exact or not
- */
- public BugzillaReportNode(float initialValue, BugzillaSearchHit hit,
- boolean isExact) {
- this.hit = hit;
- this.isExact = isExact;
- bug = null;
- stackTraces = new ArrayList<StackTrace>();
- }
-
- /**
- * Get the bugzilla search hit relating to this DoiInfo
- *
- * @return The BugzillaSearchHit related to this DoiInfo
- */
- public BugzillaSearchHit getHit() {
- return hit;
- }
-
- @Override
- public String toString() {
- return hit.toString();
- }
-
- /**
- * Determine if the search hit this represents is exact or not
- *
- * @return <code>true</code> if the search was exact otherwise
- * <code>false</code>
- */
- public boolean isExact() {
- return isExact;
- }
-
- /**
- * Set whether this bug has any exact elements in it - the search used was fully qualified
- *
- * @param isExact -
- * Whether there are any exact element matches in it
- */
- public void setExact(boolean isExact) {
- this.isExact = isExact;
- }
-
- /**
- * Get the bug report associated with this DoiInfo<br>
- * The bug is downloaded if it was not previously
- *
- * @return Returns the BugReport
- *
- * @throws IOException
- * @throws LoginException
- * @throws MalformedURLException
- */
- public BugReport getBug() throws MalformedURLException, LoginException, IOException {
- if(bug == null){
-
- // get the bug report
- bug = BugzillaRepository.getInstance().getBug(
- hit.getId());
- }
+ /** The BugzillaSearchHit associated with this DoiInfo */
+ private BugzillaSearchHit hit;
+
+ /** Whether this search hit was from an exact search like a stack trace */
+ private boolean isExact = false;
+
+ /** List of all of the StackTrace's in the given bug */
+ private List<StackTrace> stackTraces;
+
+ /** The bug report associated with this DoiInfo */
+ private BugReport bug;
+
+ /**
+ * Constructor
+ *
+ * @param initialValue
+ * The initial Doi value
+ * @param hit
+ * The BugzillaSearchHit associated with this DoiInfo
+ * @param isExact
+ * Whether the search was exact or not
+ */
+ public BugzillaReportNode(float initialValue, BugzillaSearchHit hit, boolean isExact) {
+ this.hit = hit;
+ this.isExact = isExact;
+ bug = null;
+ stackTraces = new ArrayList<StackTrace>();
+ }
+
+ /**
+ * Get the bugzilla search hit relating to this DoiInfo
+ *
+ * @return The BugzillaSearchHit related to this DoiInfo
+ */
+ public BugzillaSearchHit getHit() {
+ return hit;
+ }
+
+ @Override
+ public String toString() {
+ return hit.toString();
+ }
+
+ /**
+ * Determine if the search hit this represents is exact or not
+ *
+ * @return <code>true</code> if the search was exact otherwise
+ * <code>false</code>
+ */
+ public boolean isExact() {
+ return isExact;
+ }
+
+ /**
+ * Set whether this bug has any exact elements in it - the search used was
+ * fully qualified
+ *
+ * @param isExact -
+ * Whether there are any exact element matches in it
+ */
+ public void setExact(boolean isExact) {
+ this.isExact = isExact;
+ }
+
+ /**
+ * Get the bug report associated with this DoiInfo<br>
+ * The bug is downloaded if it was not previously
+ *
+ * @return Returns the BugReport
+ *
+ * @throws IOException
+ * @throws LoginException
+ * @throws MalformedURLException
+ */
+ public BugReport getBug() throws MalformedURLException, LoginException, IOException {
+ if (bug == null) {
+ // get the bug report
+ bug = BugzillaRepositoryUtil.getBug(hit.getServer(), hit.getId());
+ }
return bug;
- }
-
- /**
- * Set the bug report associated with this DoiInfo
- *
- * @param bug -
- * BugReport that this is associated with
- */
- public void setBug(BugReport bug) {
- this.bug = bug;
- }
-
- /**
- * Get all of the stack traces contained in the bug
- *
- * @return Returns a list of StackTrace's
- */
- public List<StackTrace> getStackTraces() {
- return stackTraces;
- }
-
- /**
- * Determine whether the doi info has any stack traces associated with it
- * @return <code>true</code> if there are some stack traces else <code>false</code>
- */
- public boolean hasStackTraces(){
- return !stackTraces.isEmpty();
- }
-
- /**
- * Add a stack trace to this DoiInfo
- *
- * @param stackTrace -
- * The StackTrace to add
- */
- public void addStackTrace(StackTrace stackTrace) {
- this.stackTraces.add(stackTrace);
- }
-
- /**
- * Add an array of stack traces to this DoiInfo
- *
- * @param stackTracesToAdd -
- * The StackTraces to add
- */
- public void addStackTraces(StackTrace[] stackTracesToAdd) {
- for (int i = 0; i < stackTracesToAdd.length; i++)
- this.stackTraces.add(stackTracesToAdd[i]);
- }
-
- /**
- * Get the name of the bug report
- * @return The name of the bug report, max 20 characters
- */
- public String getName() {
- String description = hit.getDescription();
- int length = description.length();
- if (length > MAX_LABEL_LENGTH) description = description.substring(0, MAX_LABEL_LENGTH) + "..";
- return "bug " + hit.getId() + ": " + description;
- }
-
- public String getElementHandle() {
- return hit.getServer() + ";" + hit.getId();
- }
+ }
+
+ /**
+ * Set the bug report associated with this DoiInfo
+ *
+ * @param bug -
+ * BugReport that this is associated with
+ */
+ public void setBug(BugReport bug) {
+ this.bug = bug;
+ }
+
+ /**
+ * Get all of the stack traces contained in the bug
+ *
+ * @return Returns a list of StackTrace's
+ */
+ public List<StackTrace> getStackTraces() {
+ return stackTraces;
+ }
+
+ /**
+ * Determine whether the doi info has any stack traces associated with it
+ *
+ * @return <code>true</code> if there are some stack traces else
+ * <code>false</code>
+ */
+ public boolean hasStackTraces() {
+ return !stackTraces.isEmpty();
+ }
+
+ /**
+ * Add a stack trace to this DoiInfo
+ *
+ * @param stackTrace -
+ * The StackTrace to add
+ */
+ public void addStackTrace(StackTrace stackTrace) {
+ this.stackTraces.add(stackTrace);
+ }
+
+ /**
+ * Add an array of stack traces to this DoiInfo
+ *
+ * @param stackTracesToAdd -
+ * The StackTraces to add
+ */
+ public void addStackTraces(StackTrace[] stackTracesToAdd) {
+ for (int i = 0; i < stackTracesToAdd.length; i++)
+ this.stackTraces.add(stackTracesToAdd[i]);
+ }
+
+ /**
+ * Get the name of the bug report
+ *
+ * @return The name of the bug report, max 20 characters
+ */
+ public String getName() {
+ String description = hit.getDescription();
+ int length = description.length();
+ if (length > MAX_LABEL_LENGTH)
+ description = description.substring(0, MAX_LABEL_LENGTH) + "..";
+ return "bug " + hit.getId() + ": " + description;
+ }
+
+ public String getElementHandle() {
+ return hit.getServer() + ";" + hit.getId();
+ }
} \ No newline at end of file
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTask.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTask.java
index f0a6fe901..0aceeb8bd 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTask.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTask.java
@@ -27,7 +27,7 @@ import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.window.ApplicationWindow;
import org.eclipse.mylar.bugzilla.core.BugReport;
import org.eclipse.mylar.bugzilla.core.BugzillaPlugin;
-import org.eclipse.mylar.bugzilla.core.BugzillaRepository;
+import org.eclipse.mylar.bugzilla.core.BugzillaRepositoryUtil;
import org.eclipse.mylar.bugzilla.core.IBugzillaBug;
import org.eclipse.mylar.bugzilla.core.internal.HtmlStreamTokenizer;
import org.eclipse.mylar.bugzilla.ui.BugzillaImages;
@@ -37,6 +37,7 @@ import org.eclipse.mylar.core.MylarPlugin;
import org.eclipse.mylar.core.util.MylarStatusHandler;
import org.eclipse.mylar.tasklist.MylarTaskListPlugin;
import org.eclipse.mylar.tasklist.internal.Task;
+import org.eclipse.mylar.tasklist.repositories.TaskRepositoryManager;
import org.eclipse.mylar.tasklist.ui.TaskListImages;
import org.eclipse.mylar.tasklist.ui.views.TaskListView;
import org.eclipse.swt.graphics.Font;
@@ -52,10 +53,8 @@ import org.eclipse.ui.internal.Workbench;
*/
public class BugzillaTask extends Task {
- public static final String BUGZILLA_HANDLE_PREFIX = "Bugzilla-";
-
private static final String PROGRESS_LABEL_DOWNLOAD = "Downloading Bugzilla Reports...";
-
+
public enum BugReportSyncState {
OUTGOING, OK, INCOMMING, CONFLICT
}
@@ -125,7 +124,7 @@ public class BugzillaTask extends Task {
super(handle, label, newTask);
isDirty = false;
scheduleDownloadReport();
- setUrl();
+ initFromHandle();
}
public BugzillaTask(String handle, String label, boolean noDownload, boolean newTask) {
@@ -134,20 +133,24 @@ public class BugzillaTask extends Task {
if (!noDownload) {
scheduleDownloadReport();
}
- setUrl();
+ initFromHandle();
}
public BugzillaTask(BugzillaHit hit, boolean newTask) {
this(hit.getHandleIdentifier(), hit.getDescription(false), newTask);
setPriority(hit.getPriority());
- setUrl();
+ initFromHandle();
}
- private void setUrl() {
- int id = BugzillaTask.getBugId(getHandleIdentifier());
- String url = BugzillaRepository.getBugUrlWithoutLogin(id);
- if (url != null)
- super.setUrl(url);
+ private void initFromHandle() {
+ int id = TaskRepositoryManager.getTaskIdAsInt(getHandleIdentifier());
+ repositoryUrl = TaskRepositoryManager.getRepositoryUrl(getHandleIdentifier());
+ if (repositoryUrl != null) {
+ String url = BugzillaRepositoryUtil.getBugUrlWithoutLogin(repositoryUrl, id);
+ if (url != null) {
+ super.setUrl(url);
+ }
+ }
}
@Override
@@ -156,9 +159,9 @@ public class BugzillaTask extends Task {
return super.getDescription(truncate);
} else {
if (getState() == BugzillaTask.BugTaskState.FREE) {
- return BugzillaTask.getBugId(getHandleIdentifier()) + ": <Could not find bug>";
+ return TaskRepositoryManager.getTaskIdAsInt(getHandleIdentifier()) + ": <Could not find bug>";
} else {
- return BugzillaTask.getBugId(getHandleIdentifier()) + ":";
+ return TaskRepositoryManager.getTaskIdAsInt(getHandleIdentifier()) + ":";
}
}
// return BugzillaTasksTools.getBugzillaDescription(this);
@@ -240,10 +243,10 @@ public class BugzillaTask extends Task {
try {
// XXX make sure to send in the server name if there are multiple repositories
if (BugzillaPlugin.getDefault() == null) {
- MylarStatusHandler.log("Bug Beport download failed for: " + getBugId(getHandleIdentifier()) + " due to bugzilla core not existing", this);
+ MylarStatusHandler.log("Bug Beport download failed for: " + TaskRepositoryManager.getTaskIdAsInt(getHandleIdentifier()) + " due to bugzilla core not existing", this);
return null;
}
- return BugzillaRepository.getInstance().getBug(getBugId(getHandleIdentifier()));
+ return BugzillaRepositoryUtil.getBug(repositoryUrl, TaskRepositoryManager.getTaskIdAsInt(getHandleIdentifier()));
} catch (LoginException e) {
Workbench.getInstance().getDisplay().asyncExec(new Runnable() {
@@ -256,7 +259,7 @@ public class BugzillaTask extends Task {
Workbench.getInstance().getDisplay().asyncExec(new Runnable() {
public void run() {
((ApplicationWindow) BugzillaPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow()).setStatus("Download of bug "
- + getBugId(getHandleIdentifier()) + " failed due to I/O exception");
+ + TaskRepositoryManager.getTaskIdAsInt(getHandleIdentifier()) + " failed due to I/O exception");
}
});
// MylarPlugin.log(e, "download failed due to I/O exception");
@@ -440,7 +443,7 @@ public class BugzillaTask extends Task {
// } else if (status.equals("REOPENED")) {
// setCompleted(false);
// }
- this.setDescription(HtmlStreamTokenizer.unescape(BugzillaTask.getBugId(getHandleIdentifier()) + ": " + bugReport.getSummary()));
+ this.setDescription(HtmlStreamTokenizer.unescape(TaskRepositoryManager.getTaskIdAsInt(getHandleIdentifier()) + ": " + bugReport.getSummary()));
} catch (NullPointerException npe) {
MylarStatusHandler.fail(npe, "Task details update failed", false);
}
@@ -463,16 +466,11 @@ public class BugzillaTask extends Task {
try {
boolean isLikeOffline = offline || syncState == BugReportSyncState.OUTGOING || syncState == BugReportSyncState.CONFLICT;
final BugzillaTaskEditorInput input = new BugzillaTaskEditorInput(bugTask, isLikeOffline);
- // state = BugTaskState.OPENING;
- // notifyTaskDataChange();
- openTaskEditor(input, offline);
- // state = BugTaskState.FREE;
- // notifyTaskDataChange();
+ openTaskEditor(input, offline);
return new Status(IStatus.OK, MylarPlugin.PLUGIN_ID, IStatus.OK, "", null);
} catch (Exception e) {
- // MessageDialog.openError(null, "Error Opening Bug", "Unable to open Bug report: " + BugzillaTask.getBugId(bugTask.getHandle()));
- MylarStatusHandler.fail(e, "Unable to open Bug report: " + BugzillaTask.getBugId(bugTask.getHandleIdentifier()), true);
+ MylarStatusHandler.fail(e, "Unable to open Bug report: " + TaskRepositoryManager.getTaskIdAsInt(bugTask.getHandleIdentifier()), true);
}
return Status.CANCEL_STATUS;
}
@@ -492,7 +490,7 @@ public class BugzillaTask extends Task {
public boolean readBugReport() {
// XXX server name needs to be with the bug report
- IBugzillaBug tempBug = OfflineView.find(getBugId(getHandleIdentifier()));
+ IBugzillaBug tempBug = OfflineView.find(TaskRepositoryManager.getTaskIdAsInt(getHandleIdentifier()));
if (tempBug == null) {
bugReport = null;
return true;
@@ -531,23 +529,6 @@ public class BugzillaTask extends Task {
}
}
- public static String getServerName(String handle) {
- int index = handle.lastIndexOf('-');
- if (index != -1) {
- return handle.substring(0, index);
- }
- return null;
- }
-
- public static int getBugId(String handle) {
- int index = handle.lastIndexOf('-');
- if (index != -1) {
- String id = handle.substring(index + 1);
- return Integer.parseInt(id);
- }
- return -1;
- }
-
@Override
public Image getIcon() {
if (syncState == BugReportSyncState.OK) {
@@ -576,7 +557,7 @@ public class BugzillaTask extends Task {
@Override
public String getUrl(){
// fix for bug 103537 - should login automatically, but dont want to show the login info in the query string
- return BugzillaRepository.getBugUrlWithoutLogin(getBugId(handle));
+ return BugzillaRepositoryUtil.getBugUrlWithoutLogin(repositoryUrl, TaskRepositoryManager.getTaskIdAsInt(handle));
}
@Override
@@ -620,7 +601,7 @@ public class BugzillaTask extends Task {
}
public String getStringForSortingDescription() {
- return getBugId(getHandleIdentifier()) + "";
+ return TaskRepositoryManager.getTaskIdAsInt(getHandleIdentifier()) + "";
}
public static long getLastRefreshTimeInMinutes(Date lastRefresh) {
@@ -641,14 +622,6 @@ public class BugzillaTask extends Task {
}
}
- public static String getHandle(IBugzillaBug bug) {
- return getHandle(bug.getId());
- }
-
- public static String getHandle(int bugId) {
- return BUGZILLA_HANDLE_PREFIX + bugId;
- }
-
public BugReportSyncState getSyncState() {
return syncState;
}
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTaskEditor.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTaskEditor.java
index 6116f38f2..c700ca0f7 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTaskEditor.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTaskEditor.java
@@ -21,6 +21,7 @@ import org.eclipse.mylar.bugzilla.core.IBugzillaAttributeListener;
import org.eclipse.mylar.bugzilla.ui.BugzillaImages;
import org.eclipse.mylar.bugzilla.ui.editor.AbstractBugEditor;
import org.eclipse.mylar.bugzilla.ui.editor.ExistingBugEditor;
+import org.eclipse.mylar.tasklist.repositories.TaskRepository;
import org.eclipse.mylar.tasklist.ui.MylarTaskEditor;
import org.eclipse.mylar.tasklist.ui.TaskEditorInput;
import org.eclipse.mylar.tasklist.ui.TaskListImages;
@@ -64,7 +65,7 @@ public class BugzillaTaskEditor extends MylarTaskEditor {
}
};
- public BugzillaTaskEditor() {
+ public BugzillaTaskEditor(TaskRepository repository) {
super();
// get the workbench page and add a listener so we can detect when it closes
@@ -74,7 +75,7 @@ public class BugzillaTaskEditor extends MylarTaskEditor {
// BugzillaTaskEditorListener listener = new BugzillaTaskEditorListener();
// ap.addPartListener(listener);
- bugzillaEditor = new ExistingBugEditor();
+ bugzillaEditor = new ExistingBugEditor(repository);
bugzillaEditor.setParentEditor(this);
bugzillaEditor.addAttributeListener(ATTRIBUTE_LISTENER);
// taskSummaryEditor = new TaskInfoEditor();
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTaskEditorInput.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTaskEditorInput.java
index 017af6650..8f11adc52 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTaskEditorInput.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTaskEditorInput.java
@@ -21,6 +21,7 @@ import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.mylar.bugzilla.core.BugReport;
import org.eclipse.mylar.bugzilla.ui.editor.ExistingBugEditorInput;
import org.eclipse.mylar.bugzilla.ui.tasklist.BugzillaTask.BugReportSyncState;
+import org.eclipse.mylar.tasklist.repositories.TaskRepositoryManager;
import org.eclipse.ui.IPersistableElement;
@@ -38,10 +39,10 @@ public class BugzillaTaskEditorInput extends ExistingBugEditorInput {
private boolean offline;
public BugzillaTaskEditorInput(BugzillaTask bugTask, boolean offline) throws LoginException, IOException {
- super(BugzillaTask.getBugId(bugTask.getHandleIdentifier()), offline);
+ super(bugTask.getRepositoryUrl(), TaskRepositoryManager.getTaskIdAsInt(bugTask.getHandleIdentifier()), offline);
this.bugTask = bugTask;
offlineBug = bugTask.getBugReport();
- bugId = BugzillaTask.getBugId(bugTask.getHandleIdentifier());
+ bugId = TaskRepositoryManager.getTaskIdAsInt(bugTask.getHandleIdentifier());
bugTitle = "";
this.offline = offline;
}
@@ -89,7 +90,7 @@ public class BugzillaTaskEditorInput extends ExistingBugEditorInput {
/**
* Returns the online server bug for this input
*
- * @see BugzillaRepository
+ * @see BugzillaRepositoryUtil
* @see BugReport
*/
// public BugReport getServerBug() {
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTaskExternalizer.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTaskExternalizer.java
index 67f4b9bd2..d91aecb9b 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTaskExternalizer.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTaskExternalizer.java
@@ -17,15 +17,16 @@ import org.eclipse.mylar.bugzilla.ui.BugzillaUiPlugin;
import org.eclipse.mylar.bugzilla.ui.tasklist.BugzillaTask.BugReportSyncState;
import org.eclipse.mylar.bugzilla.ui.tasklist.BugzillaTask.BugTaskState;
import org.eclipse.mylar.core.util.MylarStatusHandler;
-import org.eclipse.mylar.tasklist.ITaskCategory;
-import org.eclipse.mylar.tasklist.ITaskQuery;
import org.eclipse.mylar.tasklist.ITask;
+import org.eclipse.mylar.tasklist.ITaskCategory;
import org.eclipse.mylar.tasklist.ITaskHandler;
+import org.eclipse.mylar.tasklist.ITaskQuery;
import org.eclipse.mylar.tasklist.MylarTaskListPlugin;
import org.eclipse.mylar.tasklist.internal.DelegatingLocalTaskExternalizer;
-import org.eclipse.mylar.tasklist.internal.TaskListExternalizerException;
import org.eclipse.mylar.tasklist.internal.TaskCategory;
import org.eclipse.mylar.tasklist.internal.TaskList;
+import org.eclipse.mylar.tasklist.internal.TaskListExternalizerException;
+import org.eclipse.mylar.tasklist.repositories.TaskRepositoryManager;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -55,7 +56,7 @@ public class BugzillaTaskExternalizer extends DelegatingLocalTaskExternalizer {
private static final String SYNC_STATE = "offlineSyncState";
private static final String DESCRIPTION = "Description";
-
+
private static final String URL = "URL";
private static final String BUGZILLA_TASK_REGISTRY = "BugzillaTaskRegistry" + TAG_CATEGORY;
@@ -92,11 +93,11 @@ public class BugzillaTaskExternalizer extends DelegatingLocalTaskExternalizer {
@Override
public void readCategory(Node node, TaskList taskList) throws TaskListExternalizerException {
- Element e = (Element) node;
- if (e.getNodeName().equals(BUGZILLA_TASK_REGISTRY)) {
+ Element element = (Element) node;
+ if (element.getNodeName().equals(BUGZILLA_TASK_REGISTRY)) {
readRegistry(node, taskList);
} else {
- BugzillaQueryCategory cat = new BugzillaQueryCategory(e.getAttribute(DESCRIPTION), e.getAttribute(URL), e
+ BugzillaQueryCategory cat = new BugzillaQueryCategory(element.getAttribute(REPOSITORY_URL), element.getAttribute(URL), element.getAttribute(DESCRIPTION), element
.getAttribute(MAX_HITS));
taskList.internalAddQuery(cat);
}
@@ -120,10 +121,10 @@ public class BugzillaTaskExternalizer extends DelegatingLocalTaskExternalizer {
Element element = (Element) node;
ITaskQuery cat = null;
if (node.getNodeName().equals(TAG_BUGZILLA_CUSTOM_QUERY)) {
- cat = new BugzillaCustomQueryCategory(element.getAttribute(NAME), element.getAttribute(QUERY_STRING), element
+ cat = new BugzillaCustomQueryCategory(element.getAttribute(REPOSITORY_URL), element.getAttribute(NAME), element.getAttribute(QUERY_STRING), element
.getAttribute(MAX_HITS));
} else if (node.getNodeName().equals(TAG_BUGZILLA_QUERY)) {
- cat = new BugzillaQueryCategory(element.getAttribute(NAME), element.getAttribute(QUERY_STRING), element
+ cat = new BugzillaQueryCategory(element.getAttribute(REPOSITORY_URL), element.getAttribute(QUERY_STRING), element.getAttribute(NAME), element
.getAttribute(MAX_HITS));
}
if (cat != null) {
@@ -290,7 +291,7 @@ public class BugzillaTaskExternalizer extends DelegatingLocalTaskExternalizer {
} else {
throw new TaskListExternalizerException("Description not stored for bug report");
}
- BugzillaHit hit = new BugzillaHit(label, priority, BugzillaTask.getBugId(handle), null, status);
+ BugzillaHit hit = new BugzillaHit(label, priority, query.getRepositoryUrl(), TaskRepositoryManager.getTaskIdAsInt(handle), null, status);
query.addHit(hit);
}
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTaskHandler.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTaskHandler.java
index a47d24419..1e3b02bef 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTaskHandler.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTaskHandler.java
@@ -29,6 +29,7 @@ import org.eclipse.mylar.tasklist.ITask;
import org.eclipse.mylar.tasklist.ITaskHandler;
import org.eclipse.mylar.tasklist.MylarTaskListPlugin;
import org.eclipse.mylar.tasklist.MylarTaskListPrefConstants;
+import org.eclipse.mylar.tasklist.repositories.TaskRepositoryManager;
import org.eclipse.mylar.tasklist.ui.ITaskListElement;
import org.eclipse.mylar.tasklist.ui.actions.CopyDescriptionAction;
import org.eclipse.mylar.tasklist.ui.actions.DeleteAction;
@@ -106,7 +107,7 @@ public class BugzillaTaskHandler implements ITaskHandler {
"Unable to open the selected bugzilla task since you are currently offline");
return;
}
- String title = "Bug #" + BugzillaTask.getBugId(t.getHandleIdentifier());
+ String title = "Bug #" + TaskRepositoryManager.getTaskIdAsInt(t.getHandleIdentifier());
BugzillaUITools.openUrl(title, title, t.getUrl());
} else {
// not supported
@@ -156,7 +157,7 @@ public class BugzillaTaskHandler implements ITaskHandler {
"Unable to open the selected bugzilla report since you are currently offline");
return;
}
- BugzillaOpenStructure open = new BugzillaOpenStructure(((BugzillaHit) element).getServerName(),
+ BugzillaOpenStructure open = new BugzillaOpenStructure(((BugzillaHit) element).getRepositoryUrl(),
((BugzillaHit) element).getId(), -1);
List<BugzillaOpenStructure> selectedBugs = new ArrayList<BugzillaOpenStructure>();
selectedBugs.add(open);
@@ -169,7 +170,7 @@ public class BugzillaTaskHandler implements ITaskHandler {
"Unable to open the selected bugzilla report since you are currently offline");
return;
}
- String title = "Bug #" + BugzillaTask.getBugId(hit.getHandleIdentifier());
+ String title = "Bug #" + TaskRepositoryManager.getTaskIdAsInt(hit.getHandleIdentifier());
BugzillaUITools.openUrl(title, title, hit.getBugUrl());
} else {
// not supported
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTaskListManager.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTaskListManager.java
index 59d289e39..20c3dec69 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTaskListManager.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTaskListManager.java
@@ -20,6 +20,7 @@ import org.eclipse.mylar.bugzilla.ui.tasklist.BugzillaTask.BugReportSyncState;
import org.eclipse.mylar.tasklist.ITask;
import org.eclipse.mylar.tasklist.MylarTaskListPlugin;
import org.eclipse.mylar.tasklist.internal.TaskCategory;
+import org.eclipse.mylar.tasklist.repositories.TaskRepositoryManager;
import org.eclipse.mylar.tasklist.ui.views.TaskListView;
/**
@@ -70,7 +71,7 @@ public class BugzillaTaskListManager implements IOfflineBugListener {
return;
}
- String handle = BugzillaTask.getHandle(bug);
+ String handle = TaskRepositoryManager.getHandle(bug.getServer(), bug.getId());
ITask task = MylarTaskListPlugin.getTaskListManager().getTaskForHandle(handle, true);
if(task != null && task instanceof BugzillaTask){
BugzillaTask bugTask = (BugzillaTask) task;
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTasksTools.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTasksTools.java
index aff27cb8c..1c9f93528 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTasksTools.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTasksTools.java
@@ -15,7 +15,7 @@ package org.eclipse.mylar.bugzilla.ui.tasklist;
import org.eclipse.mylar.bugzilla.core.BugReport;
import org.eclipse.mylar.bugzilla.core.internal.HtmlStreamTokenizer;
-
+import org.eclipse.mylar.tasklist.repositories.TaskRepositoryManager;
/**
* @author Mik Kersten
@@ -29,8 +29,7 @@ public class BugzillaTasksTools {
public static String getBugzillaDescription(BugzillaTask bugTask) {
if (bugTask == null) return "<no info>";
- String prefix = //((bugTask.isDirty()) ? ">" : "") +
- BugzillaTask.getBugId(bugTask.getHandleIdentifier()) + ": ";
+ String prefix = TaskRepositoryManager.getTaskIdAsInt(bugTask.getHandleIdentifier()) + ": ";
if (bugTask.getState() == BugzillaTask.BugTaskState.DOWNLOADING) {
return prefix + "<Downloading bug report from server...>";
@@ -51,5 +50,4 @@ public class BugzillaTasksTools {
return prefix + "<Could not find bug>";
}
}
-
}
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/wizard/AbstractBugWizard.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/wizard/AbstractBugWizard.java
index fba31752e..78a0f3ac8 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/wizard/AbstractBugWizard.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/wizard/AbstractBugWizard.java
@@ -25,7 +25,6 @@ import org.eclipse.mylar.bugzilla.core.Attribute;
import org.eclipse.mylar.bugzilla.core.BugReportPostHandler;
import org.eclipse.mylar.bugzilla.core.BugzillaException;
import org.eclipse.mylar.bugzilla.core.BugzillaPlugin;
-import org.eclipse.mylar.bugzilla.core.BugzillaPreferencePage;
import org.eclipse.mylar.bugzilla.core.IBugzillaConstants;
import org.eclipse.mylar.bugzilla.core.NewBugModel;
import org.eclipse.mylar.bugzilla.core.PossibleBugzillaFailureException;
@@ -34,6 +33,7 @@ import org.eclipse.mylar.bugzilla.ui.WebBrowserDialog;
import org.eclipse.mylar.bugzilla.ui.editor.AbstractBugEditor;
import org.eclipse.mylar.bugzilla.ui.editor.ExistingBugEditorInput;
import org.eclipse.mylar.core.util.MylarStatusHandler;
+import org.eclipse.mylar.tasklist.repositories.TaskRepository;
import org.eclipse.search.internal.ui.SearchMessages;
import org.eclipse.search.internal.ui.util.ExceptionHandler;
import org.eclipse.swt.widgets.Display;
@@ -54,6 +54,11 @@ import org.eclipse.ui.progress.IProgressService;
*/
public abstract class AbstractBugWizard extends Wizard implements INewWizard {
+ protected TaskRepository repository;
+
+ /** The ID of the posted bug report. */
+ private String id;
+
protected boolean fromDialog = false;
/** The model used to store all of the data for the wizard */
@@ -68,14 +73,9 @@ public abstract class AbstractBugWizard extends Wizard implements INewWizard {
/** The workbench instance */
protected IWorkbench workbenchInstance;
- /** The ID of the posted bug report. */
- private String id;
-
- /**
- * Constructor for AbstractBugWizard
- */
- public AbstractBugWizard() {
+ public AbstractBugWizard(TaskRepository repository) {
super();
+ this.repository = repository;
model = new NewBugModel();
id = null; // Since there is no bug posted yet.
super.setDefaultPageImageDescriptor(BugzillaUiPlugin.imageDescriptorFromPlugin("org.eclipse.mylar.bugzilla.ui", "icons/wizban/bug-wizard.gif"));
@@ -96,7 +96,7 @@ public abstract class AbstractBugWizard extends Wizard implements INewWizard {
public void addPages() {
try {
// check Bugzilla preferences to see if user has supplied a username
- if (BugzillaPreferencePage.getUserName().equals(""))
+ if (repository.getUserName().equals(""))
throw new LoginException(
"A Bugzilla User Name has not been provided."
+ " Please check your Bugzilla Preferences information.");
@@ -314,7 +314,7 @@ public abstract class AbstractBugWizard extends Wizard implements INewWizard {
IEditorInput input = null;
try {
- input = new ExistingBugEditorInput(Integer.parseInt(id));
+ input = new ExistingBugEditorInput(repository.getServerUrl().toExternalForm(), Integer.parseInt(id));
BugzillaPlugin.getDefault().getWorkbench()
.getActiveWorkbenchWindow().getActivePage().openEditor(
input, IBugzillaConstants.EXISTING_BUG_EDITOR_ID, false);
@@ -350,14 +350,14 @@ public abstract class AbstractBugWizard extends Wizard implements INewWizard {
protected void setURL(BugReportPostHandler form, String formName)
throws MalformedURLException {
- String baseURL = BugzillaPlugin.getDefault().getServerName();
+// String baseURL = BugzillaPlugin.getDefault().getServerName();
+ String baseURL = repository.getServerUrl().toExternalForm();
if (!baseURL.endsWith("/"))
baseURL += "/";
form.setURL(baseURL + formName);
- // add the login information to the bug post
- form.add("Bugzilla_login", BugzillaPreferencePage.getUserName());
- form.add("Bugzilla_password", BugzillaPreferencePage.getPassword());
+ form.add("Bugzilla_login", repository.getUserName());
+ form.add("Bugzilla_password", repository.getPassword());
}
/**
@@ -403,4 +403,8 @@ public abstract class AbstractBugWizard extends Wizard implements INewWizard {
* @return the last page of this wizard
*/
abstract protected AbstractWizardDataPage getWizardDataPage();
+
+ public TaskRepository getRepository() {
+ return repository;
+ }
}
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/wizard/NewBugWizard.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/wizard/NewBugWizard.java
index f075bdd4b..1e1e48438 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/wizard/NewBugWizard.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/wizard/NewBugWizard.java
@@ -19,8 +19,9 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.mylar.bugzilla.core.BugzillaPlugin;
-import org.eclipse.mylar.bugzilla.core.BugzillaRepository;
+import org.eclipse.mylar.bugzilla.core.BugzillaRepositoryUtil;
import org.eclipse.mylar.bugzilla.ui.OfflineView;
+import org.eclipse.mylar.tasklist.repositories.TaskRepository;
/**
@@ -37,12 +38,12 @@ public class NewBugWizard extends AbstractBugWizard {
/** The wizard page where the attributes are selected and the bug is submitted */
WizardAttributesPage attributePage;
- public NewBugWizard(){
- this(false);
+ public NewBugWizard(TaskRepository repository) {
+ this(repository, false);
}
- public NewBugWizard(boolean fromDialog){
- super();
+ public NewBugWizard(TaskRepository repository, boolean fromDialog){
+ super(repository);
this.fromDialog = fromDialog;
}
@@ -53,7 +54,7 @@ public class NewBugWizard extends AbstractBugWizard {
// try to get the list of products from the server
if (!model.hasParsedProducts()) {
try {
- WizardProductPage.products = BugzillaRepository.getInstance().getProductList();
+ WizardProductPage.products = BugzillaRepositoryUtil.getProductList(repository.getServerUrl().toExternalForm());
model.setConnected(true);
model.setParsedProductsStatus(true);
} catch (Exception e) {
@@ -79,7 +80,7 @@ public class NewBugWizard extends AbstractBugWizard {
// use ProductConfiguration to get products instead
String[] products = BugzillaPlugin.getDefault()
- .getProductConfiguration().getProducts();
+ .getProductConfiguration(repository.getServerUrl().toExternalForm()).getProducts();
// add products from ProductConfiguration to product page's
// product list
@@ -104,9 +105,9 @@ public class NewBugWizard extends AbstractBugWizard {
// // There wasn't a list of products so there must only be 1
// if (!model.hasParsedAttributes()) {
// if (model.isConnected()) {
-// BugzillaRepository.getInstance().getnewBugAttributes(model, true);
+// BugzillaRepositoryUtil.getInstance().getnewBugAttributes(model, true);
// } else {
-// BugzillaRepository.getInstance().getProdConfigAttributes(model);
+// BugzillaRepositoryUtil.getInstance().getProdConfigAttributes(model);
// }
// model.setParsedAttributesStatus(true);
// }
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/wizard/WizardProductPage.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/wizard/WizardProductPage.java
index db35945b8..2b73214be 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/wizard/WizardProductPage.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/wizard/WizardProductPage.java
@@ -22,8 +22,7 @@ import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.mylar.bugzilla.core.BugzillaPlugin;
-import org.eclipse.mylar.bugzilla.core.BugzillaPreferencePage;
-import org.eclipse.mylar.bugzilla.core.BugzillaRepository;
+import org.eclipse.mylar.bugzilla.core.BugzillaRepositoryUtil;
import org.eclipse.mylar.bugzilla.core.IBugzillaConstants;
import org.eclipse.mylar.bugzilla.core.NewBugModel;
import org.eclipse.swt.SWT;
@@ -56,7 +55,7 @@ public class WizardProductPage extends AbstractWizardListPage {
/** String to hold previous product; determines if attribute option values need to be updated */
private String prevProduct;
-
+
/**
* Constructor for WizardProductPage
*
@@ -91,10 +90,10 @@ public class WizardProductPage extends AbstractWizardListPage {
monitor.beginTask("Updating search options...", 55);
try {
- BugzillaPreferencePage.updateQueryOptions(monitor);
+ BugzillaRepositoryUtil.updateQueryOptions(bugWizard.getRepository(), monitor);
products = new ArrayList<String>();
- for(String product : BugzillaPreferencePage.queryOptionsToArray(prefs.getString(IBugzillaConstants.PRODUCT_VALUES))){
+ for(String product : BugzillaRepositoryUtil.queryOptionsToArray(prefs.getString(IBugzillaConstants.VALUES_PRODUCT))){
products.add(product);
}
monitor.worked(1);
@@ -141,11 +140,12 @@ public class WizardProductPage extends AbstractWizardListPage {
// try to get the attributes from the bugzilla server
try {
if (!model.hasParsedAttributes() || !prevProduct.equals(model.getProduct())) {
+ String serverUrl = bugWizard.getRepository().getServerUrl().toExternalForm();
if (model.isConnected()) {
- BugzillaRepository.getInstance().getnewBugAttributes(model, false);
+ BugzillaRepositoryUtil.getnewBugAttributes(serverUrl, model, false);
}
else {
- BugzillaRepository.getInstance().getProdConfigAttributes(model);
+ BugzillaRepositoryUtil.getProdConfigAttributes(serverUrl, model);
}
model.setParsedAttributesStatus(true);
if (prevProduct == null) {
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/bugs/BugzillaStructureBridge.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/bugs/BugzillaStructureBridge.java
index a747db9f0..f3281ed33 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/bugs/BugzillaStructureBridge.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/bugs/BugzillaStructureBridge.java
@@ -20,7 +20,8 @@ import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.mylar.bugzilla.core.BugReport;
-import org.eclipse.mylar.bugzilla.core.BugzillaRepository;
+import org.eclipse.mylar.bugzilla.core.BugzillaPlugin;
+import org.eclipse.mylar.bugzilla.core.BugzillaRepositoryUtil;
import org.eclipse.mylar.bugzilla.core.BugzillaTools;
import org.eclipse.mylar.bugzilla.core.search.BugzillaSearchHit;
import org.eclipse.mylar.bugzilla.ui.editor.AbstractBugEditor;
@@ -31,6 +32,8 @@ import org.eclipse.mylar.core.AbstractRelationProvider;
import org.eclipse.mylar.core.IDegreeOfSeparation;
import org.eclipse.mylar.core.IMylarStructureBridge;
import org.eclipse.mylar.core.internal.DegreeOfSeparation;
+import org.eclipse.mylar.tasklist.MylarTaskListPlugin;
+import org.eclipse.mylar.tasklist.repositories.TaskRepository;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.progress.IProgressService;
@@ -80,6 +83,9 @@ public class BugzillaStructureBridge implements IMylarStructureBridge {
public Object getObjectForHandle(final String handle) {
result = null;
+ // HACK: determine appropriate repository
+ final TaskRepository repository = MylarTaskListPlugin.getRepositoryManager().getDefaultRepository(BugzillaPlugin.REPOSITORY_KIND);
+
String[] parts = handle.split(";");
if (parts.length >= 2) {
String server = parts[0];
@@ -117,7 +123,7 @@ public class BugzillaStructureBridge implements IMylarStructureBridge {
public void run(IProgressMonitor monitor) {
monitor.beginTask("Downloading Bug# " + id, IProgressMonitor.UNKNOWN);
try {
- result = BugzillaRepository.getInstance().getCurrentBug(id);
+ result = BugzillaRepositoryUtil.getCurrentBug(repository.getServerUrl().toExternalForm(), id);
if (result != null) {
MylarBugsPlugin.getDefault().getCache().cache(bugHandle, result);
}
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/bugs/BugzillaUiBridge.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/bugs/BugzillaUiBridge.java
index 3999b0a59..ca1b46575 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/bugs/BugzillaUiBridge.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/bugs/BugzillaUiBridge.java
@@ -45,7 +45,7 @@ public class BugzillaUiBridge implements IMylarUiBridge {
public void open(IMylarElement node) {
String handle = node.getHandleIdentifier();
String bugHandle = handle;
- String server =handle.substring(0, handle.indexOf(";"));
+ String server = handle.substring(0, handle.indexOf(";"));
handle = handle.substring(handle.indexOf(";") + 1);
int next = handle.indexOf(";");
@@ -60,8 +60,9 @@ public class BugzillaUiBridge implements IMylarUiBridge {
commentNumer = Integer.parseInt(handle.substring(handle.indexOf(";") + 1));
bugHandle = bugHandle.substring(0, next);
}
-
- ITask task = MylarTaskListPlugin.getTaskListManager().getTaskForHandle(BugzillaTask.getHandle(bugId), true);
+
+ ITask task = MylarTaskListPlugin.getTaskListManager().getTaskForHandle(handle, true);
+// ITask task = MylarTaskListPlugin.getTaskListManager().getTaskForHandle(BugTaskUtil.getHandle(bugId), true);
if (task != null && task instanceof BugzillaTask) {
BugzillaTask bugzillaTask = (BugzillaTask)task;
bugzillaTask.openTask(commentNumer, true);
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/bugs/java/BugzillaHyperLink.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/bugs/java/BugzillaHyperLink.java
index 2854d08d9..ec8e2adbf 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/bugs/java/BugzillaHyperLink.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/bugs/java/BugzillaHyperLink.java
@@ -12,10 +12,16 @@ package org.eclipse.mylar.bugs.java;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.hyperlink.IHyperlink;
+import org.eclipse.mylar.bugzilla.core.BugzillaPlugin;
import org.eclipse.mylar.core.util.MylarStatusHandler;
+import org.eclipse.mylar.tasklist.MylarTaskListPlugin;
+import org.eclipse.mylar.tasklist.repositories.TaskRepository;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.progress.IProgressService;
+/**
+ * @author Mik Kersten
+ */
public class BugzillaHyperLink implements IHyperlink {
private IRegion region;
@@ -40,7 +46,8 @@ public class BugzillaHyperLink implements IHyperlink {
}
public void open() {
- OpenBugzillaReportJob job = new OpenBugzillaReportJob(id);
+ TaskRepository repository = MylarTaskListPlugin.getRepositoryManager().getDefaultRepository(BugzillaPlugin.REPOSITORY_KIND);
+ OpenBugzillaReportJob job = new OpenBugzillaReportJob(repository.getServerUrl().toExternalForm(), id);
IProgressService service = PlatformUI.getWorkbench().getProgressService();
try {
service.run(true, false, job);
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/bugs/java/OpenBugzillaReportJob.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/bugs/java/OpenBugzillaReportJob.java
index 76b9e537a..d3c7b65b6 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/bugs/java/OpenBugzillaReportJob.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/bugs/java/OpenBugzillaReportJob.java
@@ -16,7 +16,6 @@ import java.util.List;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.mylar.bugzilla.core.BugzillaPlugin;
import org.eclipse.mylar.bugzilla.ui.BugzillaOpenStructure;
import org.eclipse.mylar.bugzilla.ui.ViewBugzillaAction;
import org.eclipse.mylar.core.util.MylarStatusHandler;
@@ -28,15 +27,18 @@ public class OpenBugzillaReportJob implements IRunnableWithProgress {
private int id;
- public OpenBugzillaReportJob(int id) {
+ private String serverUrl;
+
+ public OpenBugzillaReportJob(String serverUrl, int id) {
this.id = id;
+ this.serverUrl = serverUrl;
}
public void run(IProgressMonitor monitor) {
try {
monitor.beginTask("Opening Bugzilla Report", 10);
List<BugzillaOpenStructure> list = new ArrayList<BugzillaOpenStructure>(1);
- list.add(new BugzillaOpenStructure(BugzillaPlugin.getDefault().getServerName(), id, -1));
+ list.add(new BugzillaOpenStructure(serverUrl, id, -1));
new ViewBugzillaAction("Open Bug " + id, list).run(monitor);
monitor.done();
} catch (Exception e) {
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/bugs/search/BugzillaMylarSearch.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/bugs/search/BugzillaMylarSearch.java
index 117e26005..ff7e2bdad 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/bugs/search/BugzillaMylarSearch.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/bugs/search/BugzillaMylarSearch.java
@@ -49,13 +49,16 @@ public class BugzillaMylarSearch implements IMylarSearchOperation {
private String handle = "";
+ private String serverUrl = "";
+
/**
* Constructor
* @param scope The scope of this search
*/
- public BugzillaMylarSearch(int scope, IJavaElement element) {
+ public BugzillaMylarSearch(int scope, IJavaElement element, String serverUrl) {
this.scope = scope;
this.element = element;
+ this.serverUrl = serverUrl;
}
public IStatus run(IProgressMonitor monitor){
@@ -175,5 +178,9 @@ public class BugzillaMylarSearch implements IMylarSearchOperation {
return memberLandmarks;
}
+
+ public String getServerUrl() {
+ return serverUrl;
+ }
} \ No newline at end of file
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/bugs/search/BugzillaMylarSearchOperation.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/bugs/search/BugzillaMylarSearchOperation.java
index 019c01596..815f08750 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/bugs/search/BugzillaMylarSearchOperation.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/bugs/search/BugzillaMylarSearchOperation.java
@@ -29,6 +29,7 @@ import org.eclipse.jdt.core.IType;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.mylar.bugs.MylarBugsPlugin;
import org.eclipse.mylar.bugzilla.core.BugReport;
+import org.eclipse.mylar.bugzilla.core.BugzillaPlugin;
import org.eclipse.mylar.bugzilla.core.Comment;
import org.eclipse.mylar.bugzilla.core.search.BugzillaSearchEngine;
import org.eclipse.mylar.bugzilla.core.search.BugzillaSearchHit;
@@ -42,6 +43,7 @@ import org.eclipse.mylar.core.util.MylarStatusHandler;
import org.eclipse.mylar.tasklist.ITask;
import org.eclipse.mylar.tasklist.MylarTaskListPlugin;
import org.eclipse.mylar.tasklist.internal.TaskCategory;
+import org.eclipse.mylar.tasklist.repositories.TaskRepository;
import org.eclipse.ui.actions.WorkspaceModifyOperation;
/**
@@ -50,145 +52,142 @@ import org.eclipse.ui.actions.WorkspaceModifyOperation;
* @author Shawn Minto
* @author Mik Kersten
*/
-public class BugzillaMylarSearchOperation extends WorkspaceModifyOperation
- implements IBugzillaSearchOperation {
+public class BugzillaMylarSearchOperation extends WorkspaceModifyOperation implements IBugzillaSearchOperation {
/** The IMember we are doing the search for */
- private IMember javaElement;
-
- /** The bugzilla collector for the search */
- private BugzillaResultCollector collector = null;
-
- /** The status of the search operation */
- private IStatus status;
-
- /** The LoginException that was thrown when trying to do the search */
- private LoginException loginException = null;
-
- /** The fully qualified name of the member we are searching for */
- private String name;
-
- /** The bugzilla search query */
- private BugzillaSearchQuery query;
-
- private BugzillaMylarSearch search;
-
- private int scope;
-
- /**
- * Constructor
- *
- * @param m
- * The member that we are doing the search for
- */
- public BugzillaMylarSearchOperation(BugzillaMylarSearch search, IMember m, int scope) {
- this.javaElement = m;
- this.search = search;
- this.scope = scope;
- name = getFullyQualifiedName(m);
- }
-
- /**
- * Get the fully qualified name of a IMember
- * TODO: move to a more central location so that others can use this, but don't want to add unecessary coupling
- *
- * @return String representing the fully qualified name
- */
- public static String getFullyQualifiedName(IJavaElement je) {
- if(!(je instanceof IMember)) return null;
-
- IMember m = (IMember)je;
- if (m.getDeclaringType() == null)
- return ((IType) m).getFullyQualifiedName();
- else
- return m.getDeclaringType().getFullyQualifiedName() + "."
- + m.getElementName();
- }
-
- @Override
- public void execute(IProgressMonitor monitor) {
-
- BugzillaResultCollector searchCollector = null;
-
- if(scope == BugzillaMylarSearch.FULLY_QUAL){
- searchCollector = searchQualified(monitor);
- }else if(scope == BugzillaMylarSearch.UNQUAL){
- searchCollector = searchUnqualified(monitor);
- }else if(scope == BugzillaMylarSearch.LOCAL_QUAL){
- searchCollector = searchLocalQual(monitor);
- }else if(scope == BugzillaMylarSearch.LOCAL_UNQUAL){
- searchCollector = searchLocalUnQual(monitor);
- } else {
- status = Status.OK_STATUS;
- return;
- }
-
- if(searchCollector == null){
- search.notifySearchCompleted(
- new ArrayList<BugzillaReportNode>());
- return;
- }
-
- List<BugzillaSearchHit> l = searchCollector.getResults();
-
- // get the list of doi elements
- List<BugzillaReportNode> doiList = getDoiList(l);
-
- // we completed the search, so notify all of the listeners
- // that the search has been completed
- MylarBugsPlugin.getBridge().addToLandmarksHash(doiList, javaElement, scope);
- search.notifySearchCompleted(
- doiList);
- // MIK: commmented out logging
-// MonitorPlugin.log(this, "There were " + doiList.size() + " items found");
- }
-
- /**
- * Search the local bugs for the member using the qualified name
- * @param monitor The progress monitor to search with
- * @return The BugzillaResultCollector with the results of the search
- */
- private BugzillaResultCollector searchLocalQual(IProgressMonitor monitor) {
-
- //get the fully qualified name for searching
- String elementName = getFullyQualifiedName(javaElement);
-
- // setup the search result collector
- collector = new BugzillaResultCollector();
- collector.setOperation(this);
- collector.setProgressMonitor(monitor);
-
- // get all of the root tasks and start the search
- List<ITask> tasks = MylarTaskListPlugin.getTaskListManager().getTaskList().getRootTasks();
- searchLocal(tasks, collector, elementName, monitor);
+ private IMember javaElement;
+
+ /** The bugzilla collector for the search */
+ private BugzillaResultCollector collector = null;
+
+ /** The status of the search operation */
+ private IStatus status;
+
+ /** The LoginException that was thrown when trying to do the search */
+ private LoginException loginException = null;
+
+ /** The fully qualified name of the member we are searching for */
+ private String name;
+
+ /** The bugzilla search query */
+ private BugzillaSearchQuery query;
+
+ private BugzillaMylarSearch search;
+
+ private int scope;
+
+ public BugzillaMylarSearchOperation(BugzillaMylarSearch search, IMember m, int scope) {
+ this.javaElement = m;
+ this.search = search;
+ this.scope = scope;
+ name = getFullyQualifiedName(m);
+ }
+
+ /**
+ * Get the fully qualified name of a IMember TODO: move to a more central
+ * location so that others can use this, but don't want to add unecessary
+ * coupling
+ *
+ * @return String representing the fully qualified name
+ */
+ public static String getFullyQualifiedName(IJavaElement je) {
+ if (!(je instanceof IMember))
+ return null;
+
+ IMember m = (IMember) je;
+ if (m.getDeclaringType() == null)
+ return ((IType) m).getFullyQualifiedName();
+ else
+ return m.getDeclaringType().getFullyQualifiedName() + "." + m.getElementName();
+ }
+
+ @Override
+ public void execute(IProgressMonitor monitor) {
+
+ BugzillaResultCollector searchCollector = null;
+
+ if (scope == BugzillaMylarSearch.FULLY_QUAL) {
+ searchCollector = searchQualified(search.getServerUrl(), monitor);
+ } else if (scope == BugzillaMylarSearch.UNQUAL) {
+ searchCollector = searchUnqualified(search.getServerUrl(), monitor);
+ } else if (scope == BugzillaMylarSearch.LOCAL_QUAL) {
+ searchCollector = searchLocalQual(monitor);
+ } else if (scope == BugzillaMylarSearch.LOCAL_UNQUAL) {
+ searchCollector = searchLocalUnQual(monitor);
+ } else {
+ status = Status.OK_STATUS;
+ return;
+ }
+
+ if (searchCollector == null) {
+ search.notifySearchCompleted(new ArrayList<BugzillaReportNode>());
+ return;
+ }
+
+ List<BugzillaSearchHit> l = searchCollector.getResults();
+
+ // get the list of doi elements
+ List<BugzillaReportNode> doiList = getDoiList(l);
+
+ // we completed the search, so notify all of the listeners
+ // that the search has been completed
+ MylarBugsPlugin.getBridge().addToLandmarksHash(doiList, javaElement, scope);
+ search.notifySearchCompleted(doiList);
+ // MIK: commmented out logging
+ // MonitorPlugin.log(this, "There were " + doiList.size() + " items
+ // found");
+ }
+
+ /**
+ * Search the local bugs for the member using the qualified name
+ *
+ * @param monitor
+ * The progress monitor to search with
+ * @return The BugzillaResultCollector with the results of the search
+ */
+ private BugzillaResultCollector searchLocalQual(IProgressMonitor monitor) {
+
+ // get the fully qualified name for searching
+ String elementName = getFullyQualifiedName(javaElement);
+
+ // setup the search result collector
+ collector = new BugzillaResultCollector();
+ collector.setOperation(this);
+ collector.setProgressMonitor(monitor);
+
+ // get all of the root tasks and start the search
+ List<ITask> tasks = MylarTaskListPlugin.getTaskListManager().getTaskList().getRootTasks();
+ searchLocal(tasks, collector, elementName, monitor);
for (TaskCategory cat : MylarTaskListPlugin.getTaskListManager().getTaskList().getTaskCategories()) {
- searchLocal(cat.getChildren(), collector, elementName, monitor);
+ searchLocal(cat.getChildren(), collector, elementName, monitor);
}
-
- // return the collector
- return collector;
- }
-
- /**
- * Search the local bugs for the member using the unqualified name
- * @param monitor The progress monitor to search with
+
+ // return the collector
+ return collector;
+ }
+
+ /**
+ * Search the local bugs for the member using the unqualified name
+ *
+ * @param monitor
+ * The progress monitor to search with
* @return The BugzillaResultCollector with the results of the search
*/
private BugzillaResultCollector searchLocalUnQual(IProgressMonitor monitor) {
- // get the element name for searching
- String elementName = javaElement.getElementName();
-
- // setup the search result collector
+ // get the element name for searching
+ String elementName = javaElement.getElementName();
+
+ // setup the search result collector
collector = new BugzillaResultCollector();
collector.setOperation(this);
collector.setProgressMonitor(monitor);
-
+
// get all of the root tasks and start the search
List<ITask> tasks = MylarTaskListPlugin.getTaskListManager().getTaskList().getRootTasks();
- searchLocal(tasks, collector, elementName, monitor);
+ searchLocal(tasks, collector, elementName, monitor);
for (TaskCategory cat : MylarTaskListPlugin.getTaskListManager().getTaskList().getTaskCategories()) {
- searchLocal(cat.getChildren(), collector, elementName, monitor);
+ searchLocal(cat.getChildren(), collector, elementName, monitor);
}
// return the collector
return collector;
@@ -196,330 +195,323 @@ public class BugzillaMylarSearchOperation extends WorkspaceModifyOperation
/**
* Search the local bugs for the member
- * @param tasks The tasks to search
- * @param searchCollector The collector to add the results to
- * @param elementName The name of the element that we are looking for
- * @param monitor The progress monitor
+ *
+ * @param tasks
+ * The tasks to search
+ * @param searchCollector
+ * The collector to add the results to
+ * @param elementName
+ * The name of the element that we are looking for
+ * @param monitor
+ * The progress monitor
*/
- private void searchLocal(List<ITask> tasks, BugzillaResultCollector searchCollector, String elementName, IProgressMonitor monitor) {
- if(tasks == null) return;
-
+ private void searchLocal(List<ITask> tasks, BugzillaResultCollector searchCollector, String elementName,
+ IProgressMonitor monitor) {
+ if (tasks == null)
+ return;
+
// go through all of the tasks
- for(ITask task : tasks){
+ for (ITask task : tasks) {
monitor.worked(1);
-
+
// check what kind of task it is
- if(task instanceof BugzillaTask){
-
+ if (task instanceof BugzillaTask) {
+
// we have a bugzilla task, so get the bug report
- BugzillaTask bugTask = (BugzillaTask)task;
+ BugzillaTask bugTask = (BugzillaTask) task;
BugReport bug = bugTask.getBugReport();
-
- // parse the bug report for the element that we are searching for
+
+ // parse the bug report for the element that we are searching
+ // for
boolean isHit = search(elementName, bug);
-
+
// determine if we have a hit or not
- if(isHit){
-
- // make a search hit from the bug and then add it to the collector
- BugzillaSearchHit hit = new BugzillaSearchHit(bug.getId(), bug.getDescription(), "","","","","","","", bug.getServer());
- try{
+ if (isHit) {
+
+ // make a search hit from the bug and then add it to the
+ // collector
+ BugzillaSearchHit hit = new BugzillaSearchHit(bug.getServer(), bug.getId(), bug.getDescription(), "", "", "",
+ "", "", "", "");
+ try {
searchCollector.accept(hit);
- } catch(CoreException e){
- MylarStatusHandler.log(e, "bug search failed");
+ } catch (CoreException e) {
+ MylarStatusHandler.log(e, "bug search failed");
}
}
}
}
- status = Status.OK_STATUS;
+ status = Status.OK_STATUS;
+ }
+
+ /**
+ * Search the bug for the given element name
+ *
+ * @param elementName
+ * The name of the element to search for
+ * @param bug
+ * The bug to search in
+ */
+ private boolean search(String elementName, BugReport bug) {
+
+ if (bug == null)
+ return false; // MIK: added null check here
+ String description = bug.getDescription();
+ String summary = bug.getSummary();
+ List<Comment> comments = bug.getComments();
+
+ // search the description and the summary
+ if (Util.hasElementName(elementName, summary))
+ return true;
+
+ if (Util.hasElementName(elementName, description))
+ return true;
+
+ Iterator<Comment> comItr = comments.iterator();
+ while (comItr.hasNext()) {
+ Comment comment = comItr.next();
+ String commentText = comment.getText();
+ // search the text for a reference to the element
+ if (Util.hasElementName(elementName, commentText))
+ return true;
+ }
+ return false;
}
/**
- * Search the bug for the given element name
- * @param elementName The name of the element to search for
- * @param bug The bug to search in
- */
- private boolean search(String elementName, BugReport bug) {
-
- if (bug == null) return false; // MIK: added null check here
- String description = bug.getDescription();
- String summary = bug.getSummary();
- List<Comment> comments = bug.getComments();
-
- // search the description and the summary
- if(Util.hasElementName(elementName, summary))
- return true;
-
- if(Util.hasElementName(elementName, description))
- return true;
-
- Iterator<Comment> comItr = comments.iterator();
- while (comItr.hasNext()) {
- Comment comment = comItr.next();
- String commentText = comment.getText();
- // search the text for a reference to the element
- if(Util.hasElementName(elementName, commentText))
- return true;
- }
- return false;
- }
-
- /**
- * Perform the actual search on the Bugzilla server
- * @param url The url to use for the search
- * @param searchCollector The collector to put the search results into
- * @param monitor The progress monitor to use for the search
- * @return The BugzillaResultCollector with the search results
- */
- private BugzillaResultCollector search(String url, BugzillaResultCollector searchCollector, IProgressMonitor monitor){
-
- // set the initial number of matches to 0
- int matches = 0;
- // setup the progress monitor and start the search
+ * Perform the actual search on the Bugzilla server
+ *
+ * @param url
+ * The url to use for the search
+ * @param searchCollector
+ * The collector to put the search results into
+ * @param monitor
+ * The progress monitor to use for the search
+ * @return The BugzillaResultCollector with the search results
+ */
+ private BugzillaResultCollector search(String url, TaskRepository repository, BugzillaResultCollector searchCollector, IProgressMonitor monitor) {
+
+ // set the initial number of matches to 0
+ int matches = 0;
+ // setup the progress monitor and start the search
searchCollector.setProgressMonitor(monitor);
- BugzillaSearchEngine engine = new BugzillaSearchEngine(url);
+ BugzillaSearchEngine engine = new BugzillaSearchEngine(repository, url);
try {
+ // perform the search
+ status = engine.search(searchCollector, matches);
+
+ // check the status so that we don't keep searching if there
+ // is a problem
+ if (status.getCode() == IStatus.CANCEL) {
+ return null;
+ } else if (!status.isOK()) {
+ MylarStatusHandler.log("search error", this);
+ MylarStatusHandler.log(status);
+ return null;
+ }
+ return searchCollector;
+ } catch (LoginException e) {
+ // save this exception to throw later
+ this.loginException = e;
+ }
+ return null;
+ }
+
+ /**
+ * Perform a search for qualified instances of the member
+ *
+ * @param monitor
+ * The progress monitor to use
+ * @return The BugzillaResultCollector with the search results
+ */
+ private BugzillaResultCollector searchQualified(String repositoryUrl, IProgressMonitor monitor) {
+ // create a new collector for the results
+ collector = new BugzillaResultCollector();
+ collector.setOperation(this);
+ collector.setProgressMonitor(monitor);
+
+ // get the search url
+ String url = Util.getExactSearchURL(repositoryUrl, javaElement);
+ TaskRepository repository = MylarTaskListPlugin.getRepositoryManager().getRepository(BugzillaPlugin.REPOSITORY_KIND, repositoryUrl);
+ return search(url, repository, collector, monitor);
+ }
+
+ /**
+ * Perform a search for unqualified instances of the member
+ *
+ * @param monitor
+ * The progress monitor to use
+ * @return The BugzillaResultCollector with the search results
+ */
+ private BugzillaResultCollector searchUnqualified(String repositoryUrl, IProgressMonitor monitor) {
+ // create a new collector for the results
+ collector = new BugzillaResultCollector();
+ collector.setOperation(this);
+ collector.setProgressMonitor(monitor);
+
+ // get the search url
+ String url = Util.getInexactSearchURL(repositoryUrl, javaElement);
+ TaskRepository repository = MylarTaskListPlugin.getRepositoryManager().getRepository(BugzillaPlugin.REPOSITORY_KIND, repositoryUrl);
- // perform the search
- status = engine.search(searchCollector, matches);
-
- // check the status so that we don't keep searching if there
- // is a problem
- if (status.getCode() == IStatus.CANCEL) {
- return null;
- } else if (!status.isOK()) {
- MylarStatusHandler.log("search error", this);
- MylarStatusHandler.log(status);
- return null;
- }
- return searchCollector;
- } catch (LoginException e) {
- //save this exception to throw later
- this.loginException = e;
- }
- return null;
+ return search(url, repository, collector, monitor);
+ }
+
+ /**
+ * Perform a second pass parse to determine if there are any stack traces in
+ * the bug - currently only used for the exact search results
+ *
+ * @param doiList -
+ * the list of BugzillaSearchHitDOI elements to parse
+ */
+ public static void secondPassBugzillaParser(List<BugzillaReportNode> doiList) {
+
+ // go through each of the items in the doiList
+ for (BugzillaReportNode info : doiList) {
+
+ // get the bug report so that we have all of the data
+ // - descriptions, comments, etc
+ BugReport b = null;
+ try {
+ b = info.getBug();
+ } catch (Exception e) {
+ // don't care since null will be caught
+ }
+
+ // if the report could not be downloaded, try the next one
+ if (b == null)
+ continue;
+
+ // see if the description has a stack trace in it
+ StackTrace[] stackTrace = StackTrace.getStackTrace(b.getDescription(), b.getDescription());
+ if (stackTrace != null) {
+
+ // add the stack trace to the doi info
+ info.setExact(true);
+ info.addStackTraces(stackTrace);
+ }
+
+ // go through all of the comments for the bug
+ Iterator<Comment> comItr = b.getComments().iterator();
+ while (comItr.hasNext()) {
+ Comment comment = comItr.next();
+ String commentText = comment.getText();
+
+ // see if the comment has a stack trace in it
+ stackTrace = StackTrace.getStackTrace(commentText, comment);
+ if (stackTrace != null) {
+
+ // add the stack trace to the doi info
+ info.setExact(true);
+ info.addStackTraces(stackTrace);
+ }
+ }
+ }
}
/**
- * Perform a search for qualified instances of the member
- * @param monitor The progress monitor to use
- * @return The BugzillaResultCollector with the search results
- */
- private BugzillaResultCollector searchQualified(IProgressMonitor monitor)
- {
- // create a new collector for the results
- collector = new BugzillaResultCollector();
- collector.setOperation(this);
- collector.setProgressMonitor(monitor);
-
- // get the search url
- String url = Util.getExactSearchURL(javaElement);
-
- // log the url that we are searching with
- // MIK: commmented out logging
-// MonitorPlugin.log(this, url);
-
- return search(url, collector, monitor);
- }
-
- /**
- * Perform a search for unqualified instances of the member
- * @param monitor The progress monitor to use
- * @return The BugzillaResultCollector with the search results
- */
- private BugzillaResultCollector searchUnqualified(IProgressMonitor monitor)
- {
- // create a new collector for the results
- collector = new BugzillaResultCollector();
- collector.setOperation(this);
- collector.setProgressMonitor(monitor);
-
- // get the search url
- String url = Util.getInexactSearchURL(javaElement);
-
- // log the url that we are searching with
- // MIK: commmented out logging
-// MonitorPlugin.log(this, url);
-
- return search(url, collector, monitor);
- }
-
-// /**
-// * Remove all of the duplicates
-// * @param compare The List of BugzillaSearchHits to compare with
-// * @param base The List of BugzillaSearchHits to remove the duplicates from
-// */
-// private void removeDuplicates(List<BugzillaSearchHit> compare, List<BugzillaSearchHit> base){
-//
-// for(BugzillaSearchHit h1 : compare){
-// Iterator itr2 = base.iterator();
-// while(itr2.hasNext()){
-// BugzillaSearchHit h2 = (BugzillaSearchHit)itr2.next();
-// if(h2.getId() == h1.getId()){
-// // we found a duplicate so remove it
-// itr2.remove();
-// break;
-// }
-// }
-// }
-// }
-//
- /**
- * Perform a second pass parse to determine if there are any stack traces in
- * the bug - currently only used for the exact search results
- *
- * @param doiList -
- * the list of BugzillaSearchHitDOI elements to parse
- */
- public static void secondPassBugzillaParser(List<BugzillaReportNode> doiList) {
-
- // go through each of the items in the doiList
- for(BugzillaReportNode info : doiList) {
-
- // get the bug report so that we have all of the data
- // - descriptions, comments, etc
- BugReport b = null;
- try{
- b = info.getBug();
- }catch(Exception e){
- // don't care since null will be caught
- }
-
- // if the report could not be downloaded, try the next one
- if (b == null)
- continue;
-
- // see if the description has a stack trace in it
- StackTrace[] stackTrace = StackTrace.getStackTrace(b.getDescription(), b.getDescription());
- if (stackTrace != null) {
-
- // add the stack trace to the doi info
- info.setExact(true);
- info.addStackTraces(stackTrace);
- }
-
- // go through all of the comments for the bug
- Iterator<Comment> comItr = b.getComments().iterator();
- while (comItr.hasNext()) {
- Comment comment = comItr.next();
- String commentText = comment.getText();
-
- // see if the comment has a stack trace in it
- stackTrace = StackTrace.getStackTrace(commentText, comment);
- if (stackTrace != null) {
-
- // add the stack trace to the doi info
- info.setExact(true);
- info.addStackTraces(stackTrace);
- }
- }
- }
- }
-
- /**
- * Add the results returned to the Hash of landmarks
- *
- * @param results
- * The list of results
- * @param isExact
- * whether the search was exact or not
- */
- private List<BugzillaReportNode> getDoiList(List<BugzillaSearchHit> results) {
- List<BugzillaReportNode> doiList = new ArrayList<BugzillaReportNode>();
-
- boolean isExact = (scope==BugzillaMylarSearch.FULLY_QUAL || scope==BugzillaMylarSearch.LOCAL_QUAL)?true:false;
-
- BugzillaReportNode info = null;
- // go through all of the results and create a DoiInfo list
- for(BugzillaSearchHit hit : results){
-
- try {
- float value = 0;
- info = new BugzillaReportNode(
- value, hit, isExact);
-
- // only download the bug for the exact matches
- //downloading bugs kills the time - can we do this elsewhere? - different thread? persistant?
-// if(isExact){
-// // get the bug report for the doi info item
-// BugReport b = BugzillaRepository.getInstance().getBug(
-// hit.getId());
-// // add the bug to the doi info for future use
-// info.setBug(b);
-// }
-
- } catch (Exception e) {
- MylarStatusHandler.log(e, "search failed");
- }
- finally{
- doiList.add(info);
- }
- }
- return doiList;
- }
-
- /**
- * @see org.eclipse.mylar.bugs.core.search.IBugzillaSearchOperation#getStatus()
- */
- public IStatus getStatus() throws LoginException {
- // if a LoginException was thrown while trying to search, throw this
- if (loginException == null) {
- return status;
- } else {
- throw loginException;
- }
- }
-
- /**
- * @see org.eclipse.mylar.bugs.core.search.IBugzillaSearchOperation#getImageDescriptor()
- */
- public ImageDescriptor getImageDescriptor() {
- return null;
- }
-
- /**
- * Get the member that we are performing the search for
- *
- * @return The member this search is being performed for
- */
- public IMember getSearchMember() {
- return javaElement;
- }
-
- /**
- * Get the name of the member that we are searching for
- *
- * @return The fully qualified name of the member
- */
- public String getSearchMemberName() {
- return name;
- }
-
- /**
- * @see org.eclipse.mylar.bugs.core.search.IBugzillaSearchOperation#getQuery()
- */
- public BugzillaSearchQuery getQuery() {
- return query;
- }
-
- /**
- * @see org.eclipse.mylar.bugs.core.search.IBugzillaSearchOperation#setQuery(org.eclipse.mylar.bugs.core.search.BugzillaSearchQuery)
- */
- public void setQuery(BugzillaSearchQuery newQuery) {
- this.query = newQuery;
- }
-
- /**
- * Get the name of the element that we are searching for
- *
- * @return The name of the element
- */
- public String getName(){
- return name;
- }
+ * Add the results returned to the Hash of landmarks
+ *
+ * @param results
+ * The list of results
+ * @param isExact
+ * whether the search was exact or not
+ */
+ private List<BugzillaReportNode> getDoiList(List<BugzillaSearchHit> results) {
+ List<BugzillaReportNode> doiList = new ArrayList<BugzillaReportNode>();
+
+ boolean isExact = (scope == BugzillaMylarSearch.FULLY_QUAL || scope == BugzillaMylarSearch.LOCAL_QUAL) ? true
+ : false;
+
+ BugzillaReportNode info = null;
+ // go through all of the results and create a DoiInfo list
+ for (BugzillaSearchHit hit : results) {
+
+ try {
+ float value = 0;
+ info = new BugzillaReportNode(value, hit, isExact);
+
+ // only download the bug for the exact matches
+ // downloading bugs kills the time - can we do this elsewhere? -
+ // different thread? persistant?
+ // if(isExact){
+ // // get the bug report for the doi info item
+ // BugReport b = BugzillaRepositoryUtil.getInstance().getBug(
+ // hit.getId());
+ // // add the bug to the doi info for future use
+ // info.setBug(b);
+ // }
+
+ } catch (Exception e) {
+ MylarStatusHandler.log(e, "search failed");
+ } finally {
+ doiList.add(info);
+ }
+ }
+ return doiList;
+ }
+
+ /**
+ * @see org.eclipse.mylar.bugs.core.search.IBugzillaSearchOperation#getStatus()
+ */
+ public IStatus getStatus() throws LoginException {
+ // if a LoginException was thrown while trying to search, throw this
+ if (loginException == null) {
+ return status;
+ } else {
+ throw loginException;
+ }
+ }
+
+ /**
+ * @see org.eclipse.mylar.bugs.core.search.IBugzillaSearchOperation#getImageDescriptor()
+ */
+ public ImageDescriptor getImageDescriptor() {
+ return null;
+ }
+
+ /**
+ * Get the member that we are performing the search for
+ *
+ * @return The member this search is being performed for
+ */
+ public IMember getSearchMember() {
+ return javaElement;
+ }
+
+ /**
+ * Get the name of the member that we are searching for
+ *
+ * @return The fully qualified name of the member
+ */
+ public String getSearchMemberName() {
+ return name;
+ }
+
+ /**
+ * @see org.eclipse.mylar.bugs.core.search.IBugzillaSearchOperation#getQuery()
+ */
+ public BugzillaSearchQuery getQuery() {
+ return query;
+ }
+
+ /**
+ * @see org.eclipse.mylar.bugs.core.search.IBugzillaSearchOperation#setQuery(org.eclipse.mylar.bugs.core.search.BugzillaSearchQuery)
+ */
+ public void setQuery(BugzillaSearchQuery newQuery) {
+ this.query = newQuery;
+ }
+
+ /**
+ * Get the name of the element that we are searching for
+ *
+ * @return The name of the element
+ */
+ public String getName() {
+ return name;
+ }
/**
* Get the scope of the search operation
+ *
* @return The scope - defined in BugzillaMylarSearch
*/
public int getScope() {
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/bugs/search/BugzillaReferencesProvider.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/bugs/search/BugzillaReferencesProvider.java
index 7f7575502..ca756fe65 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/bugs/search/BugzillaReferencesProvider.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/bugs/search/BugzillaReferencesProvider.java
@@ -28,11 +28,14 @@ import org.eclipse.jdt.core.JavaCore;
import org.eclipse.mylar.bugs.BugzillaSearchManager;
import org.eclipse.mylar.bugs.BugzillaStructureBridge;
import org.eclipse.mylar.bugs.MylarBugsPlugin;
+import org.eclipse.mylar.bugzilla.core.BugzillaPlugin;
import org.eclipse.mylar.bugzilla.ui.tasklist.BugzillaReportNode;
import org.eclipse.mylar.core.AbstractRelationProvider;
import org.eclipse.mylar.core.IMylarElement;
import org.eclipse.mylar.core.search.IActiveSearchListener;
import org.eclipse.mylar.core.search.IMylarSearchOperation;
+import org.eclipse.mylar.tasklist.MylarTaskListPlugin;
+import org.eclipse.mylar.tasklist.repositories.TaskRepository;
import org.eclipse.ui.PlatformUI;
@@ -70,7 +73,9 @@ public class BugzillaReferencesProvider extends AbstractRelationProvider {
@Override
public IMylarSearchOperation getSearchOperation(IMylarElement node, int limitTo, int degreeOfSepatation) {
IJavaElement javaElement = JavaCore.create(node.getHandleIdentifier());
- return new BugzillaMylarSearch(degreeOfSepatation, javaElement);
+
+ TaskRepository repository = MylarTaskListPlugin.getRepositoryManager().getDefaultRepository(BugzillaPlugin.REPOSITORY_KIND);
+ return new BugzillaMylarSearch(degreeOfSepatation, javaElement, repository.getServerUrl().toExternalForm());
}
private void runJob(final IMylarElement node, final int degreeOfSeparation) {
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/bugs/search/Util.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/bugs/search/Util.java
index 84008772d..89508089f 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/bugs/search/Util.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/bugs/search/Util.java
@@ -21,14 +21,17 @@ import org.eclipse.jdt.core.IMember;
import org.eclipse.jdt.core.IType;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.mylar.bugzilla.core.BugzillaPlugin;
-import org.eclipse.mylar.bugzilla.core.BugzillaPreferencePage;
+import org.eclipse.mylar.bugzilla.core.BugzillaRepositoryUtil;
import org.eclipse.mylar.bugzilla.core.IBugzillaConstants;
+import org.eclipse.mylar.tasklist.MylarTaskListPlugin;
+import org.eclipse.mylar.tasklist.repositories.TaskRepository;
/**
* Utilities methods for the BugzillaMylarBridge
*
* @author Shawn Minto
+ * @author Mik Kersten
*/
public class Util {
@@ -43,11 +46,11 @@ public class Util {
/**
* List of all of the resolutions that we can have <br> FIXED, INVALID, WONTFIX, LATER, REMIND, DUPLICATE, WORKSFORME, MOVED, ---
*/
- private static String[] resolutionValues = BugzillaPreferencePage.queryOptionsToArray(prefs.getString(IBugzillaConstants.RESOLUTION_VALUES));
+ private static String[] resolutionValues = BugzillaRepositoryUtil.queryOptionsToArray(prefs.getString(IBugzillaConstants.VALUES_RESOLUTION));
/**
* List of all of the statuses that we can have <br> UNCONFIRMED, NEW, ASSIGNED, REOPENED, RESOLVED, VERIFIED, CLOSED
*/
- private static String[] statusValues = BugzillaPreferencePage.queryOptionsToArray(prefs.getString(IBugzillaConstants.STATUS_VALUES));
+ private static String[] statusValues = BugzillaRepositoryUtil.queryOptionsToArray(prefs.getString(IBugzillaConstants.VALUES_STATUS));
/**
* Get the bugzilla url used for searching for exact matches
@@ -56,8 +59,8 @@ public class Util {
* The IMember to create the query string for
* @return A url string for the search
*/
- public static String getExactSearchURL(IMember je) {
- StringBuffer sb = getQueryURLStart();
+ public static String getExactSearchURL(String repositoryUrl, IMember je) {
+ StringBuffer sb = getQueryURLStart(repositoryUrl);
String long_desc = "";
@@ -83,8 +86,8 @@ public class Util {
* The IMember to create the query string for
* @return A url string for the search
*/
- public static String getInexactSearchURL(IMember je) {
- StringBuffer sb = getQueryURLStart();
+ public static String getInexactSearchURL(String repositoryUrl, IMember je) {
+ StringBuffer sb = getQueryURLStart(repositoryUrl);
String long_desc = "";
@@ -135,32 +138,32 @@ public class Util {
* @return The start of the query url as a StringBuffer <br>
* Example: https://bugs.eclipse.org/bugs/buglist.cgi?long_desc_type=allwordssubstr&long_desc=
*/
- public static StringBuffer getQueryURLStart() {
- StringBuffer sb = new StringBuffer(BugzillaPlugin.getDefault()
- .getServerName());
+ public static StringBuffer getQueryURLStart(String repositoryUrl) {
+ StringBuffer sb = new StringBuffer(repositoryUrl);
if (sb.charAt(sb.length() - 1) != '/') {
sb.append('/');
}
sb.append("buglist.cgi?");
- // use the username and password if we have it
- if (BugzillaPreferencePage.getUserName() != null
- && !BugzillaPreferencePage.getUserName().equals("")
- && BugzillaPreferencePage.getPassword() != null
- && !BugzillaPreferencePage.getPassword().equals("")) {
+ TaskRepository repository = MylarTaskListPlugin.getRepositoryManager().getRepository(BugzillaPlugin.REPOSITORY_KIND, repositoryUrl);
+ if (repository != null && repository.hasCredentials()) {
+// if (BugzillaPreferencePage.getUserName() != null
+// && !BugzillaPreferencePage.getUserName().equals("")
+// && BugzillaPreferencePage.getPassword() != null
+// && !BugzillaPreferencePage.getPassword().equals("")) {
try{
sb.append("GoAheadAndLogIn=1&Bugzilla_login="
- + URLEncoder.encode(BugzillaPreferencePage.getUserName(), Charset.defaultCharset().toString())
+ + URLEncoder.encode(repository.getUserName(), //BugzillaPreferencePage.getUserName(),
+ Charset.defaultCharset().toString())
+ "&Bugzilla_password="
- + URLEncoder.encode(BugzillaPreferencePage.getPassword(), Charset.defaultCharset().toString())
+ + URLEncoder.encode(repository.getPassword(), //BugzillaPreferencePage.getPassword(),
+ Charset.defaultCharset().toString())
+ "&");
- } catch (UnsupportedEncodingException e)
- {
+ } catch (UnsupportedEncodingException e) {
// should never get here since we are using the default encoding
}
}
-
// add the description search type
sb.append("long_desc_type=");
sb.append(patternOperationValues[0]); // search for all words
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/bugs/ui/actions/OpenCorrespondingReportAction.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/bugs/ui/actions/OpenCorrespondingReportAction.java
index b6378a71a..06cbee5e4 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/bugs/ui/actions/OpenCorrespondingReportAction.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/bugs/ui/actions/OpenCorrespondingReportAction.java
@@ -16,9 +16,12 @@ import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.mylar.bugs.java.OpenBugzillaReportJob;
+import org.eclipse.mylar.bugzilla.core.BugzillaPlugin;
import org.eclipse.mylar.bugzilla.ui.BugzillaUITools;
import org.eclipse.mylar.core.util.MylarStatusHandler;
import org.eclipse.mylar.ide.team.MylarContextChangeSet;
+import org.eclipse.mylar.tasklist.MylarTaskListPlugin;
+import org.eclipse.mylar.tasklist.repositories.TaskRepository;
import org.eclipse.swt.widgets.Display;
import org.eclipse.team.internal.ccvs.core.client.listeners.LogEntry;
import org.eclipse.team.internal.ui.synchronize.ChangeSetDiffNode;
@@ -38,6 +41,9 @@ public class OpenCorrespondingReportAction implements IViewActionDelegate {
}
public void run(IAction action) {
+// HACK: determine appropriate repository
+ final TaskRepository repository = MylarTaskListPlugin.getRepositoryManager().getDefaultRepository(BugzillaPlugin.REPOSITORY_KIND);
+
if (action instanceof ObjectPluginAction) {
ObjectPluginAction objectAction = (ObjectPluginAction)action;
if (objectAction.getSelection() instanceof StructuredSelection) {
@@ -61,7 +67,7 @@ public class OpenCorrespondingReportAction implements IViewActionDelegate {
// ignore
}
if (id != -1) {
- OpenBugzillaReportJob job = new OpenBugzillaReportJob(id);
+ OpenBugzillaReportJob job = new OpenBugzillaReportJob(repository.getServerUrl().toExternalForm(), id);
IProgressService service = PlatformUI.getWorkbench().getProgressService();
try {
service.run(true, false, job);
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasklist/tests/AllTasklistTests.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasklist/tests/AllTasklistTests.java
index c7457217d..762d24ed9 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasklist/tests/AllTasklistTests.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasklist/tests/AllTasklistTests.java
@@ -24,7 +24,7 @@ public class AllTasklistTests {
//$JUnit-BEGIN$
suite.addTestSuite(TaskTest.class);
- suite.addTestSuite(RepositoryManagerTest.class);
+ suite.addTestSuite(TaskRepositoryManagerTest.class);
suite.addTestSuite(TaskListStandaloneTest.class);
suite.addTestSuite(TaskListManagerTest.class);
suite.addTestSuite(TaskListUiTest.class);
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasklist/tests/TaskListManagerTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasklist/tests/TaskListManagerTest.java
index dc10cea36..526a98949 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasklist/tests/TaskListManagerTest.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasklist/tests/TaskListManagerTest.java
@@ -13,18 +13,26 @@
*/
package org.eclipse.mylar.tasklist.tests;
+import java.net.MalformedURLException;
+import java.net.URL;
import java.util.List;
import junit.framework.TestCase;
+import org.eclipse.mylar.bugzilla.core.BugzillaPlugin;
+import org.eclipse.mylar.bugzilla.core.IBugzillaConstants;
+import org.eclipse.mylar.bugzilla.ui.tasklist.BugzillaQueryCategory;
import org.eclipse.mylar.bugzilla.ui.tasklist.BugzillaTask;
import org.eclipse.mylar.bugzilla.ui.tasklist.BugzillaTaskExternalizer;
import org.eclipse.mylar.tasklist.ITask;
+import org.eclipse.mylar.tasklist.ITaskQuery;
import org.eclipse.mylar.tasklist.MylarTaskListPlugin;
import org.eclipse.mylar.tasklist.internal.Task;
import org.eclipse.mylar.tasklist.internal.TaskCategory;
import org.eclipse.mylar.tasklist.internal.TaskList;
import org.eclipse.mylar.tasklist.internal.TaskListManager;
+import org.eclipse.mylar.tasklist.repositories.TaskRepository;
+import org.eclipse.mylar.tasklist.repositories.TaskRepositoryManager;
/**
* @author Mik Kersten
@@ -33,11 +41,23 @@ public class TaskListManagerTest extends TestCase {
private TaskListManager manager;
+ private TaskRepository repository;
+
+ public TaskListManagerTest() {
+ try {
+ repository = new TaskRepository(BugzillaPlugin.REPOSITORY_KIND, new URL(IBugzillaConstants.ECLIPSE_BUGZILLA_URL));
+ } catch (MalformedURLException e) {
+ fail();
+ e.printStackTrace();
+ }
+ }
+
@Override
protected void setUp() throws Exception {
super.setUp();
manager = MylarTaskListPlugin.getTaskListManager();
manager.createNewTaskList();
+ MylarTaskListPlugin.getRepositoryManager().addRepository(repository);
}
@Override
@@ -45,8 +65,29 @@ public class TaskListManagerTest extends TestCase {
super.tearDown();
manager.createNewTaskList();
MylarTaskListPlugin.getDefault().getTaskListSaveManager().saveTaskListAndContexts();
+ MylarTaskListPlugin.getRepositoryManager().removeRepository(repository);
}
+ public void testRepositoryUrlHandles() {
+
+ String repository = IBugzillaConstants.ECLIPSE_BUGZILLA_URL;
+ String id = "123";
+ String handle = TaskRepositoryManager.getHandle(repository, id);
+ BugzillaTask bugTask = new BugzillaTask(handle, "label 124", true);
+ assertEquals(repository, bugTask.getRepositoryUrl());
+
+ manager.moveToRoot(bugTask);
+
+ manager.saveTaskList();
+ TaskList list = new TaskList();
+ manager.setTaskList(list);
+ manager.readOrCreateTaskList();
+
+ BugzillaTask readReport = (BugzillaTask)manager.getTaskList().getRootTasks().get(0);
+ assertEquals(readReport.getDescription(true), readReport.getDescription(true));
+ assertEquals(readReport.getRepositoryUrl(), readReport.getRepositoryUrl());
+ }
+
public void testMoves() {
assertEquals(0, manager.getTaskList().getRootTasks().size());
Task task1 = new Task("t1", "t1", true);
@@ -89,12 +130,25 @@ public class TaskListManagerTest extends TestCase {
assertTrue(task.getPlans().get(0).equals("default"));
}
- public void testCreationAndExternalization() {
-// File file = new File("foo" + MylarTaskListPlugin.FILE_EXTENSION);
-// file.deleteOnExit();
-// TaskListManager manager = new TaskListManager(file);
+ public void testQueryExternalization() {
+ ITaskQuery query = new BugzillaQueryCategory("repositoryUrl", "queryUrl", "label", "1");
+ assertEquals("repositoryUrl", query.getRepositoryUrl());
+ assertEquals("queryUrl", query.getQueryUrl());
+ manager.addQuery(query);
+ manager.saveTaskList();
+ assertNotNull(manager.getTaskList());
- TaskListManager manager = MylarTaskListPlugin.getTaskListManager();
+ TaskList list = new TaskList();
+ manager.setTaskList(list);
+ manager.readOrCreateTaskList();
+ assertEquals(1, manager.getTaskList().getQueries().size());
+ ITaskQuery readQuery = manager.getTaskList().getQueries().get(0);
+ assertEquals(query.getQueryUrl(), readQuery.getQueryUrl());
+ assertEquals(query.getRepositoryUrl(), readQuery.getRepositoryUrl());
+ assertEquals("repositoryUrl", readQuery.getRepositoryUrl());
+ }
+
+ public void testCreationAndExternalization() {
Task task1 = new Task(manager.genUniqueTaskHandle(), "task 1", true);
manager.moveToRoot(task1);
Task sub1 = new Task(manager.genUniqueTaskHandle(), "sub 1", true);
@@ -121,7 +175,7 @@ public class TaskListManagerTest extends TestCase {
Task task6 = new Task(manager.genUniqueTaskHandle(), "task 6", true);
manager.moveToCategory(cat2, task6);
- BugzillaTask report = new BugzillaTask("123", "label 123", true);
+ BugzillaTask report = new BugzillaTask("123", "label 123", true);;
manager.moveToCategory(cat2, report);
assertEquals(cat2, report.getCategory());
@@ -144,6 +198,8 @@ public class TaskListManagerTest extends TestCase {
assertTrue(readList.get(0).getChildren().get(0).getDescription(true).equals("sub 1"));
assertTrue(readList.get(1).getDescription(true).equals("task 2"));
assertTrue(readList.get(2) instanceof BugzillaTask);
+ BugzillaTask readReport = (BugzillaTask)readList.get(2);
+ assertEquals(report2.getDescription(true), readReport.getDescription(true));
List<TaskCategory> readCats = manager.getTaskList().getTaskCategories();
assertTrue(readCats.get(0).getDescription(true).equals(BugzillaTaskExternalizer.BUGZILLA_ARCHIVE_LABEL));
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasklist/tests/RepositoryManagerTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasklist/tests/TaskRepositoryManagerTest.java
index 8bacc0284..b35328c50 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasklist/tests/RepositoryManagerTest.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasklist/tests/TaskRepositoryManagerTest.java
@@ -18,6 +18,7 @@ import java.util.List;
import junit.framework.TestCase;
+import org.eclipse.mylar.bugzilla.core.IBugzillaConstants;
import org.eclipse.mylar.tasklist.MylarTaskListPlugin;
import org.eclipse.mylar.tasklist.repositories.TaskRepository;
import org.eclipse.mylar.tasklist.repositories.TaskRepositoryManager;
@@ -25,36 +26,57 @@ import org.eclipse.mylar.tasklist.repositories.TaskRepositoryManager;
/**
* @author Mik Kersten
*/
-public class RepositoryManagerTest extends TestCase {
+public class TaskRepositoryManagerTest extends TestCase {
+ private static final String DEFAULT_KIND = "bugzilla";
+ private static final String DEFAULT_URL = "http://eclipse.org";
private TaskRepositoryManager manager;
@Override
protected void setUp() throws Exception {
super.setUp();
manager = MylarTaskListPlugin.getRepositoryManager();
+ manager.clearRepositories();
assertNotNull(manager);
}
@Override
protected void tearDown() throws Exception {
- // TODO Auto-generated method stub
super.tearDown();
manager.clearRepositories();
}
+ public void testHandles() {
+ String url = IBugzillaConstants.ECLIPSE_BUGZILLA_URL;
+ String id = "123";
+ String handle = TaskRepositoryManager.getHandle(url, id);
+ assertEquals(url, TaskRepositoryManager.getRepositoryUrl(handle));
+ assertEquals(id, TaskRepositoryManager.getTaskId(handle));
+ assertEquals(123, TaskRepositoryManager.getTaskIdAsInt(handle));
+ }
+
public void testMultipleNotAdded() throws MalformedURLException {
- TaskRepository repository = new TaskRepository(new URL("http://eclipse.org"), "bugzilla");
+ TaskRepository repository = new TaskRepository(DEFAULT_KIND, new URL(DEFAULT_URL));
manager.addRepository(repository);
- TaskRepository repository2 = new TaskRepository(new URL("http://eclipse.org"), "bugzilla");
+ TaskRepository repository2 = new TaskRepository(DEFAULT_KIND, new URL(DEFAULT_URL));
manager.addRepository(repository2);
assertEquals(1, manager.getAllRepositories().size());
}
+
+ public void testGet() throws MalformedURLException {
+ assertEquals("", MylarTaskListPlugin.getPrefs().getString(TaskRepositoryManager.PREF_REPOSITORIES));
+
+ TaskRepository repository = new TaskRepository(DEFAULT_KIND, new URL(DEFAULT_URL));
+ manager.addRepository(repository);
+ assertEquals(repository, manager.getRepository(DEFAULT_KIND, DEFAULT_URL));
+ assertNull(manager.getRepository(DEFAULT_KIND, "foo"));
+ assertNull(manager.getRepository("foo", DEFAULT_URL));
+ }
public void testRepositoryPersistance() throws MalformedURLException {
assertEquals("", MylarTaskListPlugin.getPrefs().getString(TaskRepositoryManager.PREF_REPOSITORIES));
- TaskRepository repository = new TaskRepository(new URL("http://eclipse.org"), "bugzilla");
+ TaskRepository repository = new TaskRepository(DEFAULT_KIND, new URL(DEFAULT_URL));
manager.addRepository(repository);
assertNotNull(MylarTaskListPlugin.getPrefs().getString(TaskRepositoryManager.PREF_REPOSITORIES));
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/IQueryHit.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/IQueryHit.java
index dab675b7d..cb22bf531 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/IQueryHit.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/IQueryHit.java
@@ -17,6 +17,8 @@ import org.eclipse.mylar.tasklist.ui.ITaskListElement;
*/
public interface IQueryHit extends ITaskListElement {
+ public String getRepositoryUrl();
+
public ITask getOrCreateCorrespondingTask();
public ITask getCorrespondingTask();
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ITask.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ITask.java
index e7e85a72d..550b98ba3 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ITask.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ITask.java
@@ -20,7 +20,6 @@ import org.eclipse.mylar.tasklist.ui.ITaskListElement;
/**
* @author Mik Kersten
- *
*/
public interface ITask extends ITaskListElement {
@@ -54,6 +53,10 @@ public interface ITask extends ITaskListElement {
public abstract String getUrl();
+ public abstract String getRepositoryUrl();
+
+ public abstract void setRepositoryUrl(String repositoryUrl);
+
public abstract String getNotes();
public abstract void setNotes(String notes);
@@ -115,8 +118,4 @@ public interface ITask extends ITaskListElement {
public abstract boolean participatesInTaskHandles();
public abstract boolean isPastReminder();
-}
-
-//public abstract String getRemoteContextPath();
-//
-// public abstract void setRemoteContextPath(String path);
+} \ No newline at end of file
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ITaskQuery.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ITaskQuery.java
index 5e42bc285..bfe1b7e35 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ITaskQuery.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ITaskQuery.java
@@ -23,6 +23,10 @@ public interface ITaskQuery extends ITaskListElement{
public void setQueryUrl(String query);
+ public String getRepositoryUrl();
+
+ public void setRepositoryUrl(String url);
+
public List<IQueryHit> getHits();
public int getMaxHits();
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/MylarTaskListPlugin.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/MylarTaskListPlugin.java
index 0a5ac6cbd..15567f1e8 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/MylarTaskListPlugin.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/MylarTaskListPlugin.java
@@ -279,6 +279,9 @@ public class MylarTaskListPlugin extends AbstractUIPlugin implements IStartup {
}
}
+ /**
+ * Startup order is critical
+ */
public void earlyStartup() {
final IWorkbench workbench = PlatformUI.getWorkbench();
workbench.getDisplay().asyncExec(new Runnable() {
@@ -286,6 +289,8 @@ public class MylarTaskListPlugin extends AbstractUIPlugin implements IStartup {
try {
TaskListExtensionReader.initExtensions(taskListWriter);
+ taskRepositoryManager.readRepositories();
+
taskListManager.addListener(CONTEXT_TASK_ACTIVITY_LISTENER);
taskListManager.addListener(taskListSaveManager);
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/DelegatingLocalTaskExternalizer.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/DelegatingLocalTaskExternalizer.java
index 0ace34b71..71669d473 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/DelegatingLocalTaskExternalizer.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/DelegatingLocalTaskExternalizer.java
@@ -52,6 +52,8 @@ public class DelegatingLocalTaskExternalizer implements ITaskListExternalizer {
public static final String HANDLE = "Handle";
+ public static final String REPOSITORY_URL = "RepositoryUrl";
+
public static final String TAG_CATEGORY = "Category";
public static final String TAG_TASK = "Task";
@@ -155,9 +157,14 @@ public class DelegatingLocalTaskExternalizer implements ITaskListExternalizer {
} else {
node.setAttribute(ACTIVE, FALSE);
}
- node.setAttribute(BUGZILLA, FALSE); // TODO: this is not great
+ node.setAttribute(BUGZILLA, FALSE); // TODO: get rid of this
- node.setAttribute(ISSUEURL, task.getUrl());
+ if (task.getUrl() != null) {
+ node.setAttribute(ISSUEURL, task.getUrl());
+ }
+ if (task.getRepositoryUrl() != null) {
+ node.setAttribute(REPOSITORY_URL, task.getRepositoryUrl());
+ }
node.setAttribute(NOTES, task.getNotes());
node.setAttribute(ELAPSED, "" + task.getElapsedTime());
node.setAttribute(ESTIMATED, "" + task.getEstimateTimeHours());
@@ -394,6 +401,8 @@ public class DelegatingLocalTaskExternalizer implements ITaskListExternalizer {
node.setAttribute(NAME, query.getDescription(false));
node.setAttribute(MAX_HITS, query.getMaxHits() + "");
node.setAttribute(QUERY_STRING, query.getQueryUrl());
+ node.setAttribute(REPOSITORY_URL, query.getRepositoryUrl());
+
for (IQueryHit hit : query.getHits()) {
try {
Element element = null;
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/Task.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/Task.java
index 72a9dc800..5ed66a6b7 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/Task.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/Task.java
@@ -43,6 +43,8 @@ public class Task implements ITask {
private boolean active = false;
protected String handle = "-1";
+
+ protected String repositoryUrl = null;
private boolean category = false;
@@ -73,7 +75,7 @@ public class Task implements ITask {
private Date creationDate = null;
private Date reminderDate = null;
-
+
/**
* @return null if root
*/
@@ -86,22 +88,9 @@ public class Task implements ITask {
return label;
}
-// public String getRemoteContextPath() {
-// return contextPath;
-// }
-//
-// public void setRemoteContextPath(String path) {
-// if (path.startsWith(".mylar")) { // HACK: remove this
-// this.contextPath = path.substring(path.lastIndexOf('/') + 1, path.length());
-// } else if (!path.equals("")) {
-// this.contextPath = path;
-// }
-// }
-
public Task(String handle, String label, boolean newTask) {
this.handle = handle;
this.label = label;
-// this.contextPath = handle;
if (newTask) {
creationDate = new Date();
}
@@ -122,44 +111,14 @@ public class Task implements ITask {
public void setParent(ITask parent) {
this.parent = parent;
}
-
- public Object getAdapter(Class adapter) {
- return null;
- }
/**
* Package visible in order to prevent sets that don't update the index.
*/
public void setActive(boolean active) {
this.active = active;
-// if (active && !isStalled) {
-// lastActivatedDate = new Date();
-// } else {
-// calculateElapsedTime(isStalled);
-// lastActivatedDate = null;
-// }
}
-// private void calculateElapsedTime(boolean isStalled) {
-// if (lastActivatedDate != null) {
-// timeActive += new Date().getTime() - lastActivatedDate.getTime();
-// if (isStalled) {
-// timeActive -= TaskListManager.INACTIVITY_TIME_MILLIS;
-// }
-// if (isActive()) {
-// lastActivatedDate = new Date();
-// } else {
-// lastActivatedDate = null;
-// }
-// }
-//
-// if (timeActive < 0) {
-// MylarPlugin.fail(new RuntimeException("Elapsed time was less than zero for: " + getDescription(true)), "",
-// false);
-// timeActive = 0;
-// }
-// }
-
public boolean isActive() {
return active;
}
@@ -183,16 +142,13 @@ public class Task implements ITask {
IWorkbenchPage page = MylarTaskListPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow()
.getActivePage();
- // if we couldn't get a page, get out
if (page == null) {
return;
}
IEditorInput input = new TaskEditorInput(this);
try {
- // try to open an editor on the input task
page.openEditor(input, MylarTaskListPrefConstants.TASK_EDITOR_ID);
-
} catch (PartInitException ex) {
MylarStatusHandler.log(ex, "open failed");
}
@@ -499,65 +455,12 @@ public class Task implements ITask {
}
return false;
}
-}
-/**
-// * Clients should use getElapsedTime() and perform their own formatting
-// *
-// * @deprecated
-// */
-//public String getElapsedTimeForDisplay() {
-// calculateElapsedTime(false);
-// return DateUtil.getFormattedDuration(timeActive);
-//}
-
-// private String getReminderDateForDisplay() {
-// if (reminderDate != null) {
-//
-// String f = "EEE, yyyy-MM-dd";
-// SimpleDateFormat format = new SimpleDateFormat(f, Locale.ENGLISH);
-// return format.format(reminderDate);
-// } else {
-// return "";
-// }
-// }
-
-// /**
-// * Clients should use getElapsedTime() and perform
-// * their own formatting
-// * @deprecated
-// */
-// public String getEstimateTimeForDisplay() {
-// return estimatedTimeHours / 10 + " Hours";
-// }
-
-//public void setReminderDate(String date) {
-//if (!date.equals("")) {
-// String formatString = "yyyy-MM-dd HH:mm:ss.S z";
-// SimpleDateFormat format = new SimpleDateFormat(formatString, Locale.ENGLISH);
-// try {
-// reminderDate = format.parse(date);
-// } catch (ParseException e) {
-// MylarPlugin.log(e, "Could not parse end date");
-// reminderDate = null;
-// }
-//} else {
-// reminderDate = null;
-//}
-//}
-
-// public void setCreationDate(String date) {
-// if (!date.equals("")) {
-// String formatString = "yyyy-MM-dd HH:mm:ss.S z";
-// SimpleDateFormat format = new SimpleDateFormat(formatString,
-// Locale.ENGLISH);
-// try {
-// creationDate = format.parse(date);
-// } catch (ParseException e) {
-// MylarPlugin.log(e, "Could not parse end date");
-// creationDate = null;
-// }
-// } else {
-//
-// }
-// }
+ public String getRepositoryUrl() {
+ return repositoryUrl;
+ }
+
+ public void setRepositoryUrl(String repositoryUrl) {
+ this.repositoryUrl = repositoryUrl;
+ }
+}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/TaskListManager.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/TaskListManager.java
index 72f4799bc..052b5a9ad 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/TaskListManager.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/internal/TaskListManager.java
@@ -248,7 +248,7 @@ public class TaskListManager {
public void markComplete(ITask task, boolean complete) {
task.setCompleted(complete);
- for (ITaskActivityListener listener : new ArrayList<ITaskActivityListener>(listeners)) {
+ for (ITaskActivityListener listener : new ArrayList<ITaskActivityListener>(listeners)) {
listener.tasklistModified(); // to ensure comleted filter notices
}
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/repositories/TaskRepository.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/repositories/TaskRepository.java
index 86bd4ddb6..ce4a3fd10 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/repositories/TaskRepository.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/repositories/TaskRepository.java
@@ -35,7 +35,7 @@ public class TaskRepository {
private String kind;
- public TaskRepository(URL serverUrl, String kind) {
+ public TaskRepository(String kind, URL serverUrl) {
this.serverUrl = serverUrl;
this.kind = kind;
}
@@ -45,20 +45,34 @@ public class TaskRepository {
}
@SuppressWarnings("unchecked")
- public Map<String, String> getAuthorizationCredentials() {
+ public Map<String, String> getCredentials() {
return Platform.getAuthorizationInfo(serverUrl, AUTH_REALM, AUTH_SCHEME);
}
+ public boolean hasCredentials() {
+ String username = getUserName();
+ String password = getPassword();
+ return username != null && !username.equals("") && password != null && !password.equals("");
+ }
+
@SuppressWarnings("unchecked")
public String getUserName() {
Map<String, String> map = Platform.getAuthorizationInfo(serverUrl, AUTH_REALM, AUTH_SCHEME);
- return map.get(AUTH_USERNAME);
+ if (map != null && map.containsKey(AUTH_USERNAME)) {
+ return map.get(AUTH_USERNAME);
+ } else {
+ return null;
+ }
}
-
+
@SuppressWarnings("unchecked")
public String getPassword() {
Map<String, String> map = Platform.getAuthorizationInfo(serverUrl, AUTH_REALM, AUTH_SCHEME);
- return map.get(AUTH_PASSWORD);
+ if (map != null && map.containsKey(AUTH_PASSWORD)) {
+ return map.get(AUTH_PASSWORD);
+ } else {
+ return null;
+ }
}
@SuppressWarnings("unchecked")
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/repositories/TaskRepositoryManager.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/repositories/TaskRepositoryManager.java
index 6ffbd2397..b7845b6b9 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/repositories/TaskRepositoryManager.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/repositories/TaskRepositoryManager.java
@@ -14,6 +14,7 @@ package org.eclipse.mylar.tasklist.repositories;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -36,9 +37,13 @@ public class TaskRepositoryManager {
private Map<String, Set<TaskRepository>> repositoryMap = new HashMap<String, Set<TaskRepository>>();
private Set<ITaskRepositoryListener> listeners = new HashSet<ITaskRepositoryListener>();
+
+ public static final String HANDLE_DELIM = "-";
+
+ public static final String MISSING_REPOSITORY_HANDLE = "Bugzilla" + HANDLE_DELIM;
private static final String STORE_DELIM = ", ";
-
+
public List<ITaskRepositoryClient> getRepositoryClients() {
return repositoryClients;
}
@@ -47,7 +52,6 @@ public class TaskRepositoryManager {
if (!repositoryClients.contains(repositoryClient)) {
repositoryClients.add(repositoryClient);
}
- readRepositories();
}
public void removeRepositoryClient(ITaskRepositoryClient repositoryClient) {
@@ -55,10 +59,12 @@ public class TaskRepositoryManager {
}
public void addRepository(TaskRepository repository) {
- Set<TaskRepository> repositories = repositoryMap.get(repository.getKind());
- if (repositories == null) {
+ Set<TaskRepository> repositories;
+ if (!repositoryMap.containsKey(repository.getKind())) {
repositories = new HashSet<TaskRepository>();
repositoryMap.put(repository.getKind(), repositories);
+ } else {
+ repositories = repositoryMap.get(repository.getKind());
}
repositories.add(repository);
saveRepositories();
@@ -80,8 +86,54 @@ public class TaskRepositoryManager {
listeners.remove(listener);
}
+ public TaskRepository getRepository(String kind, String urlString) {
+// if (!repositoriesRead) readRepositories();
+
+ if (repositoryMap.containsKey(kind)) {
+ for (TaskRepository repository : repositoryMap.get(kind)) {
+ if (repository.getServerUrl().toExternalForm().equals(urlString)) {
+ return repository;
+ }
+ }
+ }
+ return null;
+ }
+
+ public Set<TaskRepository> getRepositories(String kind) {
+// if (!repositoriesRead) readRepositories();
+
+ if (repositoryMap.containsKey(kind)) {
+ return repositoryMap.get(kind);
+ } else {
+ return Collections.emptySet();
+ }
+ }
+
+ public List<TaskRepository> getAllRepositories() {
+// if (!repositoriesRead) readRepositories();
+
+ List<TaskRepository> repositories = new ArrayList<TaskRepository>();
+ for (ITaskRepositoryClient repositoryClient : repositoryClients) {
+ if (repositoryMap.containsKey(repositoryClient.getKind())) {
+ repositories.addAll(repositoryMap.get(repositoryClient.getKind()));
+ }
+ }
+ return repositories;
+ }
+
+ @Deprecated
+ public TaskRepository getDefaultRepository(String kind) {
+ // HACK: returns first repository found
+ if (repositoryMap.containsKey(kind)) {
+ for (TaskRepository repository : repositoryMap.get(kind)) {
+ return repository;
+ }
+ }
+ return null;
+ }
+
public Map<String, Set<TaskRepository>> readRepositories() {
- repositoryMap.clear();
+ System.err.println(">>> " + repositoryClients);
for (ITaskRepositoryClient repositoryClient : repositoryClients) {
String read = MylarTaskListPlugin.getPrefs().getString(PREF_REPOSITORIES + repositoryClient.getKind());
Set<TaskRepository> repositories = new HashSet<TaskRepository>();
@@ -92,7 +144,7 @@ public class TaskRepositoryManager {
try {
URL url = new URL(urlString);
repositoryMap.put(repositoryClient.getKind(), repositories);
- repositories.add(new TaskRepository(url, repositoryClient.getKind()));
+ repositories.add(new TaskRepository(repositoryClient.getKind(), url));
} catch (MalformedURLException e) {
MylarStatusHandler.fail(e, "could not restore URL: " + urlString, false);
}
@@ -102,6 +154,7 @@ public class TaskRepositoryManager {
for (ITaskRepositoryListener listener : listeners) {
listener.repositorySetUpdated();
}
+ System.err.println("> read repositories: " + repositoryMap);
return repositoryMap;
}
@@ -122,18 +175,46 @@ public class TaskRepositoryManager {
}
}
- public List<TaskRepository> getAllRepositories() {
- List<TaskRepository> repositories = new ArrayList<TaskRepository>();
- for (ITaskRepositoryClient repositoryClient : repositoryClients) {
- if (repositoryMap.containsKey(repositoryClient.getKind())) {
- repositories.addAll(repositoryMap.get(repositoryClient.getKind()));
- }
- }
- return repositories;
- }
-
public void clearRepositories() {
repositoryMap.clear();
saveRepositories();
}
+
+ public static String getRepositoryUrl(String handle) {
+ int index = handle.lastIndexOf(HANDLE_DELIM);
+ if (index != -1) {
+ return handle.substring(0, index);
+ }
+ return null;
+ }
+
+ public static String getTaskId(String taskHandle) {
+ int index = taskHandle.lastIndexOf(HANDLE_DELIM);
+ if (index != -1) {
+ String id = taskHandle.substring(index + 1);
+ return id;
+ }
+ return null;
+ }
+
+ public static int getTaskIdAsInt(String taskHandle) {
+ String idString = getTaskId(taskHandle);
+ if (idString != null) {
+ return Integer.parseInt(idString);
+ } else {
+ return -1;
+ }
+ }
+
+ public static String getHandle(String repositoryUrl, String taskId) {
+ if (repositoryUrl == null) {
+ return MISSING_REPOSITORY_HANDLE + taskId;
+ } else {
+ return repositoryUrl + HANDLE_DELIM + taskId;
+ }
+ }
+
+ public static String getHandle(String repositoryUrl, int taskId) {
+ return getHandle(repositoryUrl, "" + taskId);
+ }
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/MylarTaskEditor.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/MylarTaskEditor.java
index 62cb2e502..9e0f5ad38 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/MylarTaskEditor.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/MylarTaskEditor.java
@@ -253,8 +253,9 @@ public class MylarTaskEditor extends MultiPageEditorPart {
}
}
- public void updatePartName() {
- firePropertyChange(PROP_DIRTY);
+ public void updatePartName() {
+ this.setPartName(taskEditorInput.getTask().getDescription(true));
+ firePropertyChange(PROP_DIRTY);
return;
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/TaskInfoEditor.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/TaskInfoEditor.java
index 77158bb9c..672d976d6 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/TaskInfoEditor.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/TaskInfoEditor.java
@@ -92,15 +92,19 @@ public class TaskInfoEditor extends EditorPart {
private static final String pasteActionDefId = "org.eclipse.ui.edit.paste";
private Button removeReminder;
-
+
+ private Button completedCheckbox;
+
private Text pathText;
+ private Text endDate;
+
private ScrolledForm form;
private Text description;
private Text issueReportURL;
-
+
private Combo priorityCombo;
private Text notes;
@@ -113,10 +117,12 @@ public class TaskInfoEditor extends EditorPart {
private ITaskActivityListener TASK_LIST_LISTENER = new ITaskActivityListener() {
public void taskActivated(ITask activeTask) {
-// if (task != null && !browse.isDisposed()
-// && activeTask.getHandleIdentifier().equals(task.getHandleIdentifier())) {
-// browse.setEnabled(false);
-// }
+ // if (task != null && !browse.isDisposed()
+ // &&
+ // activeTask.getHandleIdentifier().equals(task.getHandleIdentifier()))
+ // {
+ // browse.setEnabled(false);
+ // }
}
public void tasksActivated(List<ITask> tasks) {
@@ -126,10 +132,12 @@ public class TaskInfoEditor extends EditorPart {
}
public void taskDeactivated(ITask deactiveTask) {
-// if (task != null && !browse.isDisposed()
-// && deactiveTask.getHandleIdentifier().equals(task.getHandleIdentifier())) {
-// browse.setEnabled(true);
-// }
+ // if (task != null && !browse.isDisposed()
+ // &&
+ // deactiveTask.getHandleIdentifier().equals(task.getHandleIdentifier()))
+ // {
+ // browse.setEnabled(true);
+ // }
}
public void tasklistRead() {
@@ -137,38 +145,60 @@ public class TaskInfoEditor extends EditorPart {
}
public void taskChanged(ITask updateTask) {
- if (updateTask != null && updateTask.getHandleIdentifier().equals(task.getHandleIdentifier())) {
+ if (updateTask != null
+ && updateTask.getHandleIdentifier().equals(
+ task.getHandleIdentifier())) {
if (!description.isDisposed()) {
description.setText(updateTask.getDescription(false));
- TaskInfoEditor.this.setPartName(updateTask.getDescription(true));
+ TaskInfoEditor.this.setPartName(updateTask
+ .getDescription(true));
parentEditor.updatePartName();
}
-// if (!pathText.isDisposed() && !updateTask.getContextPath().equals(task.getContextPath())) {
-// pathText.setText(MylarPlugin.getDefault().getDataDirectory() + '/' + task.getContextPath());
-// }
+ if (!priorityCombo.isDisposed()) {
+ int selectionIndex = priorityCombo.indexOf(updateTask
+ .getPriority());
+ priorityCombo.select(selectionIndex);
+ }
+ if (!completedCheckbox.isDisposed()) {
+ completedCheckbox.setSelection(updateTask.isCompleted());
+ }
+
+ if (updateTask.isCompleted() && !endDate.isDisposed()) {
+ endDate.setText(getTaskDateString(updateTask));
+ } else if (!updateTask.isCompleted() && !endDate.isDisposed()) {
+ endDate.setText("");
+ }
+
}
}
public void tasklistModified() {
// TODO Auto-generated method stub
-
+
}
};
public TaskInfoEditor() {
super();
- cutAction = new RetargetAction(ActionFactory.CUT.getId(), WorkbenchMessages.Workbench_cut);
+ cutAction = new RetargetAction(ActionFactory.CUT.getId(),
+ WorkbenchMessages.Workbench_cut);
cutAction.setToolTipText(WorkbenchMessages.Workbench_cutToolTip);
- cutAction.setImageDescriptor(WorkbenchImages.getImageDescriptor(ISharedImages.IMG_TOOL_CUT));
- cutAction.setHoverImageDescriptor(WorkbenchImages.getImageDescriptor(ISharedImages.IMG_TOOL_CUT));
- cutAction.setDisabledImageDescriptor(WorkbenchImages.getImageDescriptor(ISharedImages.IMG_TOOL_CUT_DISABLED));
+ cutAction.setImageDescriptor(WorkbenchImages
+ .getImageDescriptor(ISharedImages.IMG_TOOL_CUT));
+ cutAction.setHoverImageDescriptor(WorkbenchImages
+ .getImageDescriptor(ISharedImages.IMG_TOOL_CUT));
+ cutAction.setDisabledImageDescriptor(WorkbenchImages
+ .getImageDescriptor(ISharedImages.IMG_TOOL_CUT_DISABLED));
cutAction.setAccelerator(SWT.CTRL | 'x');
cutAction.setActionDefinitionId(cutActionDefId);
- pasteAction = new RetargetAction(ActionFactory.PASTE.getId(), WorkbenchMessages.Workbench_paste);
+ pasteAction = new RetargetAction(ActionFactory.PASTE.getId(),
+ WorkbenchMessages.Workbench_paste);
pasteAction.setToolTipText(WorkbenchMessages.Workbench_pasteToolTip);
- pasteAction.setImageDescriptor(WorkbenchImages.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE));
- pasteAction.setHoverImageDescriptor(WorkbenchImages.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE));
+ pasteAction.setImageDescriptor(WorkbenchImages
+ .getImageDescriptor(ISharedImages.IMG_TOOL_PASTE));
+ pasteAction.setHoverImageDescriptor(WorkbenchImages
+ .getImageDescriptor(ISharedImages.IMG_TOOL_PASTE));
pasteAction.setDisabledImageDescriptor(WorkbenchImages
.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE_DISABLED));
pasteAction.setAccelerator(SWT.CTRL | 'v');
@@ -176,13 +206,17 @@ public class TaskInfoEditor extends EditorPart {
copyAction = new TaskEditorCopyAction();
copyAction.setText(WorkbenchMessages.Workbench_copy);
- copyAction.setImageDescriptor(WorkbenchImages.getImageDescriptor(ISharedImages.IMG_TOOL_COPY));
- copyAction.setHoverImageDescriptor(WorkbenchImages.getImageDescriptor(ISharedImages.IMG_TOOL_COPY));
- copyAction.setDisabledImageDescriptor(WorkbenchImages.getImageDescriptor(ISharedImages.IMG_TOOL_COPY_DISABLED));
+ copyAction.setImageDescriptor(WorkbenchImages
+ .getImageDescriptor(ISharedImages.IMG_TOOL_COPY));
+ copyAction.setHoverImageDescriptor(WorkbenchImages
+ .getImageDescriptor(ISharedImages.IMG_TOOL_COPY));
+ copyAction.setDisabledImageDescriptor(WorkbenchImages
+ .getImageDescriptor(ISharedImages.IMG_TOOL_COPY_DISABLED));
copyAction.setAccelerator(SWT.CTRL | 'c');
copyAction.setEnabled(false);
- MylarTaskListPlugin.getTaskListManager().addListener(TASK_LIST_LISTENER);
+ MylarTaskListPlugin.getTaskListManager()
+ .addListener(TASK_LIST_LISTENER);
}
@Override
@@ -198,10 +232,15 @@ public class TaskInfoEditor extends EditorPart {
} else {
task.setReminderDate(null);
}
- task.setPriority(priorityCombo.getItem(priorityCombo.getSelectionIndex()));
-
+ task.setPriority(priorityCombo.getItem(priorityCombo
+ .getSelectionIndex()));
+
+ MylarTaskListPlugin.getTaskListManager().markComplete(task,
+ completedCheckbox.getSelection());
+
refreshTaskListView(task);
MylarTaskListPlugin.getTaskListManager().notifyTaskChanged(task);
+
markDirty(false);
}
@@ -212,9 +251,11 @@ public class TaskInfoEditor extends EditorPart {
@SuppressWarnings("deprecation")
@Override
- public void init(IEditorSite site, IEditorInput input) throws PartInitException {
+ public void init(IEditorSite site, IEditorInput input)
+ throws PartInitException {
if (!(input instanceof TaskEditorInput)) {
- throw new PartInitException("Invalid Input: Must be TaskEditorInput");
+ throw new PartInitException(
+ "Invalid Input: Must be TaskEditorInput");
}
setSite(site);
setInput(input);
@@ -277,7 +318,8 @@ public class TaskInfoEditor extends EditorPart {
task = taskEditorInput.getTask();
if (task == null) {
- MessageDialog.openError(parent.getShell(), "No such task", "No task exists with this id");
+ MessageDialog.openError(parent.getShell(), "No such task",
+ "No task exists with this id");
return null;
}
@@ -294,7 +336,8 @@ public class TaskInfoEditor extends EditorPart {
}
private void createOverviewSection(Composite parent, FormToolkit toolkit) {
- Section section = toolkit.createSection(parent, ExpandableComposite.TITLE_BAR);
+ Section section = toolkit.createSection(parent,
+ ExpandableComposite.TITLE_BAR);
section.setText(DESCRIPTION_OVERVIEW);
section.setLayout(new TableWrapLayout());
section.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
@@ -317,7 +360,8 @@ public class TaskInfoEditor extends EditorPart {
Label l = toolkit.createLabel(container, "Description:");
l.setForeground(toolkit.getColors().getColor(FormColors.TITLE));
- description = toolkit.createText(container, task.getDescription(true), SWT.BORDER);
+ description = toolkit.createText(container, task.getDescription(true),
+ SWT.BORDER);
TableWrapData td = new TableWrapData(TableWrapData.FILL_GRAB);
// td.colspan = 2;
description.setLayoutData(td);
@@ -333,8 +377,10 @@ public class TaskInfoEditor extends EditorPart {
Label urlLabel = toolkit.createLabel(container, "Web Link:");
urlLabel.setForeground(toolkit.getColors().getColor(FormColors.TITLE));
- issueReportURL = toolkit.createText(container, task.getUrl(), SWT.BORDER);
- issueReportURL.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
+ issueReportURL = toolkit.createText(container, task.getUrl(),
+ SWT.BORDER);
+ issueReportURL
+ .setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
// issueReportURL.setForeground(HYPERLINK);
if (!task.isLocal()) {
@@ -345,42 +391,13 @@ public class TaskInfoEditor extends EditorPart {
markDirty(true);
}
});
- }
-
- Label priorityLabel = toolkit.createLabel(container, "Priority:");
- priorityLabel.setForeground(toolkit.getColors().getColor(FormColors.TITLE));
- Composite priorityComposite = toolkit.createComposite(container);
-
- GridLayout gridLayout = new GridLayout();
- gridLayout.numColumns = 1;
- gridLayout.horizontalSpacing = 0;
- gridLayout.verticalSpacing = 0;
- gridLayout.marginWidth = 0;
- gridLayout.marginHeight = 0;
- priorityComposite.setLayout(gridLayout);
- priorityCombo = new Combo(priorityComposite, SWT.DROP_DOWN);
-
- // Populate the combo box with priority levels
- for(String priorityLevel : TaskListView.PRIORITY_LEVELS) {
- priorityCombo.add(priorityLevel);
- }
-
- int selectionIndex = priorityCombo.indexOf(task.getPriority());
- priorityCombo.select(selectionIndex);
-
- if (!task.isLocal()) {
- priorityCombo.setEnabled(false);
- } else {
- priorityCombo.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- TaskInfoEditor.this.markDirty(true);
- }
- });
}
}
- private void createDocumentationSection(Composite parent, FormToolkit toolkit) {
- Section section = toolkit.createSection(parent, ExpandableComposite.TITLE_BAR);
+ private void createDocumentationSection(Composite parent,
+ FormToolkit toolkit) {
+ Section section = toolkit.createSection(parent,
+ ExpandableComposite.TITLE_BAR);
section.setText("Documentation");
section.setLayout(new TableWrapLayout());
section.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
@@ -399,7 +416,8 @@ public class TaskInfoEditor extends EditorPart {
layout.numColumns = 1;
container.setLayout(layout);
- notes = toolkit.createText(container, task.getNotes(), SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
+ notes = toolkit.createText(container, task.getNotes(), SWT.BORDER
+ | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
TableWrapData tablewrap = new TableWrapData(TableWrapData.FILL_GRAB);
tablewrap.heightHint = 200;
tablewrap.grabVertical = true;
@@ -414,10 +432,12 @@ public class TaskInfoEditor extends EditorPart {
}
private void createPlanningSection(Composite parent, FormToolkit toolkit) {
- Section section = toolkit.createSection(parent, ExpandableComposite.TITLE_BAR);
+
+ Section section = toolkit.createSection(parent,
+ ExpandableComposite.TITLE_BAR);
section.setText("Planning");
- section.setLayout(new TableWrapLayout());
section.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
+ section.setLayout(new TableWrapLayout());
section.addExpansionListener(new IExpansionListener() {
public void expansionStateChanging(ExpansionEvent e) {
form.reflow(true);
@@ -427,22 +447,61 @@ public class TaskInfoEditor extends EditorPart {
form.reflow(true);
}
});
- Composite container = toolkit.createComposite(section);
- section.setClient(container);
+
+ Composite sectionClient = toolkit.createComposite(section);
+
TableWrapLayout layout = new TableWrapLayout();
- layout.numColumns = 3;
- container.setLayout(layout);
+ layout.numColumns = 2;
+
+ sectionClient.setLayout(layout);
+ sectionClient.setLayoutData(TableWrapData.FILL);
+
+ section.setClient(sectionClient);
+
+ // /////// Priority
- Label label = toolkit.createLabel(container, "Reminder:");
+ Composite priorityComposite = toolkit.createComposite(sectionClient);
+ priorityComposite.setLayout(new GridLayout(2, false));
+
+ Label priorityLabel = toolkit.createLabel(priorityComposite,
+ "Priority:");
+ priorityLabel.setForeground(toolkit.getColors().getColor(
+ FormColors.TITLE));
+
+ priorityCombo = new Combo(priorityComposite, SWT.DROP_DOWN);
+
+ // Populate the combo box with priority levels
+ for (String priorityLevel : TaskListView.PRIORITY_LEVELS) {
+ priorityCombo.add(priorityLevel);
+ }
+
+ int selectionIndex = priorityCombo.indexOf(task.getPriority());
+ priorityCombo.select(selectionIndex);
+
+ if (!task.isLocal()) {
+ priorityCombo.setEnabled(false);
+ } else {
+ priorityCombo.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ TaskInfoEditor.this.markDirty(true);
+ }
+ });
+ }
+
+ // Reminder
+ Composite reminderComposite = toolkit.createComposite(sectionClient);
+ reminderComposite.setLayout(new GridLayout(3, false));
+ Label label = toolkit.createLabel(reminderComposite, "Reminder:");
label.setForeground(toolkit.getColors().getColor(FormColors.TITLE));
- datePicker = new DatePicker(container, SWT.NULL);
+ datePicker = new DatePicker(reminderComposite, SWT.NULL);
Calendar calendar = Calendar.getInstance();
if (task.getReminderDate() != null) {
calendar.setTime(task.getReminderDate());
datePicker.setDate(calendar);
}
- datePicker.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
+ datePicker.setBackground(Display.getDefault().getSystemColor(
+ SWT.COLOR_WHITE));
datePicker.addPickerSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent arg0) {
TaskInfoEditor.this.markDirty(true);
@@ -453,7 +512,8 @@ public class TaskInfoEditor extends EditorPart {
}
});
- removeReminder = toolkit.createButton(container, "Clear", SWT.PUSH | SWT.CENTER);
+ removeReminder = toolkit.createButton(reminderComposite, "Clear",
+ SWT.PUSH | SWT.CENTER);
if (task.isActive()) {
removeReminder.setEnabled(false);
} else {
@@ -466,21 +526,21 @@ public class TaskInfoEditor extends EditorPart {
datePicker.setDateText("");
TaskInfoEditor.this.markDirty(true);
}
- });
-
- label = toolkit.createLabel(container, "Estimated time:");
- label.setForeground(toolkit.getColors().getColor(FormColors.TITLE));
+ });
- Composite estimatedComposite = toolkit.createComposite(container);
+ // ///////////////
+ Composite estimatedComposite = toolkit.createComposite(sectionClient);
GridLayout gridLayout = new GridLayout();
- gridLayout.numColumns = 2;
+ gridLayout.numColumns = 3;
gridLayout.horizontalSpacing = 2;
gridLayout.verticalSpacing = 2;
gridLayout.marginWidth = 0;
gridLayout.marginHeight = 2;
gridLayout.makeColumnsEqualWidth = false;
estimatedComposite.setLayout(gridLayout);
+ label = toolkit.createLabel(estimatedComposite, "Estimated time:");
+ label.setForeground(toolkit.getColors().getColor(FormColors.TITLE));
estimated = new Spinner(estimatedComposite, SWT.BORDER);
estimated.setSelection(task.getEstimateTimeHours());
@@ -506,68 +566,119 @@ public class TaskInfoEditor extends EditorPart {
GridData hoursLabelGridData = new org.eclipse.swt.layout.GridData();
hoursLabelGridData.horizontalAlignment = org.eclipse.swt.layout.GridData.END;
hoursLabelGridData.verticalAlignment = org.eclipse.swt.layout.GridData.FILL;
- label.setData(hoursLabelGridData);
-
- // Temp hack because couldn't get the estimatedComposite above to span
- // two columns
- label = toolkit.createLabel(container, " ");
+ label.setLayoutData(hoursLabelGridData);
- label = toolkit.createLabel(container, "Elapsed time:");
+ Composite elapsedTimeComposite = toolkit.createComposite(sectionClient);
+ TableWrapLayout elapsedLayout = new TableWrapLayout();
+ gridLayout.numColumns = 2;
+ elapsedTimeComposite.setLayout(elapsedLayout);
+ label = toolkit.createLabel(elapsedTimeComposite, "Elapsed time:");
label.setForeground(toolkit.getColors().getColor(FormColors.TITLE));
-
+
String elapsedTimeString = "0";
try {
- elapsedTimeString = DateUtil.getFormattedDuration(task.getElapsedTime(), true);
+ elapsedTimeString = DateUtil.getFormattedDuration(task
+ .getElapsedTime(), true);
+ if (elapsedTimeString.equals(""))
+ elapsedTimeString = "0";
} catch (RuntimeException e) {
MylarStatusHandler.fail(e, "Could not format reminder date", true);
}
- Text reminder = toolkit.createText(container, elapsedTimeString, SWT.BORDER);
-
+
+ Text reminderText = toolkit.createText(elapsedTimeComposite,
+ elapsedTimeString, SWT.BORDER);
+
TableWrapData td = new TableWrapData(TableWrapData.FILL_GRAB);
td.grabHorizontal = true;
- td.colspan = 2;
- reminder.setLayoutData(td);
- reminder.setEditable(false);
-
- label = toolkit.createLabel(container, "Creation date:");
+ reminderText.setLayoutData(td);
+ reminderText.setEditable(false);
+
+ Composite creationDateComposite = toolkit
+ .createComposite(sectionClient);
+ TableWrapLayout creationLayout = new TableWrapLayout();
+ creationLayout.numColumns = 2;
+ creationDateComposite.setLayout(creationLayout);
+ label = toolkit.createLabel(creationDateComposite, "Creation date:");
label.setForeground(toolkit.getColors().getColor(FormColors.TITLE));
String creationDateString = "";
try {
- creationDateString = DateFormat.getDateInstance(DateFormat.LONG).format(task.getCreationDate());
+ creationDateString = DateFormat.getDateInstance(DateFormat.LONG)
+ .format(task.getCreationDate());
} catch (RuntimeException e) {
MylarStatusHandler.fail(e, "Could not format creation date", true);
}
- Text creationDate = toolkit.createText(container, creationDateString, SWT.BORDER);
+ Text creationDate = toolkit.createText(creationDateComposite,
+ creationDateString, SWT.BORDER);
td = new TableWrapData(TableWrapData.FILL_GRAB);
td.grabHorizontal = true;
- td.colspan = 2;
creationDate.setLayoutData(td);
creationDate.setEditable(false);
-// creationDate.setEnabled(false);
+ creationDate.setEnabled(false);
- label = toolkit.createLabel(container, "Completion date:");
+ Composite completedComposite = toolkit.createComposite(sectionClient);
+ completedComposite.setLayout(new GridLayout(2, false));
+ label = toolkit.createLabel(completedComposite, "Completed:");
label.setForeground(toolkit.getColors().getColor(FormColors.TITLE));
- String completionDateString = "";
- if (task.getCompletionDate() != null) {
- try {
- completionDateString = DateFormat.getDateInstance(DateFormat.LONG).format(task.getCompletionDate());
- } catch (RuntimeException e) {
- MylarStatusHandler.fail(e, "Could not format date", true);
+ completedCheckbox = toolkit.createButton(completedComposite, "",
+ SWT.CHECK);
+ completedCheckbox.setSelection(task.isCompleted());
+
+ completedCheckbox.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ if (!completedCheckbox.getSelection()) {
+ if (!endDate.isDisposed()) {
+ endDate.setText("");
+ }
+ } else {
+ if (!endDate.isDisposed()) {
+ endDate.setText(getTaskDateString(task));
+ }
+ }
+ TaskInfoEditor.this.markDirty(true);
}
+ });
+
+ Composite completionDateComposite = toolkit
+ .createComposite(sectionClient);
+ TableWrapLayout completionLayout = new TableWrapLayout();
+ completionLayout.numColumns = 2;
+ completionDateComposite.setLayout(completionLayout);
+ label = toolkit
+ .createLabel(completionDateComposite, "Completion date:");
+ label.setForeground(toolkit.getColors().getColor(FormColors.TITLE));
+ String completionDateString = "";
+ if (task.isCompleted()) {
+ completionDateString = getTaskDateString(task);
}
- Text endDate = toolkit.createText(container, completionDateString, SWT.BORDER);
+ endDate = toolkit.createText(completionDateComposite,
+ completionDateString, SWT.BORDER);
td = new TableWrapData(TableWrapData.FILL_GRAB);
td.grabHorizontal = true;
- td.colspan = 2;
endDate.setLayoutData(td);
endDate.setEditable(false);
-// endDate.setEnabled(false);
+ endDate.setEnabled(false);
+
+ }
+
+ private String getTaskDateString(ITask task) {
+
+ String completionDateString = "";
+ try {
+ completionDateString = DateFormat.getDateInstance(DateFormat.LONG)
+ .format(task.getCompletionDate());
+ } catch (RuntimeException e) {
+ MylarStatusHandler.fail(e, "Could not format date", true);
+ return completionDateString;
+ }
+ return completionDateString;
}
private void createDetailsSection(Composite parent, FormToolkit toolkit) {
- Section section = toolkit.createSection(parent, ExpandableComposite.TITLE_BAR | Section.TWISTIE);
+ Section section = toolkit.createSection(parent,
+ ExpandableComposite.TITLE_BAR | Section.TWISTIE);
section.setText("Resources");
section.setLayout(new TableWrapLayout());
section.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
@@ -587,61 +698,69 @@ public class TaskInfoEditor extends EditorPart {
layout.numColumns = 2;
container.setLayout(layout);
-// Label l = toolkit.createLabel(container, "Task Handle:");
-// l.setForeground(toolkit.getColors().getColor(FormColors.TITLE));
-// Text handle = toolkit.createText(container, task.getHandleIdentifier(), SWT.BORDER);
-// TableWrapData td = new TableWrapData(TableWrapData.FILL_GRAB);
-// td.colspan = 2;
-// handle.setLayoutData(td);
-// handle.setEditable(false);
-// handle.setEnabled(false);
+ // Label l = toolkit.createLabel(container, "Task Handle:");
+ // l.setForeground(toolkit.getColors().getColor(FormColors.TITLE));
+ // Text handle = toolkit.createText(container,
+ // task.getHandleIdentifier(), SWT.BORDER);
+ // TableWrapData td = new TableWrapData(TableWrapData.FILL_GRAB);
+ // td.colspan = 2;
+ // handle.setLayoutData(td);
+ // handle.setEditable(false);
+ // handle.setEnabled(false);
Label l2 = toolkit.createLabel(container, "Task context file:");
l2.setForeground(toolkit.getColors().getColor(FormColors.TITLE));
- File contextFile = MylarPlugin.getContextManager().getFileForContext(task.getHandleIdentifier());
-// String contextPath = MylarPlugin.getDefault().getDataDirectory()
-// + '/' + task.getContextPath() + MylarContextManager.CONTEXT_FILE_EXTENSION;
+ File contextFile = MylarPlugin.getContextManager().getFileForContext(
+ task.getHandleIdentifier());
+ // String contextPath = MylarPlugin.getDefault().getDataDirectory()
+ // + '/' + task.getContextPath() +
+ // MylarContextManager.CONTEXT_FILE_EXTENSION;
if (contextFile != null) {
- pathText = toolkit.createText(container, contextFile.getAbsolutePath(), SWT.BORDER);
+ pathText = toolkit.createText(container, contextFile
+ .getAbsolutePath(), SWT.BORDER);
pathText.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
pathText.setEditable(false);
pathText.setEnabled(false);
}
-// browse = toolkit.createButton(container, "Change", SWT.PUSH | SWT.CENTER);
-// if (task.isActive()) {
-// browse.setEnabled(false);
-// } else {
-// browse.setEnabled(true);
-// }
-// browse.addSelectionListener(new SelectionAdapter() {
-// @Override
-// public void widgetSelected(SelectionEvent e) {
-//
-// if (task.isActive()) {
-// MessageDialog.openInformation(Display.getDefault().getActiveShell(), "Task Message",
-// "Task can not be active when changing taskscape");
-// } else {
-// FileDialog dialog = new FileDialog(Display.getDefault().getActiveShell(), SWT.OPEN);
-// String[] ext = { "*.xml" };
-// dialog.setFilterExtensions(ext);
-//
-// String mylarDir = MylarPlugin.getDefault().getDataDirectory() + "/";
-// mylarDir = mylarDir.replaceAll("\\\\", "/");
-// dialog.setFilterPath(mylarDir);
-//
-// String res = dialog.open();
-// if (res != null) {
-// res = res.replaceAll("\\\\", "/");
-// pathText.setText("<MylarDir>/" + res + ".xml");
-// markDirty(true);
-// }
-// }
-// }
-// });
-// toolkit.createLabel(container, "");
-// l = toolkit.createLabel(container, "Go to Task List Preferences to change task context directory");
-// l.setForeground(toolkit.getColors().getColor(FormColors.TITLE));
+ // browse = toolkit.createButton(container, "Change", SWT.PUSH |
+ // SWT.CENTER);
+ // if (task.isActive()) {
+ // browse.setEnabled(false);
+ // } else {
+ // browse.setEnabled(true);
+ // }
+ // browse.addSelectionListener(new SelectionAdapter() {
+ // @Override
+ // public void widgetSelected(SelectionEvent e) {
+ //
+ // if (task.isActive()) {
+ // MessageDialog.openInformation(Display.getDefault().getActiveShell(),
+ // "Task Message",
+ // "Task can not be active when changing taskscape");
+ // } else {
+ // FileDialog dialog = new
+ // FileDialog(Display.getDefault().getActiveShell(), SWT.OPEN);
+ // String[] ext = { "*.xml" };
+ // dialog.setFilterExtensions(ext);
+ //
+ // String mylarDir = MylarPlugin.getDefault().getDataDirectory() + "/";
+ // mylarDir = mylarDir.replaceAll("\\\\", "/");
+ // dialog.setFilterPath(mylarDir);
+ //
+ // String res = dialog.open();
+ // if (res != null) {
+ // res = res.replaceAll("\\\\", "/");
+ // pathText.setText("<MylarDir>/" + res + ".xml");
+ // markDirty(true);
+ // }
+ // }
+ // }
+ // });
+ // toolkit.createLabel(container, "");
+ // l = toolkit.createLabel(container, "Go to Task List Preferences to
+ // change task context directory");
+ // l.setForeground(toolkit.getColors().getColor(FormColors.TITLE));
}
private void refreshTaskListView(ITask task) {
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/actions/MarkTaskCompleteAction.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/actions/MarkTaskCompleteAction.java
index e6c22ad3d..5904827dd 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/actions/MarkTaskCompleteAction.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/actions/MarkTaskCompleteAction.java
@@ -40,6 +40,7 @@ public class MarkTaskCompleteAction extends Action {
for (Object selectedObject : ((IStructuredSelection)this.view.getViewer().getSelection()).toList()) {
if (selectedObject instanceof ITask) {
MylarTaskListPlugin.getTaskListManager().markComplete(((ITask)selectedObject), true);
+ MylarTaskListPlugin.getTaskListManager().notifyTaskChanged((ITask)selectedObject);
}
}
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/actions/MarkTaskIncompleteAction.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/actions/MarkTaskIncompleteAction.java
index 834f0e817..a3cf66f05 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/actions/MarkTaskIncompleteAction.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/actions/MarkTaskIncompleteAction.java
@@ -40,6 +40,7 @@ public class MarkTaskIncompleteAction extends Action {
for (Object selectedObject : ((IStructuredSelection)this.view.getViewer().getSelection()).toList()) {
if (selectedObject instanceof ITask) {
MylarTaskListPlugin.getTaskListManager().markComplete(((ITask)selectedObject), false);
+ MylarTaskListPlugin.getTaskListManager().notifyTaskChanged((ITask)selectedObject);
}
}
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/views/TaskListView.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/views/TaskListView.java
index 593098729..0befed5da 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/views/TaskListView.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/views/TaskListView.java
@@ -122,18 +122,18 @@ import org.eclipse.ui.part.ViewPart;
* @author Ken Sueda
*/
public class TaskListView extends ViewPart {
-
+
private static final String LABEL_NO_TASKS = "no task active";
public static final String ID = "org.eclipse.mylar.tasks.ui.views.TaskListView";
- public static final String[] PRIORITY_LEVELS = {
- MylarTaskListPlugin.PriorityLevel.P1.toString(),
- MylarTaskListPlugin.PriorityLevel.P2.toString(),
- MylarTaskListPlugin.PriorityLevel.P3.toString(),
- MylarTaskListPlugin.PriorityLevel.P4.toString(),
- MylarTaskListPlugin.PriorityLevel.P5.toString() };
-
+ public static final String[] PRIORITY_LEVELS = {
+ MylarTaskListPlugin.PriorityLevel.P1.toString(),
+ MylarTaskListPlugin.PriorityLevel.P2.toString(),
+ MylarTaskListPlugin.PriorityLevel.P3.toString(),
+ MylarTaskListPlugin.PriorityLevel.P4.toString(),
+ MylarTaskListPlugin.PriorityLevel.P5.toString() };
+
private static final String SEPARATOR_ID_REPORTS = "reports";
private static final String PART_NAME = "Mylar Tasks";
@@ -154,10 +154,10 @@ public class TaskListView extends ViewPart {
private CopyDescriptionAction copyDescriptionAction;
- private OpenTaskEditorAction openTaskEditor;
-
+ private OpenTaskEditorAction openTaskEditor;
+
private OpenTaskUrlInExternalBrowser openUrlInExternal;
-
+
private CreateTaskAction createTaskAction;
private CreateCategoryAction createCategoryAction;
@@ -212,8 +212,8 @@ public class TaskListView extends ViewPart {
private TaskActivationHistory taskHistory = new TaskActivationHistory();
- /**
- * True if the view should indicate that interaction monitoring is paused
+ /**
+ * True if the view should indicate that interaction monitoring is paused
*/
protected boolean isPaused = false;
@@ -242,11 +242,13 @@ public class TaskListView extends ViewPart {
}
public void tasklistModified() {
- if (!getViewer().getControl().isDisposed()) getViewer().refresh();
+ if (!getViewer().getControl().isDisposed())
+ getViewer().refresh();
}
-
+
private void refresh(ITaskListElement element) {
- if (getViewer().getControl() != null && !getViewer().getControl().isDisposed()) {
+ if (getViewer().getControl() != null
+ && !getViewer().getControl().isDisposed()) {
if (element == null) {
getViewer().getControl().setRedraw(false);
getViewer().refresh();
@@ -256,10 +258,11 @@ public class TaskListView extends ViewPart {
}
}
}
-
+
};
-
- private final class PriorityDropDownAction extends Action implements IMenuCreator {
+
+ private final class PriorityDropDownAction extends Action implements
+ IMenuCreator {
private Menu dropDownMenu = null;
public PriorityDropDownAction() {
@@ -299,7 +302,8 @@ public class TaskListView extends ViewPart {
Action P1 = new Action(PRIORITY_LEVELS[0], AS_CHECK_BOX) {
@Override
public void run() {
- MylarTaskListPlugin.setPriorityLevel(MylarTaskListPlugin.PriorityLevel.P1);
+ MylarTaskListPlugin
+ .setPriorityLevel(MylarTaskListPlugin.PriorityLevel.P1);
PRIORITY_FILTER.displayPrioritiesAbove(PRIORITY_LEVELS[0]);
getViewer().refresh();
}
@@ -312,7 +316,8 @@ public class TaskListView extends ViewPart {
Action P2 = new Action(PRIORITY_LEVELS[1], AS_CHECK_BOX) {
@Override
public void run() {
- MylarTaskListPlugin.setPriorityLevel(MylarTaskListPlugin.PriorityLevel.P2);
+ MylarTaskListPlugin
+ .setPriorityLevel(MylarTaskListPlugin.PriorityLevel.P2);
PRIORITY_FILTER.displayPrioritiesAbove(PRIORITY_LEVELS[1]);
getViewer().refresh();
}
@@ -325,7 +330,8 @@ public class TaskListView extends ViewPart {
Action P3 = new Action(PRIORITY_LEVELS[2], AS_CHECK_BOX) {
@Override
public void run() {
- MylarTaskListPlugin.setPriorityLevel(MylarTaskListPlugin.PriorityLevel.P3);
+ MylarTaskListPlugin
+ .setPriorityLevel(MylarTaskListPlugin.PriorityLevel.P3);
PRIORITY_FILTER.displayPrioritiesAbove(PRIORITY_LEVELS[2]);
getViewer().refresh();
}
@@ -338,7 +344,8 @@ public class TaskListView extends ViewPart {
Action P4 = new Action(PRIORITY_LEVELS[3], AS_CHECK_BOX) {
@Override
public void run() {
- MylarTaskListPlugin.setPriorityLevel(MylarTaskListPlugin.PriorityLevel.P4);
+ MylarTaskListPlugin
+ .setPriorityLevel(MylarTaskListPlugin.PriorityLevel.P4);
PRIORITY_FILTER.displayPrioritiesAbove(PRIORITY_LEVELS[3]);
getViewer().refresh();
}
@@ -351,7 +358,8 @@ public class TaskListView extends ViewPart {
Action P5 = new Action(PRIORITY_LEVELS[4], AS_CHECK_BOX) {
@Override
public void run() {
- MylarTaskListPlugin.setPriorityLevel(MylarTaskListPlugin.PriorityLevel.P5);
+ MylarTaskListPlugin
+ .setPriorityLevel(MylarTaskListPlugin.PriorityLevel.P5);
PRIORITY_FILTER.displayPrioritiesAbove(PRIORITY_LEVELS[4]);
getViewer().refresh();
}
@@ -392,7 +400,8 @@ public class TaskListView extends ViewPart {
public static TaskListView openInActivePerspective() {
try {
- return (TaskListView) Workbench.getInstance().getActiveWorkbenchWindow().getActivePage().showView(ID);
+ return (TaskListView) Workbench.getInstance()
+ .getActiveWorkbenchWindow().getActivePage().showView(ID);
} catch (Exception e) {
return null;
}
@@ -400,21 +409,25 @@ public class TaskListView extends ViewPart {
public TaskListView() {
INSTANCE = this;
- MylarTaskListPlugin.getTaskListManager().addListener(ACTIVITY_LISTENER); // TODO: remove on close?
+ MylarTaskListPlugin.getTaskListManager().addListener(ACTIVITY_LISTENER); // TODO:
+ // remove
+ // on
+ // close?
}
/**
* TODO: should be updated when view mode switches to fast and vice-versa
*/
private void updateDescription(ITask task) {
- if (getSite() == null || getSite().getPage() == null) return;
-
+ if (getSite() == null || getSite().getPage() == null)
+ return;
+
IViewReference reference = getSite().getPage().findViewReference(ID);
boolean isFastView = false;
if (reference != null && reference.isFastView()) {
isFastView = true;
}
-
+
if (task != null) {
setTitleToolTip(PART_NAME + " (" + task.getDescription(true) + ")");
if (isFastView) {
@@ -429,9 +442,9 @@ public class TaskListView extends ViewPart {
} else {
setContentDescription("");
}
- }
+ }
}
-
+
class TaskListCellModifier implements ICellModifier {
public boolean canModify(Object element, String property) {
@@ -459,8 +472,10 @@ public class TaskListView extends ViewPart {
if (taskListElement instanceof ITask) {
task = (ITask) taskListElement;
} else if (taskListElement instanceof IQueryHit) {
- if (((IQueryHit) taskListElement).getCorrespondingTask() != null) {
- task = ((IQueryHit) taskListElement).getCorrespondingTask();
+ if (((IQueryHit) taskListElement)
+ .getCorrespondingTask() != null) {
+ task = ((IQueryHit) taskListElement)
+ .getCorrespondingTask();
}
}
switch (columnIndex) {
@@ -473,9 +488,10 @@ public class TaskListView extends ViewPart {
case 1:
return "";
case 2:
- String priorityString = taskListElement.getPriority().substring(1);
+ String priorityString = taskListElement.getPriority()
+ .substring(1);
int priorityInt = new Integer(priorityString);
- return priorityInt-1;
+ return priorityInt - 1;
case 3:
return taskListElement.getDescription(true);
}
@@ -515,7 +531,8 @@ public class TaskListView extends ViewPart {
try {
columnIndex = Arrays.asList(columnNames).indexOf(property);
if (((TreeItem) element).getData() instanceof ITaskCategory) {
- ITaskCategory cat = (ITaskCategory) ((TreeItem) element).getData();
+ ITaskCategory cat = (ITaskCategory) ((TreeItem) element)
+ .getData();
switch (columnIndex) {
case 0:
break;
@@ -528,7 +545,8 @@ public class TaskListView extends ViewPart {
break;
}
} else if (((TreeItem) element).getData() instanceof ITaskQuery) {
- ITaskQuery cat = (ITaskQuery) ((TreeItem) element).getData();
+ ITaskQuery cat = (ITaskQuery) ((TreeItem) element)
+ .getData();
switch (columnIndex) {
case 0:
break;
@@ -542,25 +560,31 @@ public class TaskListView extends ViewPart {
}
} else if (((TreeItem) element).getData() instanceof ITaskListElement) {
- final ITaskListElement taskListElement = (ITaskListElement) ((TreeItem) element).getData();
+ final ITaskListElement taskListElement = (ITaskListElement) ((TreeItem) element)
+ .getData();
ITask task = null;
if (taskListElement instanceof ITask) {
task = (ITask) taskListElement;
} else if (taskListElement instanceof IQueryHit) {
- if (((IQueryHit) taskListElement).getCorrespondingTask() != null) {
- task = ((IQueryHit) taskListElement).getCorrespondingTask();
+ if (((IQueryHit) taskListElement)
+ .getCorrespondingTask() != null) {
+ task = ((IQueryHit) taskListElement)
+ .getCorrespondingTask();
}
}
switch (columnIndex) {
case 0:
if (taskListElement instanceof IQueryHit) {
- task = ((IQueryHit) taskListElement).getOrCreateCorrespondingTask();
+ task = ((IQueryHit) taskListElement)
+ .getOrCreateCorrespondingTask();
}
if (task != null) {
if (task.isActive()) {
new TaskDeactivateAction().run();
- nextTaskAction.setEnabled(taskHistory.hasNext());
- previousTaskAction.setEnabled(taskHistory.hasPrevious());
+ nextTaskAction
+ .setEnabled(taskHistory.hasNext());
+ previousTaskAction.setEnabled(taskHistory
+ .hasPrevious());
} else {
new TaskActivateAction().run();
addTaskToHistory(task);
@@ -573,13 +597,17 @@ public class TaskListView extends ViewPart {
if (task.isLocal()) {
Integer intVal = (Integer) value;
task.setPriority("P" + (intVal + 1));
+ MylarTaskListPlugin.getTaskListManager()
+ .notifyTaskChanged(task);
}
break;
case 3:
if (task.isLocal()) {
task.setDescription(((String) value).trim());
-// MylarTaskListPlugin.getTaskListManager().notifyTaskPropertyChanged(task, columnNames[3]);
- MylarTaskListPlugin.getTaskListManager().notifyTaskChanged(task);
+ // MylarTaskListPlugin.getTaskListManager().notifyTaskPropertyChanged(task,
+ // columnNames[3]);
+ MylarTaskListPlugin.getTaskListManager()
+ .notifyTaskChanged(task);
}
break;
}
@@ -620,7 +648,10 @@ public class TaskListView extends ViewPart {
public int compare(Viewer compareViewer, Object o1, Object o2) {
if (o1 instanceof ITaskCategory || o1 instanceof ITaskQuery) {
if (o2 instanceof ITaskCategory || o2 instanceof ITaskQuery) {
- return ((ITaskListElement) o1).getDescription(false).compareTo(((ITaskListElement) o2).getDescription(false));
+ return ((ITaskListElement) o1).getDescription(false)
+ .compareTo(
+ ((ITaskListElement) o2)
+ .getDescription(false));
} else {
return -1;
}
@@ -630,22 +661,25 @@ public class TaskListView extends ViewPart {
} else if (o2 instanceof ITaskListElement) {
ITaskListElement element1 = (ITaskListElement) o1;
ITaskListElement element2 = (ITaskListElement) o2;
- // if (element1.isCompleted() && element2.isCompleted()) {
- // return element1.getPriority().compareTo(element2.getPriority());
- // }
- // if (element1.isCompleted()) return 1;
- // if (element2.isCompleted()) return -1;
- // if (element1.hasCorrespondingActivatableTask() && element2.hasCorrespondingActivatableTask()) {
- // ITask task1 = element1.getOrCreateCorrespondingTask();
- // ITask task2 = element2.getOrCreateCorrespondingTask();
+ // if (element1.isCompleted() && element2.isCompleted()) {
+ // return
+ // element1.getPriority().compareTo(element2.getPriority());
+ // }
+ // if (element1.isCompleted()) return 1;
+ // if (element2.isCompleted()) return -1;
+ // if (element1.hasCorrespondingActivatableTask() &&
+ // element2.hasCorrespondingActivatableTask()) {
+ // ITask task1 = element1.getOrCreateCorrespondingTask();
+ // ITask task2 = element2.getOrCreateCorrespondingTask();
//
- // if (task1.isCompleted()) return 1;
- // if (task2.isCompleted()) return -1;
- // }
+ // if (task1.isCompleted()) return 1;
+ // if (task2.isCompleted()) return -1;
+ // }
if (column != null && column.equals(columnNames[1])) {
return 0;
} else if (column == columnNames[2]) {
- return element1.getPriority().compareTo(element2.getPriority());
+ return element1.getPriority().compareTo(
+ element2.getPriority());
} else if (column == columnNames[3]) {
String c1 = element1.getStringForSortingDescription();
String c2 = element2.getStringForSortingDescription();
@@ -686,16 +720,19 @@ public class TaskListView extends ViewPart {
IMemento m = sorter.createChild("sorter");
m.putInteger("sortIndex", sortIndex);
- MylarTaskListPlugin.getDefault().getTaskListSaveManager().createTaskListBackupFile();
+ MylarTaskListPlugin.getDefault().getTaskListSaveManager()
+ .createTaskListBackupFile();
if (MylarTaskListPlugin.getDefault() != null) {
- MylarTaskListPlugin.getDefault().getTaskListSaveManager().saveTaskListAndContexts();
+ MylarTaskListPlugin.getDefault().getTaskListSaveManager()
+ .saveTaskListAndContexts();
}
}
private void restoreState() {
if (taskListMemento != null) {
- IMemento taskListWidth = taskListMemento.getChild(columnWidthIdentifier);
+ IMemento taskListWidth = taskListMemento
+ .getChild(columnWidthIdentifier);
if (taskListWidth != null) {
for (int i = 0; i < columnWidths.length; i++) {
IMemento m = taskListWidth.getChild("col" + i);
@@ -706,7 +743,8 @@ public class TaskListView extends ViewPart {
}
}
}
- IMemento sorterMemento = taskListMemento.getChild(tableSortIdentifier);
+ IMemento sorterMemento = taskListMemento
+ .getChild(tableSortIdentifier);
if (sorterMemento != null) {
IMemento m = sorterMemento.getChild("sorter");
if (m != null) {
@@ -717,11 +755,12 @@ public class TaskListView extends ViewPart {
} else {
sortIndex = 2; // default priority
}
- getViewer().setSorter(new TaskListTableSorter(columnNames[sortIndex]));
+ getViewer().setSorter(
+ new TaskListTableSorter(columnNames[sortIndex]));
}
addFilter(PRIORITY_FILTER);
- // if (MylarTaskListPlugin.getDefault().isFilterInCompleteMode())
- // MylarTaskListPlugin.getTaskListManager().getTaskList().addFilter(inCompleteFilter);
+ // if (MylarTaskListPlugin.getDefault().isFilterInCompleteMode())
+ // MylarTaskListPlugin.getTaskListManager().getTaskList().addFilter(inCompleteFilter);
if (MylarTaskListPlugin.getDefault().isFilterCompleteMode())
addFilter(COMPLETE_FILTER);
if (MylarTaskListPlugin.getDefault().isMultipleActiveTasksMode()) {
@@ -732,15 +771,17 @@ public class TaskListView extends ViewPart {
getViewer().refresh();
}
- /**
- * This is a callback that will allow us
- * to create the viewer and initialize it.
+ /**
+ * This is a callback that will allow us to create the viewer and initialize
+ * it.
*/
@Override
public void createPartControl(Composite parent) {
- tree = new FilteredTree(parent, SWT.MULTI | SWT.VERTICAL | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.HIDE_SELECTION, new TaskListPatternFilter());
+ tree = new FilteredTree(parent, SWT.MULTI | SWT.VERTICAL | SWT.H_SCROLL
+ | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.HIDE_SELECTION,
+ new TaskListPatternFilter());
tree.setInitialText("");
-
+
getViewer().getTree().setHeaderVisible(true);
getViewer().getTree().setLinesVisible(true);
getViewer().setColumnProperties(columnNames);
@@ -757,7 +798,8 @@ public class TaskListView extends ViewPart {
@Override
public void widgetSelected(SelectionEvent e) {
sortIndex = index;
- getViewer().setSorter(new TaskListTableSorter(columnNames[sortIndex]));
+ getViewer().setSorter(
+ new TaskListTableSorter(columnNames[sortIndex]));
}
});
columns[i].addControlListener(new ControlListener() {
@@ -780,7 +822,8 @@ public class TaskListView extends ViewPart {
((Text) textEditor.getControl()).setOrientation(SWT.LEFT_TO_RIGHT);
editors[0] = new CheckboxCellEditor();
editors[1] = textEditor;
- editors[2] = new ComboBoxCellEditor(getViewer().getTree(), PRIORITY_LEVELS, SWT.READ_ONLY);
+ editors[2] = new ComboBoxCellEditor(getViewer().getTree(),
+ PRIORITY_LEVELS, SWT.READ_ONLY);
editors[3] = textEditor;
getViewer().setCellEditors(editors);
getViewer().setCellModifier(new TaskListCellModifier());
@@ -815,48 +858,53 @@ public class TaskListView extends ViewPart {
});
// HACK: to support right click anywhere to select an item
-// getViewer().getTree().addMouseListener(new MouseListener() {
-//
-// public void mouseDoubleClick(MouseEvent e) {
-// }
-//
-// public void mouseDown(MouseEvent e) {
-// Tree t = getViewer().getTree();
-// TreeItem item = t.getItem(new Point(e.x, e.y));
-// if (e.button == 3 && item != null) {
-// getViewer().setSelection(new StructuredSelection(item.getData()));
-// } else if (item == null) {
-// getViewer().setSelection(new StructuredSelection());
-// }
-// }
-//
-// public void mouseUp(MouseEvent e) {
-// }
-// });
+ // getViewer().getTree().addMouseListener(new MouseListener() {
+ //
+ // public void mouseDoubleClick(MouseEvent e) {
+ // }
+ //
+ // public void mouseDown(MouseEvent e) {
+ // Tree t = getViewer().getTree();
+ // TreeItem item = t.getItem(new Point(e.x, e.y));
+ // if (e.button == 3 && item != null) {
+ // getViewer().setSelection(new StructuredSelection(item.getData()));
+ // } else if (item == null) {
+ // getViewer().setSelection(new StructuredSelection());
+ // }
+ // }
+ //
+ // public void mouseUp(MouseEvent e) {
+ // }
+ // });
// HACK: shouldn't need to update explicitly
- getViewer().addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- Object selectedObject = ((IStructuredSelection) getViewer().getSelection()).getFirstElement();
- if (selectedObject instanceof ITaskListElement) {
- updateActionEnablement(rename, (ITaskListElement) selectedObject);
- }
- }
- });
+ getViewer().addSelectionChangedListener(
+ new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ Object selectedObject = ((IStructuredSelection) getViewer()
+ .getSelection()).getFirstElement();
+ if (selectedObject instanceof ITaskListElement) {
+ updateActionEnablement(rename,
+ (ITaskListElement) selectedObject);
+ }
+ }
+ });
makeActions();
hookContextMenu();
hookOpenAction();
contributeToActionBars();
- ToolTipHandler toolTipHandler = new ToolTipHandler(getViewer().getControl().getShell());
+ ToolTipHandler toolTipHandler = new ToolTipHandler(getViewer()
+ .getControl().getShell());
toolTipHandler.activateHoverHelp(getViewer().getControl());
initDragAndDrop(parent);
expandToActiveTasks();
restoreState();
-
- List<ITask> activeTasks = MylarTaskListPlugin.getTaskListManager().getTaskList().getActiveTasks();
+
+ List<ITask> activeTasks = MylarTaskListPlugin.getTaskListManager()
+ .getTaskList().getActiveTasks();
if (activeTasks.size() > 0) {
updateDescription(activeTasks.get(0));
}
@@ -864,18 +912,22 @@ public class TaskListView extends ViewPart {
@MylarWebRef(name = "Drag and drop article", url = "http://www.eclipse.org/articles/Article-Workbench-DND/drag_drop.html")
private void initDragAndDrop(Composite parent) {
- Transfer[] types = new Transfer[] { TextTransfer.getInstance(), PluginTransfer.getInstance() };
+ Transfer[] types = new Transfer[] { TextTransfer.getInstance(),
+ PluginTransfer.getInstance() };
- getViewer().addDragSupport(DND.DROP_MOVE, types, new TaskListDragSourceListener(this));
+ getViewer().addDragSupport(DND.DROP_MOVE, types,
+ new TaskListDragSourceListener(this));
- getViewer().addDropSupport(DND.DROP_COPY | DND.DROP_MOVE, types, new TaskListDropAdapter(getViewer()));
+ getViewer().addDropSupport(DND.DROP_COPY | DND.DROP_MOVE, types,
+ new TaskListDropAdapter(getViewer()));
}
void expandToActiveTasks() {
final IWorkbench workbench = PlatformUI.getWorkbench();
workbench.getDisplay().asyncExec(new Runnable() {
public void run() {
- List<ITask> activeTasks = MylarTaskListPlugin.getTaskListManager().getTaskList().getActiveTasks();
+ List<ITask> activeTasks = MylarTaskListPlugin
+ .getTaskListManager().getTaskList().getActiveTasks();
for (ITask t : activeTasks) {
getViewer().expandToLevel(t, 0);
}
@@ -904,14 +956,14 @@ public class TaskListView extends ViewPart {
private void fillLocalPullDown(IMenuManager manager) {
updateDrillDownActions();
- // manager.add(new Separator("reports"));
- // manager.add(new Separator("local"));
- // manager.add(createTaskAction);
- // manager.add(createCategoryAction);
+ // manager.add(new Separator("reports"));
+ // manager.add(new Separator("local"));
+ // manager.add(createTaskAction);
+ // manager.add(createCategoryAction);
manager.add(goUpAction);
manager.add(collapseAll);
- // manager.add(new Separator());
- // autoClose.setEnabled(true);
+ // manager.add(new Separator());
+ // autoClose.setEnabled(true);
manager.add(new Separator("context"));
manager.add(autoClose);
manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
@@ -921,7 +973,7 @@ public class TaskListView extends ViewPart {
private void fillLocalToolBar(IToolBarManager manager) {
manager.add(new Separator(SEPARATOR_ID_REPORTS));
manager.add(createTaskAction);
-// manager.add(createCategoryAction);
+ // manager.add(createCategoryAction);
manager.add(new Separator());
manager.add(filterCompleteTask);
manager.add(filterOnPriority);
@@ -929,7 +981,7 @@ public class TaskListView extends ViewPart {
manager.add(previousTaskAction);
manager.add(nextTaskAction);
manager.add(new Separator("context"));
-// manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
+ // manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
}
private void fillContextMenu(IMenuManager manager) {
@@ -937,7 +989,8 @@ public class TaskListView extends ViewPart {
ITaskListElement element = null;
;
- final Object selectedObject = ((IStructuredSelection) getViewer().getSelection()).getFirstElement();
+ final Object selectedObject = ((IStructuredSelection) getViewer()
+ .getSelection()).getFirstElement();
if (selectedObject instanceof ITaskListElement) {
element = (ITaskListElement) selectedObject;
}
@@ -960,7 +1013,7 @@ public class TaskListView extends ViewPart {
addAction(markIncompleteAction, manager, element);
}
}
-
+
if (task.isActive()) {
manager.add(deactivateAction);
} else {
@@ -971,7 +1024,7 @@ public class TaskListView extends ViewPart {
addAction(removeFromCategoryAction, manager, element);
}
}
- // manager.add(new Separator("tasks"));
+ // manager.add(new Separator("tasks"));
addAction(deleteAction, manager, element);
if (element instanceof ITaskCategory) {
manager.add(goIntoAction);
@@ -979,8 +1032,8 @@ public class TaskListView extends ViewPart {
if (drilledIntoCategory != null) {
manager.add(goUpAction);
}
- // addAction(rename, manager, element);
- // addAction(copyDescriptionAction, manager, element);
+ // addAction(rename, manager, element);
+ // addAction(copyDescriptionAction, manager, element);
manager.add(new Separator("local"));
manager.add(createTaskAction);
@@ -988,8 +1041,10 @@ public class TaskListView extends ViewPart {
manager.add(new Separator("reports"));
manager.add(new Separator("context"));
- for (IDynamicSubMenuContributor contributor : MylarTaskListPlugin.getDefault().getDynamicMenuContributers()) {
- MenuManager subMenuManager = contributor.getSubMenuManager(this, (ITaskListElement) selectedObject);
+ for (IDynamicSubMenuContributor contributor : MylarTaskListPlugin
+ .getDefault().getDynamicMenuContributers()) {
+ MenuManager subMenuManager = contributor.getSubMenuManager(this,
+ (ITaskListElement) selectedObject);
if (subMenuManager != null)
addMenuManager(subMenuManager, manager, element);
}
@@ -997,7 +1052,8 @@ public class TaskListView extends ViewPart {
manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
}
- private void addMenuManager(IMenuManager menuToAdd, IMenuManager manager, ITaskListElement element) {
+ private void addMenuManager(IMenuManager menuToAdd, IMenuManager manager,
+ ITaskListElement element) {
if (element != null && element instanceof ITask) {
manager.add(menuToAdd);
}
@@ -1006,10 +1062,12 @@ public class TaskListView extends ViewPart {
/**
* Refactor handler stuff
*/
- private void addAction(Action action, IMenuManager manager, ITaskListElement element) {
+ private void addAction(Action action, IMenuManager manager,
+ ITaskListElement element) {
manager.add(action);
if (element != null) {
- ITaskHandler handler = MylarTaskListPlugin.getDefault().getHandlerForElement(element);
+ ITaskHandler handler = MylarTaskListPlugin.getDefault()
+ .getHandlerForElement(element);
if (handler != null) {
action.setEnabled(handler.enableAction(action, element));
} else {
@@ -1030,7 +1088,7 @@ public class TaskListView extends ViewPart {
action.setEnabled(true);
}
} else if (action instanceof OpenTaskUrlInExternalBrowser) {
- if (((ITask)element).hasValidUrl()) {
+ if (((ITask) element).hasValidUrl()) {
action.setEnabled(true);
} else {
action.setEnabled(false);
@@ -1087,9 +1145,9 @@ public class TaskListView extends ViewPart {
} else {
action.setEnabled(true);
}
- // if(!canEnableGoInto){
- // goIntoAction.setEnabled(false);
- // }
+ // if(!canEnableGoInto){
+ // goIntoAction.setEnabled(false);
+ // }
}
private void makeActions() {
@@ -1146,24 +1204,31 @@ public class TaskListView extends ViewPart {
* children
*/
protected boolean lookForId(String taskId) {
- return (MylarTaskListPlugin.getTaskListManager().getTaskForHandle(taskId, true) == null);
- // for (ITask task : MylarTaskListPlugin.getTaskListManager().getTaskList().getRootTasks()) {
- // if (task.getHandle().equals(taskId)) {
- // return true;
- // }
- // }
- // for (TaskCategory cat : MylarTaskListPlugin.getTaskListManager().getTaskList().getTaskCategories()) {
- // for (ITask task : cat.getChildren()) {
- // if (task.getHandle().equals(taskId)) {
- // return true;
- // }
- // }
- // }
- // return false;
+ return (MylarTaskListPlugin.getTaskListManager().getTaskForHandle(
+ taskId, true) == null);
+ // for (ITask task :
+ // MylarTaskListPlugin.getTaskListManager().getTaskList().getRootTasks())
+ // {
+ // if (task.getHandle().equals(taskId)) {
+ // return true;
+ // }
+ // }
+ // for (TaskCategory cat :
+ // MylarTaskListPlugin.getTaskListManager().getTaskList().getTaskCategories())
+ // {
+ // for (ITask task : cat.getChildren()) {
+ // if (task.getHandle().equals(taskId)) {
+ // return true;
+ // }
+ // }
+ // }
+ // return false;
}
- public void closeTaskEditors(ITask task, IWorkbenchPage page) throws LoginException, IOException {
- ITaskHandler taskHandler = MylarTaskListPlugin.getDefault().getHandlerForElement(task);
+ public void closeTaskEditors(ITask task, IWorkbenchPage page)
+ throws LoginException, IOException {
+ ITaskHandler taskHandler = MylarTaskListPlugin.getDefault()
+ .getHandlerForElement(task);
if (taskHandler != null) {
taskHandler.taskClosed(task, page);
} else if (task instanceof Task) {
@@ -1186,7 +1251,8 @@ public class TaskListView extends ViewPart {
}
public void showMessage(String message) {
- MessageDialog.openInformation(getViewer().getControl().getShell(), "TaskList Message", message);
+ MessageDialog.openInformation(getViewer().getControl().getShell(),
+ "TaskList Message", message);
}
/**
@@ -1198,8 +1264,9 @@ public class TaskListView extends ViewPart {
}
public String getBugIdFromUser() {
- InputDialog dialog = new InputDialog(Workbench.getInstance().getActiveWorkbenchWindow().getShell(), "Enter Bugzilla ID", "Enter the Bugzilla ID: ", "",
- null);
+ InputDialog dialog = new InputDialog(Workbench.getInstance()
+ .getActiveWorkbenchWindow().getShell(), "Enter Bugzilla ID",
+ "Enter the Bugzilla ID: ", "", null);
int dialogResult = dialog.open();
if (dialogResult == Window.OK) {
return dialog.getValue();
@@ -1208,38 +1275,39 @@ public class TaskListView extends ViewPart {
}
}
- // public String[] getLabelPriorityFromUser(String kind) {
- // String[] result = new String[2];
- // Dialog dialog = null;
- // boolean isTask = kind.equals("task");
- // if (isTask) {
- // dialog = new TaskInputDialog(
- // Workbench.getInstance().getActiveWorkbenchWindow().getShell());
- // } else {
- // dialog = new InputDialog(
- // Workbench.getInstance().getActiveWorkbenchWindow().getShell(),
- // "Enter name",
- // "Enter a name for the " + kind + ": ",
- // "",
- // null);
- // }
+ // public String[] getLabelPriorityFromUser(String kind) {
+ // String[] result = new String[2];
+ // Dialog dialog = null;
+ // boolean isTask = kind.equals("task");
+ // if (isTask) {
+ // dialog = new TaskInputDialog(
+ // Workbench.getInstance().getActiveWorkbenchWindow().getShell());
+ // } else {
+ // dialog = new InputDialog(
+ // Workbench.getInstance().getActiveWorkbenchWindow().getShell(),
+ // "Enter name",
+ // "Enter a name for the " + kind + ": ",
+ // "",
+ // null);
+ // }
//
- // int dialogResult = dialog.open();
- // if (dialogResult == Window.OK) {
- // if (isTask) {
- // result[0] = ((TaskInputDialog)dialog).getTaskname();
- // result[1] = ((TaskInputDialog)dialog).getSelectedPriority();
- // } else {
- // result[0] = ((InputDialog)dialog).getValue();
- // }
- // return result;
- // } else {
- // return null;
- // }
- // }
+ // int dialogResult = dialog.open();
+ // if (dialogResult == Window.OK) {
+ // if (isTask) {
+ // result[0] = ((TaskInputDialog)dialog).getTaskname();
+ // result[1] = ((TaskInputDialog)dialog).getSelectedPriority();
+ // } else {
+ // result[0] = ((InputDialog)dialog).getValue();
+ // }
+ // return result;
+ // } else {
+ // return null;
+ // }
+ // }
public void notifyTaskDataChanged(ITask task) {
- if (getViewer().getTree() != null && !getViewer().getTree().isDisposed()) {
+ if (getViewer().getTree() != null
+ && !getViewer().getTree().isDisposed()) {
getViewer().refresh();
expandToActiveTasks();
}
@@ -1284,7 +1352,7 @@ public class TaskListView extends ViewPart {
}
/**
- * HACK: This is used for the copy action
+ * HACK: This is used for the copy action
*/
public Composite getDummyComposite() {
return tree;
@@ -1340,10 +1408,11 @@ public class TaskListView extends ViewPart {
public void indicatePaused(boolean paused) {
isPaused = paused;
- IStatusLineManager statusLineManager = getViewSite().getActionBars().getStatusLineManager();
+ IStatusLineManager statusLineManager = getViewSite().getActionBars()
+ .getStatusLineManager();
if (isPaused) {
- statusLineManager.setMessage(
- TaskListImages.getImage(TaskListImages.TASKLIST),
+ statusLineManager.setMessage(TaskListImages
+ .getImage(TaskListImages.TASKLIST),
"Mylar context capture paused");
} else {
statusLineManager.setMessage("");
@@ -1351,9 +1420,9 @@ public class TaskListView extends ViewPart {
}
/**
- * Show the shared data folder currently in use.
- * Call with "" to turn off the indication.
- * TODO: Need a better way to indicate paused and/or the shared folder
+ * Show the shared data folder currently in use. Call with "" to turn off
+ * the indication. TODO: Need a better way to indicate paused and/or the
+ * shared folder
*/
public void indicateSharedFolder(String folderName) {
if (folderName.equals("")) {
@@ -1376,9 +1445,8 @@ public class TaskListView extends ViewPart {
return drilledIntoCategory;
}
-
-// @Override
-// public String getTitleToolTip() {
-// return "xxx";
-// }
+ // @Override
+ // public String getTitleToolTip() {
+ // return "xxx";
+ // }
} \ No newline at end of file
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/wizards/AddRepositoryWizard.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/wizards/AddRepositoryWizard.java
index 57fd25c95..df0925d43 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/wizards/AddRepositoryWizard.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/wizards/AddRepositoryWizard.java
@@ -38,7 +38,7 @@ public class AddRepositoryWizard extends Wizard implements INewWizard {
@Override
public boolean performFinish() {
if (canFinish()) {
- TaskRepository repository = new TaskRepository(repositorySettingsPage.getServerUrl(), repositoryClient.getKind());
+ TaskRepository repository = new TaskRepository(repositoryClient.getKind(), repositorySettingsPage.getServerUrl());
if (repository != null) {
repository.setAuthenticationCredentials(repositorySettingsPage.getUserName(), repositorySettingsPage.getPassword());
MylarTaskListPlugin.getRepositoryManager().addRepository(repository);
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/wizards/EditRepositoryWizard.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/wizards/EditRepositoryWizard.java
index 4404acff7..de4f7c13b 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/wizards/EditRepositoryWizard.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/wizards/EditRepositoryWizard.java
@@ -35,8 +35,8 @@ public class EditRepositoryWizard extends Wizard implements INewWizard {
@Override
public boolean performFinish() {
if (canFinish()) {
- TaskRepository repository = new TaskRepository(repositorySettingsPage.getServerUrl(),
- repositorySettingsPage.getRepository().getKind());
+ TaskRepository repository = new TaskRepository(repositorySettingsPage.getRepository().getKind(),
+ repositorySettingsPage.getServerUrl());
if (repository != null) {
repository.setAuthenticationCredentials(repositorySettingsPage.getUserName(), repositorySettingsPage.getPassword());
MylarTaskListPlugin.getRepositoryManager().addRepository(repository);

Back to the top