Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormkersten2006-07-12 01:46:05 +0000
committermkersten2006-07-12 01:46:05 +0000
commit4cee1c38fd292cb5cbd951caf399fb22f5f132ca (patch)
tree3c24962ff00fd60c6c768f531308df3a8133d310
parent4b751121eca0d11bd88252185ec383139a633d40 (diff)
downloadorg.eclipse.mylyn.tasks-4cee1c38fd292cb5cbd951caf399fb22f5f132ca.tar.gz
org.eclipse.mylyn.tasks-4cee1c38fd292cb5cbd951caf399fb22f5f132ca.tar.xz
org.eclipse.mylyn.tasks-4cee1c38fd292cb5cbd951caf399fb22f5f132ca.zip
Progress on: 135605: Allow to create new issues from PDE Error Log view
https://bugs.eclipse.org/bugs/show_bug.cgi?id=135605
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/wizard/BugzillaProductPage.java5
-rw-r--r--org.eclipse.mylyn.help.ui/doc/new.html1
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasklist/tests/AllTaskListTests.java1
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasklist/tests/TaskEditorTest.java59
-rw-r--r--org.eclipse.mylyn.tasks.ui/META-INF/MANIFEST.MF3
-rw-r--r--org.eclipse.mylyn.tasks.ui/plugin.xml11
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasklist/ui/actions/NewTaskFromErrorAction.java105
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasklist/ui/editors/AbstractRepositoryTaskEditor.java9
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasklist/ui/wizards/NewRepositoryTaskWizard.java13
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasklist/ui/wizards/SelectRepositoryPage.java46
10 files changed, 227 insertions, 26 deletions
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 f9c4898e6..0942ea47f 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
@@ -281,7 +281,10 @@ public class BugzillaProductPage extends WizardPage implements Listener {
private String[] getSelectedProducts() {
ArrayList<String> products = new ArrayList<String>();
-
+ if (selection == null) {
+ return products.toArray(new String[0]);
+ }
+
Object element = selection.getFirstElement();
if (element instanceof BugzillaRepositoryQuery) {
BugzillaRepositoryQuery query = (BugzillaRepositoryQuery) element;
diff --git a/org.eclipse.mylyn.help.ui/doc/new.html b/org.eclipse.mylyn.help.ui/doc/new.html
index 45c126b34..d3df04aa4 100644
--- a/org.eclipse.mylyn.help.ui/doc/new.html
+++ b/org.eclipse.mylyn.help.ui/doc/new.html
@@ -49,6 +49,7 @@ Mylar 0.3.x</a></b></li>
<p>TO ADD:</p>
<ul>
<li>Drag and drop of contexts</li>
+ <li>Report bugs directly from Error Log view</li>
</ul>
<h2>Task List</h2>
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 b3a9b2fea..dcc4a93cb 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
@@ -48,6 +48,7 @@ public class AllTaskListTests {
suite.addTestSuite(TaskAttachmentActionsTest.class);
suite.addTestSuite(RepositorySettingsPageTest.class);
// suite.addTestSuite(RetrieveTitleFromUrlTest.class);
+ suite.addTestSuite(TaskEditorTest.class);
// $JUnit-END$
return suite;
}
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasklist/tests/TaskEditorTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasklist/tests/TaskEditorTest.java
new file mode 100644
index 000000000..11243e204
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasklist/tests/TaskEditorTest.java
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * 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.tasklist.tests;
+
+import junit.framework.TestCase;
+
+import org.eclipse.mylar.internal.bugzilla.core.BugzillaPlugin;
+import org.eclipse.mylar.internal.bugzilla.core.IBugzillaConstants;
+import org.eclipse.mylar.internal.bugzilla.core.NewBugzillaReport;
+import org.eclipse.mylar.internal.bugzilla.ui.BugzillaUiPlugin;
+import org.eclipse.mylar.internal.bugzilla.ui.editor.NewBugEditorInput;
+import org.eclipse.mylar.internal.tasklist.ui.TaskUiUtil;
+import org.eclipse.mylar.internal.tasklist.ui.editors.AbstractRepositoryTaskEditor;
+import org.eclipse.mylar.provisional.tasklist.MylarTaskListPlugin;
+import org.eclipse.mylar.provisional.tasklist.TaskRepository;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ *
+ * @author Jeff Pound
+ */
+public class TaskEditorTest extends TestCase {
+
+ /**
+ * Automated task creation needs to access newly created task editors. This
+ * test tests that the access is available.
+ *
+ * @throws Exception
+ */
+ public void testAccessNewEditor() throws Exception {
+ TaskRepository repository = new TaskRepository(BugzillaPlugin.REPOSITORY_KIND,
+ IBugzillaConstants.TEST_BUGZILLA_222_URL);
+
+ NewBugzillaReport model = new NewBugzillaReport(repository.getUrl(), MylarTaskListPlugin.getDefault()
+ .getOfflineReportsFile().getNextOfflineBugId());
+ NewBugEditorInput editorInput = new NewBugEditorInput(repository, model);
+ IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ TaskUiUtil.openEditor(editorInput, BugzillaUiPlugin.NEW_BUG_EDITOR_ID, page);
+
+ assertTrue(page.getActiveEditor() instanceof AbstractRepositoryTaskEditor);
+ AbstractRepositoryTaskEditor editor = (AbstractRepositoryTaskEditor) page.getActiveEditor();
+
+ String desc = "description";
+ String summary = "summary";
+ // ensure we have access without exceptions
+ editor.setDescriptionText(desc);
+ editor.setSummaryText(summary);
+
+ editor.changeDirtyStatus(false);
+ editor.close();
+ }
+}
diff --git a/org.eclipse.mylyn.tasks.ui/META-INF/MANIFEST.MF b/org.eclipse.mylyn.tasks.ui/META-INF/MANIFEST.MF
index 33cfd45d0..3f733153b 100644
--- a/org.eclipse.mylyn.tasks.ui/META-INF/MANIFEST.MF
+++ b/org.eclipse.mylyn.tasks.ui/META-INF/MANIFEST.MF
@@ -16,7 +16,8 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.ui.views,
org.eclipse.core.resources,
org.eclipse.ui.ide,
- org.eclipse.ui.workbench.texteditor
+ org.eclipse.ui.workbench.texteditor,
+ org.eclipse.pde.runtime
Eclipse-AutoStart: true
Bundle-Vendor: Eclipse.org
Export-Package: org.eclipse.mylar.internal.tasklist,
diff --git a/org.eclipse.mylyn.tasks.ui/plugin.xml b/org.eclipse.mylyn.tasks.ui/plugin.xml
index 5944ae8a4..f2a066506 100644
--- a/org.eclipse.mylyn.tasks.ui/plugin.xml
+++ b/org.eclipse.mylyn.tasks.ui/plugin.xml
@@ -298,6 +298,17 @@
tooltip="New Repository Query">
</action>
</viewerContribution>
+
+ <viewerContribution
+ id="org.eclipse.mylar.tasklist.ui.objectContribution"
+ targetID="org.eclipse.pde.runtime.LogView">
+ <action
+ class="org.eclipse.mylar.internal.tasklist.ui.actions.NewTaskFromErrorAction"
+ icon="icons/etool16/task-repository-new.gif"
+ id="org.eclipse.mylar.tasklist.actions.newTaskFromErrorLog"
+ label="Report Error Event"
+ menubarPath="org.eclipse.pde.runtime.LogView"/>
+ </viewerContribution>
</extension>
<extension point="org.eclipse.ui.preferencePages">
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasklist/ui/actions/NewTaskFromErrorAction.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasklist/ui/actions/NewTaskFromErrorAction.java
new file mode 100644
index 000000000..27e24a9ae
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasklist/ui/actions/NewTaskFromErrorAction.java
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * Copyright (c) 2004 - 2006 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.internal.tasklist.ui.actions;
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.mylar.internal.tasklist.TaskListPreferenceConstants;
+import org.eclipse.mylar.internal.tasklist.ui.editors.AbstractRepositoryTaskEditor;
+import org.eclipse.mylar.internal.tasklist.ui.wizards.NewRepositoryTaskWizard;
+import org.eclipse.mylar.provisional.tasklist.MylarTaskListPlugin;
+import org.eclipse.pde.internal.runtime.logview.LogEntry;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IViewActionDelegate;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * Creates a new task from the selected error log entry.
+ *
+ * @author Jeff Pound
+ */
+public class NewTaskFromErrorAction implements IViewActionDelegate, ISelectionChangedListener {
+
+ public static final String ID = "org.eclipse.mylar.tasklist.ui.repositories.actions.create";
+
+ private LogEntry selection;
+
+ public void run() {
+ boolean offline = MylarTaskListPlugin.getMylarCorePrefs().getBoolean(TaskListPreferenceConstants.WORK_OFFLINE);
+ if (offline) {
+ MessageDialog.openInformation(null, "Unable to create bug report",
+ "Unable to create a new bug report since you are currently offline");
+ return;
+ }
+
+ IWizard wizard = new NewRepositoryTaskWizard();
+
+ Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
+ if (wizard != null && shell != null && !shell.isDisposed()) {
+
+ WizardDialog dialog = new WizardDialog(shell, wizard);
+ dialog.setBlockOnOpen(true);
+ if (dialog.open() == WizardDialog.CANCEL) {
+ return;
+ }
+
+ IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ AbstractRepositoryTaskEditor editor = null;
+ try {
+ editor = (AbstractRepositoryTaskEditor) page.getActiveEditor();
+ } catch (ClassCastException e) {
+ // TODO: Handle error if editor is not created.
+ System.err.println(e);
+ }
+
+ editor.setSummaryText(selection.getSeverityText() + ": \"" + selection.getMessage() + "\" in "
+ + selection.getPluginId());
+ editor.setDescriptionText("\n\n-- Error Log --\nDate: " + selection.getDate() + "\nMessage: "
+ + selection.getMessage() + "\nSeverity: " + selection.getSeverityText() + "\nPlugin ID: "
+ + selection.getPluginId() + "\nStack Trace:\n"
+ + ((selection.getStack() == null) ? "no stack trace available" : selection.getStack()));
+
+ }
+ }
+
+ public void selectionChanged(IAction action, ISelection selection) {
+ // this selection is always empty? explicitly register a listener in
+ // init() instead
+ }
+
+ public void init(IViewPart view) {
+ ISelectionProvider sp = view.getViewSite().getSelectionProvider();
+ sp.addSelectionChangedListener(this);
+ sp.setSelection(sp.getSelection());
+ }
+
+ public void run(IAction action) {
+ run();
+ }
+
+ public void selectionChanged(SelectionChangedEvent event) {
+ selection = (LogEntry) ((TreeViewer) event.getSource()).getTree().getSelection()[0].getData();
+ }
+
+ public void setSelection(LogEntry l) {
+ selection = l;
+ }
+}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasklist/ui/editors/AbstractRepositoryTaskEditor.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasklist/ui/editors/AbstractRepositoryTaskEditor.java
index f781edcc2..609e9fb52 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasklist/ui/editors/AbstractRepositoryTaskEditor.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasklist/ui/editors/AbstractRepositoryTaskEditor.java
@@ -1960,6 +1960,15 @@ public abstract class AbstractRepositoryTaskEditor extends EditorPart {
return form;
}
+
+ public void setSummaryText(String text) {
+ this.summaryText.setText(text);
+ }
+
+ public void setDescriptionText(String text) {
+ this.descriptionTextBox.setText(text);
+ }
+
// private void addHyperlinks(final StyledText styledText, Composite
// composite) {
//
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasklist/ui/wizards/NewRepositoryTaskWizard.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasklist/ui/wizards/NewRepositoryTaskWizard.java
index ff6180dc8..a648f3c58 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasklist/ui/wizards/NewRepositoryTaskWizard.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasklist/ui/wizards/NewRepositoryTaskWizard.java
@@ -25,7 +25,12 @@ import org.eclipse.mylar.provisional.tasklist.MylarTaskListPlugin;
public class NewRepositoryTaskWizard extends MultiRepositoryAwareWizard {
private static final String TITLE = "New Repostiory Task";
-
+
+ public NewRepositoryTaskWizard() {
+ super(new NewRepositoryTaskPage(getConnectorKinds()), TITLE);
+ setNeedsProgressMonitor(true);
+ }
+
public NewRepositoryTaskWizard(IStructuredSelection selection) {
super(new NewRepositoryTaskPage(getConnectorKinds()).setSelection(selection), TITLE);
setNeedsProgressMonitor(true);
@@ -33,11 +38,11 @@ public class NewRepositoryTaskWizard extends MultiRepositoryAwareWizard {
private static List<String> getConnectorKinds() {
List<String> connectorKinds = new ArrayList<String>();
- for (AbstractRepositoryConnector client: MylarTaskListPlugin.getRepositoryManager().getRepositoryConnectors()) {
+ for (AbstractRepositoryConnector client : MylarTaskListPlugin.getRepositoryManager().getRepositoryConnectors()) {
if (client.canCreateNewTask()) {
connectorKinds.add(client.getRepositoryType());
- }
- }
+ }
+ }
return connectorKinds;
}
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasklist/ui/wizards/SelectRepositoryPage.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasklist/ui/wizards/SelectRepositoryPage.java
index dd189cf8e..87e59dd09 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasklist/ui/wizards/SelectRepositoryPage.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasklist/ui/wizards/SelectRepositoryPage.java
@@ -44,8 +44,8 @@ import org.eclipse.swt.widgets.Composite;
*/
public abstract class SelectRepositoryPage extends WizardSelectionPage {
- private static final String DESCRIPTION = "Add new repositories using the " + TaskRepositoriesView.NAME + " view.\n"
- + "If a repsitory is missing it does not support the requested operation.";
+ private static final String DESCRIPTION = "Add new repositories using the " + TaskRepositoriesView.NAME
+ + " view.\n" + "If a repsitory is missing it does not support the requested operation.";
private static final String TITLE = "Select a repository";
@@ -93,11 +93,11 @@ public abstract class SelectRepositoryPage extends WizardSelectionPage {
this.selection = selection;
return this;
}
-
+
public IStructuredSelection getSelection() {
return this.selection;
}
-
+
public void createControl(Composite parent) {
Composite container = new Composite(parent, SWT.NULL);
FillLayout layout = new FillLayout();
@@ -120,7 +120,7 @@ public abstract class SelectRepositoryPage extends WizardSelectionPage {
});
viewer.setSelection(new StructuredSelection(new Object[] { getSelectedRepository() }));
-
+
viewer.addOpenListener(new IOpenListener() {
public void open(OpenEvent event) {
@@ -130,42 +130,48 @@ public abstract class SelectRepositoryPage extends WizardSelectionPage {
});
viewer.getTable().showSelection();
viewer.getTable().setFocus();
-
-// TaskRepository defaultRepository = MylarTaskListPlugin.getRepositoryManager().getDefaultRepository(
-// repositoryKind);
-// if (defaultRepository != null) {
-// viewer.setSelection(new StructuredSelection(defaultRepository));
-// }
+
+ // TaskRepository defaultRepository =
+ // MylarTaskListPlugin.getRepositoryManager().getDefaultRepository(
+ // repositoryKind);
+ // if (defaultRepository != null) {
+ // viewer.setSelection(new StructuredSelection(defaultRepository));
+ // }
setControl(container);
}
protected TaskRepository getSelectedRepository() {
+ if (selection == null) {
+ return (TaskRepository) viewer.getElementAt(0);
+ }
+
Object element = selection.getFirstElement();
- if(element instanceof AbstractRepositoryQuery) {
+ if (element instanceof AbstractRepositoryQuery) {
AbstractRepositoryQuery query = (AbstractRepositoryQuery) element;
return getRepository(query.getRepositoryUrl(), query.getRepositoryKind());
- } else if(element instanceof AbstractQueryHit) {
+ } else if (element instanceof AbstractQueryHit) {
AbstractQueryHit queryHit = (AbstractQueryHit) element;
AbstractRepositoryTask correspondingTask = queryHit.getOrCreateCorrespondingTask();
// TODO unclear how to properly get repository kind in this case
return getRepository(queryHit.getRepositoryUrl(), correspondingTask.getRepositoryKind());
-
- } else if(element instanceof AbstractRepositoryTask) {
+
+ } else if (element instanceof AbstractRepositoryTask) {
AbstractRepositoryTask task = (AbstractRepositoryTask) element;
return getRepository(task.getRepositoryUrl(), task.getRepositoryKind());
}
-
- // TODO handle task, query hit and project (when link to repository will be implementd)
-
+
+ // TODO handle task, query hit and project (when link to repository will
+ // be implementd)
+
return null;
}
private TaskRepository getRepository(String repositoryUrl, String repositoryKind) {
- return MylarTaskListPlugin.getRepositoryManager().getRepository(repositoryKind , repositoryUrl);
+ return MylarTaskListPlugin.getRepositoryManager().getRepository(repositoryKind, repositoryUrl);
}
-
+
protected abstract IWizard createWizard(TaskRepository taskRepository);
private class CustomWizardNode implements IWizardNode {

Back to the top