Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/AbstractReportFactory.java18
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaAttachmentHandler.java2
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/NewBugWizardTest.java2
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/BugzillaRepositoryUi.java4
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/wizard/BugzillaProductPage.java81
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/wizard/NewBugzillaTaskWizard.java8
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/connector/MockRepositoryUi.java3
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/AbstractRepositoryAction.java44
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/AddRepositoryTaskAction.java5
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/NewQueryAction.java5
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/NewRepositoryTaskAction.java7
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/AddExistingTaskWizard.java5
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/NewQueryWizard.java6
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/NewRepositoryTaskPage.java4
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/NewRepositoryTaskWizard.java6
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/SelectRepositoryPage.java36
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/AbstractRepositoryConnectorUi.java3
-rw-r--r--org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/TracRepositoryUi.java2
18 files changed, 112 insertions, 129 deletions
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/AbstractReportFactory.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/AbstractReportFactory.java
index 058f528ca..473db55d3 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/AbstractReportFactory.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/AbstractReportFactory.java
@@ -19,6 +19,8 @@ import java.net.HttpURLConnection;
import java.net.Proxy;
import java.net.URL;
import java.security.GeneralSecurityException;
+import java.util.Arrays;
+import java.util.List;
import java.util.zip.GZIPInputStream;
import javax.security.auth.login.LoginException;
@@ -38,13 +40,19 @@ import org.xml.sax.helpers.XMLReaderFactory;
public class AbstractReportFactory {
private static final String CONTENT_TYPE_TEXT_HTML = "text/html";
-
+
private static final String CONTENT_TYPE_APP_RDF_XML = "application/rdf+xml";
private static final String CONTENT_TYPE_APP_XML = "application/xml";
+
+ private static final String CONTENT_TYPE_APP_XCGI = "application/x-cgi";
private static final String CONTENT_TYPE_TEXT_XML = "text/xml";
+ private static final String[] VALID_CONFIG_CONTENT_TYPES = {CONTENT_TYPE_APP_RDF_XML, CONTENT_TYPE_APP_XML, CONTENT_TYPE_TEXT_XML};
+
+ private static final List<String> VALID_TYPES = Arrays.asList(VALID_CONFIG_CONTENT_TYPES);
+
public static final int RETURN_ALL_HITS = -1;
/** expects rdf returned from repository (ctype=rdf in url)
@@ -57,6 +65,7 @@ public class AbstractReportFactory {
connection = WebClientUtil.openUrlConnection(url, proxySettings, false);
int responseCode = connection.getResponseCode();
+
if (responseCode != HttpURLConnection.HTTP_OK) {
String msg;
if (responseCode == -1 || responseCode == HttpURLConnection.HTTP_FORBIDDEN)
@@ -93,10 +102,7 @@ public class AbstractReportFactory {
in = new BufferedReader(strReader);
}
- if (connection.getContentType().contains(CONTENT_TYPE_APP_RDF_XML)
- || connection.getContentType().contains(CONTENT_TYPE_APP_XML)
- || connection.getContentType().contains(CONTENT_TYPE_TEXT_XML)) {
-
+ if (VALID_TYPES.contains(connection.getContentType().toLowerCase())) {
try {
final XMLReader reader = XMLReaderFactory.createXMLReader();
reader.setContentHandler(contentHandler);
@@ -124,6 +130,8 @@ public class AbstractReportFactory {
}
} else if (connection.getContentType().contains(CONTENT_TYPE_TEXT_HTML)) {
BugzillaServerFacade.parseHtmlError(in);
+ } else if (connection.getContentType().toLowerCase().contains(CONTENT_TYPE_APP_XCGI)) {
+ // ignore
} else {
throw new IOException("Unrecognized content type: " + connection.getContentType());
}
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaAttachmentHandler.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaAttachmentHandler.java
index 6ac5fbaa3..64ebca24a 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaAttachmentHandler.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaAttachmentHandler.java
@@ -159,7 +159,7 @@ public class BugzillaAttachmentHandler implements IAttachmentHandler {
}
postMethod.setRequestEntity(new MultipartRequestEntity(parts.toArray(new Part[1]), postMethod.getParams()));
-
+ postMethod.setDoAuthentication(true);
client.getHttpConnectionManager().getParams().setConnectionTimeout(CONNECT_TIMEOUT);
int status = client.executeMethod(postMethod);
if (status == HttpStatus.SC_OK) {
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/NewBugWizardTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/NewBugWizardTest.java
index 102ef7e5d..3495b7b79 100644
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/NewBugWizardTest.java
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/NewBugWizardTest.java
@@ -35,7 +35,7 @@ public class NewBugWizardTest extends TestCase {
TaskRepository repository = new TaskRepository(BugzillaCorePlugin.REPOSITORY_KIND,
IBugzillaConstants.TEST_BUGZILLA_220_URL);
BugzillaServerFacade.setupNewBugAttributes(repository.getUrl(), null, repository.getUserName(), repository.getPassword(), newReport, null);
- BugzillaProductPage page = new BugzillaProductPage(PlatformUI.getWorkbench(), null, repository, null);
+ BugzillaProductPage page = new BugzillaProductPage(PlatformUI.getWorkbench(), null, repository);
page.setPlatformOptions(newReport);
String os = Platform.getOS();
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/BugzillaRepositoryUi.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/BugzillaRepositoryUi.java
index ea4440895..726cec5bb 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/BugzillaRepositoryUi.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/BugzillaRepositoryUi.java
@@ -42,8 +42,8 @@ public class BugzillaRepositoryUi extends AbstractRepositoryConnectorUi {
}
@Override
- public IWizard getNewTaskWizard(TaskRepository taskRepository, IStructuredSelection selection) {
- return new NewBugzillaTaskWizard(taskRepository, selection);
+ public IWizard getNewTaskWizard(TaskRepository taskRepository) {
+ return new NewBugzillaTaskWizard(taskRepository);
}
public IWizard getQueryWizard(TaskRepository repository, AbstractRepositoryQuery query) {
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/wizard/BugzillaProductPage.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/wizard/BugzillaProductPage.java
index 2d12d8170..c02732522 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/wizard/BugzillaProductPage.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/wizard/BugzillaProductPage.java
@@ -34,6 +34,7 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.mylar.context.core.MylarStatusHandler;
@@ -42,6 +43,7 @@ import org.eclipse.mylar.internal.bugzilla.core.BugzillaQueryHit;
import org.eclipse.mylar.internal.bugzilla.core.BugzillaReportElement;
import org.eclipse.mylar.internal.bugzilla.core.BugzillaRepositoryQuery;
import org.eclipse.mylar.internal.bugzilla.core.BugzillaServerFacade;
+import org.eclipse.mylar.internal.bugzilla.core.BugzillaTask;
import org.eclipse.mylar.internal.bugzilla.core.IBugzillaConstants;
import org.eclipse.mylar.internal.bugzilla.core.NewBugzillaReport;
import org.eclipse.mylar.internal.bugzilla.ui.BugzillaUiPlugin;
@@ -61,12 +63,14 @@ import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
/**
* @author Shawn Minto
* @author Rob Elves
* @author Mik Kersten
+ * @author Eugene Kuleshov
*
* Product selection page of new bug wizard
*/
@@ -114,7 +118,6 @@ public class BugzillaProductPage extends WizardPage implements Listener {
protected IPreferenceStore prefs = BugzillaUiPlugin.getDefault().getPreferenceStore();
- private final IStructuredSelection selection;
/**
* Constructor for BugzillaProductPage
@@ -127,10 +130,8 @@ public class BugzillaProductPage extends WizardPage implements Listener {
* The repository the data is coming from
* @param selection
*/
- public BugzillaProductPage(IWorkbench workbench, NewBugzillaTaskWizard bugWiz, TaskRepository repository,
- IStructuredSelection selection) {
+ public BugzillaProductPage(IWorkbench workbench, NewBugzillaTaskWizard bugWiz, TaskRepository repository) {
super("Page1");
- this.selection = selection;
setTitle(IBugzillaConstants.TITLE_NEW_BUG);
setDescription(DESCRIPTION);
this.workbench = workbench;
@@ -308,39 +309,46 @@ public class BugzillaProductPage extends WizardPage implements Listener {
}
private String[] getSelectedProducts() {
- ArrayList<String> products = new ArrayList<String>();
+ IStructuredSelection selection = getSelection();
if (selection == null) {
- return products.toArray(new String[0]);
+ return new String[0];
}
- BugzillaRepositoryQuery query = null;
- Object element = selection.getFirstElement();
- if (element instanceof BugzillaRepositoryQuery) {
- query = (BugzillaRepositoryQuery) element;
+ ArrayList<String> products = new ArrayList<String>();
- } else if (element instanceof BugzillaQueryHit) {
- BugzillaQueryHit hit = (BugzillaQueryHit) element;
- if (hit.getParent() != null && hit.getParent() instanceof BugzillaRepositoryQuery) {
- query = (BugzillaRepositoryQuery) hit.getParent();
+ Object element = selection.getFirstElement();
+ if (element instanceof BugzillaTask) {
+ BugzillaTask task = (BugzillaTask) element;
+ products.add(task.getTaskData().getProduct());
+ } else {
+ BugzillaRepositoryQuery query = null;
+ if (element instanceof BugzillaRepositoryQuery) {
+ query = (BugzillaRepositoryQuery) element;
+
+ } else if (element instanceof BugzillaQueryHit) {
+ BugzillaQueryHit hit = (BugzillaQueryHit) element;
+ if (hit.getParent() != null && hit.getParent() instanceof BugzillaRepositoryQuery) {
+ query = (BugzillaRepositoryQuery) hit.getParent();
+ }
}
- }
-
- if (query != null) {
- String queryUrl = query.getUrl();
- queryUrl = queryUrl.substring(queryUrl.indexOf("?") + 1);
- String[] options = queryUrl.split("&");
-
- for (String option : options) {
- String key = option.substring(0, option.indexOf("="));
- if ("product".equals(key)) {
- try {
- products.add(URLDecoder.decode(option.substring(option.indexOf("=") + 1), repository
- .getCharacterEncoding()));
- // TODO: list box only accepts a single selection so we
- // break on first found
- break;
- } catch (UnsupportedEncodingException ex) {
- // ignore
+
+ if (query != null) {
+ String queryUrl = query.getUrl();
+ queryUrl = queryUrl.substring(queryUrl.indexOf("?") + 1);
+ String[] options = queryUrl.split("&");
+
+ for (String option : options) {
+ String key = option.substring(0, option.indexOf("="));
+ if ("product".equals(key)) {
+ try {
+ products.add(URLDecoder.decode(option.substring(option.indexOf("=") + 1), repository
+ .getCharacterEncoding()));
+ // TODO: list box only accepts a single selection so we
+ // break on first found
+ break;
+ } catch (UnsupportedEncodingException ex) {
+ // ignore
+ }
}
}
}
@@ -349,6 +357,15 @@ public class BugzillaProductPage extends WizardPage implements Listener {
return products.toArray(new String[products.size()]);
}
+ private IStructuredSelection getSelection() {
+ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ ISelection selection = window.getSelectionService().getSelection();
+ if(selection instanceof IStructuredSelection) {
+ return (IStructuredSelection) selection;
+ }
+ return null;
+ }
+
public void handleEvent(Event event) {
handleEventHelper(event, "You must select a product");
}
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/wizard/NewBugzillaTaskWizard.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/wizard/NewBugzillaTaskWizard.java
index 907fe0698..75984b103 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/wizard/NewBugzillaTaskWizard.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/wizard/NewBugzillaTaskWizard.java
@@ -50,8 +50,8 @@ public class NewBugzillaTaskWizard extends Wizard implements INewWizard {
// TODO: Change model to a RepositoryTaskData
// protected RepositoryTaskData model;
- public NewBugzillaTaskWizard(TaskRepository repository, IStructuredSelection selection) {
- this(false, repository, selection);
+ public NewBugzillaTaskWizard(TaskRepository repository) {
+ this(false, repository);
model = new NewBugzillaReport(repository.getUrl(), TasksUiPlugin.getDefault().getOfflineReportsFile()
.getNextOfflineBugId());
super.setDefaultPageImageDescriptor(BugzillaUiPlugin.imageDescriptorFromPlugin(
@@ -60,10 +60,10 @@ public class NewBugzillaTaskWizard extends Wizard implements INewWizard {
setNeedsProgressMonitor(true);
}
- public NewBugzillaTaskWizard(boolean fromDialog, TaskRepository repository, IStructuredSelection selection) {
+ public NewBugzillaTaskWizard(boolean fromDialog, TaskRepository repository) {
super();
this.repository = repository;
- this.productPage = new BugzillaProductPage(workbenchInstance, this, repository, selection);
+ this.productPage = new BugzillaProductPage(workbenchInstance, this, repository);
}
public void init(IWorkbench workbench, IStructuredSelection selection) {
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/connector/MockRepositoryUi.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/connector/MockRepositoryUi.java
index bf9c0c0db..6dc866ba2 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/connector/MockRepositoryUi.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/connector/MockRepositoryUi.java
@@ -8,7 +8,6 @@
package org.eclipse.mylar.tasks.tests.connector;
-import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.IWizard;
import org.eclipse.mylar.internal.tasks.ui.wizards.AbstractRepositorySettingsPage;
import org.eclipse.mylar.tasks.core.AbstractRepositoryQuery;
@@ -21,7 +20,7 @@ import org.eclipse.mylar.tasks.ui.AbstractRepositoryConnectorUi;
public class MockRepositoryUi extends AbstractRepositoryConnectorUi {
@Override
- public IWizard getNewTaskWizard(TaskRepository taskRepository, IStructuredSelection selection) {
+ public IWizard getNewTaskWizard(TaskRepository taskRepository) {
// ignore
return null;
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/AbstractRepositoryAction.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/AbstractRepositoryAction.java
deleted file mode 100644
index 3fc03626f..000000000
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/AbstractRepositoryAction.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 - 2006 Mylar committers 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
- *******************************************************************************/
-
-package org.eclipse.mylar.internal.tasks.ui.actions;
-
-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.ui.IViewActionDelegate;
-import org.eclipse.ui.IViewPart;
-
-/**
- * Abstract action used to take care of autodetecting repository based on current selection
- *
- * @author Eugene Kuleshov
- */
-public abstract class AbstractRepositoryAction extends Action implements IViewActionDelegate {
-
- private IStructuredSelection selection;
-
- public void init(IViewPart view) {
- // ignore
- }
-
- public void selectionChanged(IAction action, ISelection selection) {
- if(selection instanceof IStructuredSelection) {
- this.selection = (IStructuredSelection) selection;
- } else {
- this.selection = null;
- }
- }
-
- public IStructuredSelection getSelection() {
- return this.selection;
- }
-
-}
-
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/AddRepositoryTaskAction.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/AddRepositoryTaskAction.java
index bf9ca72bf..2d1c77c81 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/AddRepositoryTaskAction.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/AddRepositoryTaskAction.java
@@ -11,6 +11,7 @@
package org.eclipse.mylar.internal.tasks.ui.actions;
+import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.wizard.WizardDialog;
@@ -23,13 +24,13 @@ import org.eclipse.ui.PlatformUI;
* @author Mik Kersten
* @author Eugene Kuleshov
*/
-public class AddRepositoryTaskAction extends AbstractRepositoryAction {
+public class AddRepositoryTaskAction extends Action {
private static final String WIZARD_LABEL = "Add an existing repository task/issue";
public void run(IAction action) {
try {
- AddExistingTaskWizard wizard = new AddExistingTaskWizard(getSelection());
+ AddExistingTaskWizard wizard = new AddExistingTaskWizard();
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
if (shell != null && !shell.isDisposed()) {
WizardDialog dialog = new WizardDialog(shell, wizard);
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/NewQueryAction.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/NewQueryAction.java
index 7f29aff74..8739ffa77 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/NewQueryAction.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/NewQueryAction.java
@@ -11,6 +11,7 @@
package org.eclipse.mylar.internal.tasks.ui.actions;
+import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.wizard.WizardDialog;
@@ -23,13 +24,13 @@ import org.eclipse.ui.PlatformUI;
* @author Mik Kersten
* @author Eugene Kuleshov
*/
-public class NewQueryAction extends AbstractRepositoryAction {
+public class NewQueryAction extends Action {
private static final String WIZARD_LABEL = "Add or modify repository query";
public void run(IAction action) {
try {
- NewQueryWizard wizard = new NewQueryWizard(getSelection());
+ NewQueryWizard wizard = new NewQueryWizard();
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
if (shell != null && !shell.isDisposed()) {
WizardDialog dialog = new WizardDialog(shell, wizard);
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/NewRepositoryTaskAction.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/NewRepositoryTaskAction.java
index 489c2cf23..4a29a3260 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/NewRepositoryTaskAction.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/NewRepositoryTaskAction.java
@@ -13,6 +13,7 @@ package org.eclipse.mylar.internal.tasks.ui.actions;
import java.util.List;
+import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.wizard.IWizard;
import org.eclipse.jface.wizard.WizardDialog;
@@ -27,7 +28,7 @@ import org.eclipse.ui.PlatformUI;
* @author Mik Kersten
* @author Eugene Kuleshov
*/
-public class NewRepositoryTaskAction extends AbstractRepositoryAction {
+public class NewRepositoryTaskAction extends Action {
public static final String ID = "org.eclipse.mylar.tasklist.ui.repositories.actions.create";
@@ -41,9 +42,9 @@ public class NewRepositoryTaskAction extends AbstractRepositoryAction {
TaskRepository taskRepository = repositories.get(0);
AbstractRepositoryConnectorUi connectorUi = TasksUiPlugin.getRepositoryUi(taskRepository.getKind());
- wizard = connectorUi.getNewTaskWizard(taskRepository, getSelection());
+ wizard = connectorUi.getNewTaskWizard(taskRepository);
} else {
- wizard = new NewRepositoryTaskWizard(getSelection());
+ wizard = new NewRepositoryTaskWizard();
}
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/AddExistingTaskWizard.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/AddExistingTaskWizard.java
index 294f005a7..9400c7dee 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/AddExistingTaskWizard.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/AddExistingTaskWizard.java
@@ -11,7 +11,6 @@
package org.eclipse.mylar.internal.tasks.ui.wizards;
-import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.IWizard;
import org.eclipse.mylar.tasks.core.TaskRepository;
import org.eclipse.mylar.tasks.core.TaskRepositoryFilter;
@@ -28,8 +27,8 @@ public class AddExistingTaskWizard extends MultiRepositoryAwareWizard {
public static final String TITLE = "Add Existing Repository Task";
- public AddExistingTaskWizard(IStructuredSelection selection) {
- super(new SelectRepositoryPageForAddExistingTask(TaskRepositoryFilter.CAN_CREATE_TASK_FROM_KEY).setSelection(selection), TITLE);
+ public AddExistingTaskWizard() {
+ super(new SelectRepositoryPageForAddExistingTask(TaskRepositoryFilter.CAN_CREATE_TASK_FROM_KEY), TITLE);
}
private static final class SelectRepositoryPageForAddExistingTask extends SelectRepositoryPage {
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/NewQueryWizard.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/NewQueryWizard.java
index 282a845b0..214ad5e23 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/NewQueryWizard.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/NewQueryWizard.java
@@ -11,7 +11,6 @@
package org.eclipse.mylar.internal.tasks.ui.wizards;
-import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.IWizard;
import org.eclipse.mylar.tasks.core.TaskRepository;
import org.eclipse.mylar.tasks.core.TaskRepositoryFilter;
@@ -29,10 +28,7 @@ public class NewQueryWizard extends MultiRepositoryAwareWizard {
public NewQueryWizard() {
super(new SelectRepositoryPageForNewQuery(), TITLE);
}
-
- public NewQueryWizard(IStructuredSelection selection) {
- super(new SelectRepositoryPageForNewQuery().setSelection(selection), TITLE);
- }
+
private static final class SelectRepositoryPageForNewQuery extends SelectRepositoryPage {
public SelectRepositoryPageForNewQuery() {
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/NewRepositoryTaskPage.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/NewRepositoryTaskPage.java
index be88ea084..965378cf2 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/NewRepositoryTaskPage.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/NewRepositoryTaskPage.java
@@ -19,7 +19,7 @@ import org.eclipse.mylar.tasks.ui.TasksUiPlugin;
/**
* @author Mik Kersten
- * @author Euegene Kuleshov
+ * @author Eugene Kuleshov
*/
public class NewRepositoryTaskPage extends SelectRepositoryPage {
@@ -31,7 +31,7 @@ public class NewRepositoryTaskPage extends SelectRepositoryPage {
protected IWizard createWizard(TaskRepository taskRepository) {
AbstractRepositoryConnectorUi connectorUi = TasksUiPlugin.getRepositoryUi(
taskRepository.getKind());
- return connectorUi.getNewTaskWizard(taskRepository, getSelection());
+ return connectorUi.getNewTaskWizard(taskRepository); // TODO remove unused parameter
}
} \ No newline at end of file
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/NewRepositoryTaskWizard.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/NewRepositoryTaskWizard.java
index 1a3ac7934..18ae56bfc 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/NewRepositoryTaskWizard.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/NewRepositoryTaskWizard.java
@@ -11,7 +11,6 @@
package org.eclipse.mylar.internal.tasks.ui.wizards;
-import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.mylar.tasks.core.TaskRepositoryFilter;
/**
@@ -28,9 +27,4 @@ public class NewRepositoryTaskWizard extends MultiRepositoryAwareWizard {
setNeedsProgressMonitor(true);
}
- public NewRepositoryTaskWizard(IStructuredSelection selection) {
- super(new NewRepositoryTaskPage(TaskRepositoryFilter.CAN_CREATE_NEW_TASK).setSelection(selection), TITLE);
- setNeedsProgressMonitor(true);
- }
-
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/SelectRepositoryPage.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/SelectRepositoryPage.java
index 28e7d0b74..c52ae38a6 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/SelectRepositoryPage.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/SelectRepositoryPage.java
@@ -15,8 +15,11 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Set;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.viewers.DecoratingLabelProvider;
import org.eclipse.jface.viewers.IOpenListener;
+import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
@@ -48,6 +51,7 @@ import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Table;
+import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
/**
@@ -69,8 +73,6 @@ public abstract class SelectRepositoryPage extends WizardSelectionPage {
private List<TaskRepository> repositories = new ArrayList<TaskRepository>();
- private IStructuredSelection selection;
-
private final TaskRepositoryFilter taskRepositoryFilter;
class RepositoryContentProvider implements IStructuredContentProvider {
@@ -111,15 +113,6 @@ public abstract class SelectRepositoryPage extends WizardSelectionPage {
return repositories;
}
- public SelectRepositoryPage setSelection(IStructuredSelection selection) {
- this.selection = selection;
- return this;
- }
-
- public IStructuredSelection getSelection() {
- return this.selection;
- }
-
public void createControl(Composite parent) {
Composite container = new Composite(parent, SWT.NULL);
GridLayout layout = new GridLayout(1, true);
@@ -179,6 +172,7 @@ public abstract class SelectRepositoryPage extends WizardSelectionPage {
}
protected TaskRepository getSelectedRepository() {
+ IStructuredSelection selection = getSelection();
if (selection == null) {
return (TaskRepository) viewer.getElementAt(0);
}
@@ -198,11 +192,27 @@ public abstract class SelectRepositoryPage extends WizardSelectionPage {
} else if (element instanceof AbstractRepositoryTask) {
AbstractRepositoryTask task = (AbstractRepositoryTask) element;
return getRepository(task.getRepositoryUrl(), task.getRepositoryKind());
+ } else if (element instanceof IResource) {
+ IResource resource = (IResource) element;
+ return TasksUiPlugin.getDefault().getRepositoryForResource(resource, true);
+ } else if( element instanceof IAdaptable) {
+ IResource resource = (IResource) ((IAdaptable) element).getAdapter(IResource.class);
+ return TasksUiPlugin.getDefault().getRepositoryForResource(resource, true);
}
+
+ // TODO mapping between LogEntry.pliginId and repositories
- // TODO handle project (when link from projects to repositories is
- // implemented)
+ // TODO handle other selection types
+
+ return null;
+ }
+ private IStructuredSelection getSelection() {
+ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ ISelection selection = window.getSelectionService().getSelection();
+ if(selection instanceof IStructuredSelection) {
+ return (IStructuredSelection) selection;
+ }
return null;
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/AbstractRepositoryConnectorUi.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/AbstractRepositoryConnectorUi.java
index 7f3cae3ec..c92ec39ab 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/AbstractRepositoryConnectorUi.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/AbstractRepositoryConnectorUi.java
@@ -42,7 +42,8 @@ public abstract class AbstractRepositoryConnectorUi {
*/
public abstract IWizard getQueryWizard(TaskRepository repository, AbstractRepositoryQuery queryToEdit);
- public abstract IWizard getNewTaskWizard(TaskRepository taskRepository, IStructuredSelection selection);
+ // XXX remove unused selection parameter
+ public abstract IWizard getNewTaskWizard(TaskRepository taskRepository);
public abstract boolean hasRichEditor();
diff --git a/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/TracRepositoryUi.java b/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/TracRepositoryUi.java
index 7edc0fd0f..5d5690822 100644
--- a/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/TracRepositoryUi.java
+++ b/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/TracRepositoryUi.java
@@ -56,7 +56,7 @@ public class TracRepositoryUi extends AbstractRepositoryConnectorUi {
}
@Override
- public IWizard getNewTaskWizard(TaskRepository repository, IStructuredSelection selection) {
+ public IWizard getNewTaskWizard(TaskRepository repository) {
if (TracRepositoryConnector.hasRichEditor(repository)) {
return new NewTracTaskWizard(repository);
} else {

Back to the top