Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormkersten2007-01-05 19:38:47 +0000
committermkersten2007-01-05 19:38:47 +0000
commita7db52867d362dfd3c9fa7ea79a9e6b5c5f927b8 (patch)
tree8f60c58b4621a1d75fe525e47f43f35903054746
parentf7b9e4cc307db56c7495feb33ca7eae0cd438e06 (diff)
downloadorg.eclipse.mylyn.tasks-a7db52867d362dfd3c9fa7ea79a9e6b5c5f927b8.tar.gz
org.eclipse.mylyn.tasks-a7db52867d362dfd3c9fa7ea79a9e6b5c5f927b8.tar.xz
org.eclipse.mylyn.tasks-a7db52867d362dfd3c9fa7ea79a9e6b5c5f927b8.zip
RESOLVED - bug 169018: Include a "Add Attachment" action to task editor's context menu
https://bugs.eclipse.org/bugs/show_bug.cgi?id=169018
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditor.java38
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/AttachFileAction.java44
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorActionContributor.java17
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractRepositoryTaskEditor.java35
-rw-r--r--org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/editor/TracTaskEditor.java36
5 files changed, 122 insertions, 48 deletions
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditor.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditor.java
index 687b59231..f707c6fa6 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditor.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditor.java
@@ -36,9 +36,6 @@ import org.eclipse.mylar.tasks.ui.DatePicker;
import org.eclipse.mylar.tasks.ui.TasksUiPlugin;
import org.eclipse.mylar.tasks.ui.TasksUiUtil;
import org.eclipse.mylar.tasks.ui.editors.AbstractRepositoryTaskEditor;
-import org.eclipse.mylar.tasks.ui.editors.AbstractTaskEditorInput;
-import org.eclipse.mylar.tasks.ui.editors.RepositoryTaskEditorInput;
-import org.eclipse.mylar.tasks.ui.editors.RepositoryTaskOutlineNode;
import org.eclipse.mylar.tasks.ui.editors.RepositoryTaskSelection;
import org.eclipse.mylar.tasks.ui.editors.TaskEditor;
import org.eclipse.swt.SWT;
@@ -123,23 +120,26 @@ public class BugzillaTaskEditor extends AbstractRepositoryTaskEditor {
@Override
public void init(IEditorSite site, IEditorInput input) {
- if (!(input instanceof RepositoryTaskEditorInput))
- return;// MylarStatusHandler.log("Invalid Input: Must be
- // RepositoryTaskEditorInput", this);
-
- editorInput = (AbstractTaskEditorInput) input;
+ super.init(site, input);
taskData = editorInput.getTaskData();
- repository = editorInput.getRepository();
- connector = TasksUiPlugin.getRepositoryManager().getRepositoryConnector(repository.getKind());
-
- setSite(site);
- setInput(input);
-
- taskOutlineModel = RepositoryTaskOutlineNode.parseBugReport(editorInput.getTaskData());
-
- // restoreBug();
- isDirty = false;
- updateEditorTitle();
+// if (!(input instanceof RepositoryTaskEditorInput)) {
+// return;
+// }
+// super.init(site, input);
+//
+// editorInput = (AbstractTaskEditorInput) input;
+// taskData = editorInput.getTaskData();
+// repository = editorInput.getRepository();
+// connector = TasksUiPlugin.getRepositoryManager().getRepositoryConnector(repository.getKind());
+//
+// setSite(site);
+// setInput(input);
+//
+// taskOutlineModel = RepositoryTaskOutlineNode.parseBugReport(editorInput.getTaskData());
+//
+// // restoreBug();
+// isDirty = false;
+// updateEditorTitle();
}
@Override
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/AttachFileAction.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/AttachFileAction.java
new file mode 100644
index 000000000..147c596ec
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/AttachFileAction.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * 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.mylar.internal.tasks.ui.wizards.NewAttachmentWizard;
+import org.eclipse.mylar.internal.tasks.ui.wizards.NewAttachmentWizardDialog;
+import org.eclipse.mylar.tasks.core.AbstractRepositoryTask;
+import org.eclipse.mylar.tasks.core.TaskRepository;
+import org.eclipse.mylar.tasks.ui.TasksUiPlugin;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.BaseSelectionListenerAction;
+
+/**
+ * @author Mik Kersten
+ */
+public class AttachFileAction extends BaseSelectionListenerAction {
+
+ public AttachFileAction() {
+ super("Attach File...");
+ setId("org.eclipse.mylar.tasks.ui.actions.add.attachment");
+ }
+
+ @Override
+ public void run() {
+ Object selection = super.getStructuredSelection().getFirstElement();
+ if (selection instanceof AbstractRepositoryTask) {
+ AbstractRepositoryTask repositoryTask = (AbstractRepositoryTask)selection;
+ TaskRepository repository = TasksUiPlugin.getRepositoryManager().getRepository(repositoryTask.getUrl());
+
+ NewAttachmentWizard attachmentWizard = new NewAttachmentWizard(repository, repositoryTask);
+ NewAttachmentWizardDialog dialog = new NewAttachmentWizardDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), attachmentWizard);
+ attachmentWizard.setDialog(dialog);
+ dialog.create();
+ dialog.open();
+ }
+ }
+
+}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorActionContributor.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorActionContributor.java
index 5c78028b0..75b94510e 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorActionContributor.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorActionContributor.java
@@ -25,13 +25,16 @@ import org.eclipse.jface.action.Separator;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.mylar.internal.tasks.ui.IDynamicSubMenuContributor;
+import org.eclipse.mylar.internal.tasks.ui.actions.AttachFileAction;
import org.eclipse.mylar.internal.tasks.ui.actions.CopyTaskDetailsAction;
import org.eclipse.mylar.internal.tasks.ui.actions.OpenWithBrowserAction;
import org.eclipse.mylar.internal.tasks.ui.actions.TaskActivateAction;
import org.eclipse.mylar.internal.tasks.ui.actions.TaskDeactivateAction;
+import org.eclipse.mylar.tasks.core.AbstractRepositoryTask;
import org.eclipse.mylar.tasks.core.ITask;
import org.eclipse.mylar.tasks.core.ITaskListElement;
import org.eclipse.mylar.tasks.ui.TasksUiPlugin;
@@ -66,6 +69,8 @@ public class TaskEditorActionContributor extends MultiPageEditorActionBarContrib
private CopyTaskDetailsAction copyTaskDetailsAction = new CopyTaskDetailsAction(false);
+ private AttachFileAction attachFileAction = new AttachFileAction();
+
private GlobalAction cutAction;
private GlobalAction undoAction;
@@ -159,11 +164,17 @@ public class TaskEditorActionContributor extends MultiPageEditorActionBarContrib
return;
} else {
// TODO: refactor
- openWithBrowserAction.selectionChanged(new StructuredSelection(task));
- copyTaskDetailsAction.selectionChanged(new StructuredSelection(task));
+ IStructuredSelection selection = new StructuredSelection(task);
+
+ openWithBrowserAction.selectionChanged(selection);
+ copyTaskDetailsAction.selectionChanged(selection);
+ attachFileAction.selectionChanged(selection);
manager.add(openWithBrowserAction);
-
+ if (task instanceof AbstractRepositoryTask) {
+ manager.add(attachFileAction);
+ }
+
if (task.isActive()) {
manager.add(new TaskDeactivateAction() {
@Override
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractRepositoryTaskEditor.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractRepositoryTaskEditor.java
index cacff80d5..e02d6647c 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractRepositoryTaskEditor.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractRepositoryTaskEditor.java
@@ -66,6 +66,7 @@ import org.eclipse.mylar.internal.context.core.util.DateUtil;
import org.eclipse.mylar.internal.tasks.core.CommentQuoter;
import org.eclipse.mylar.internal.tasks.ui.TaskListColorsAndFonts;
import org.eclipse.mylar.internal.tasks.ui.TaskListImages;
+import org.eclipse.mylar.internal.tasks.ui.actions.AttachFileAction;
import org.eclipse.mylar.internal.tasks.ui.actions.CopyToClipboardAction;
import org.eclipse.mylar.internal.tasks.ui.actions.SaveRemoteFileAction;
import org.eclipse.mylar.internal.tasks.ui.editors.ContentOutlineTools;
@@ -282,7 +283,7 @@ public abstract class AbstractRepositoryTaskEditor extends TaskFormPage {
protected RetargetAction cutAction;
protected RetargetAction pasteAction;
-
+
protected Composite editorComposite;
protected TextViewer newCommentTextViewer;
@@ -530,7 +531,22 @@ public abstract class AbstractRepositoryTaskEditor extends TaskFormPage {
@Override
public void init(IEditorSite site, IEditorInput input) {
- super.init(site, input);
+ if (!(input instanceof RepositoryTaskEditorInput)) {
+ return;
+ }
+
+ editorInput = (AbstractTaskEditorInput) input;
+ repository = editorInput.getRepository();
+ connector = TasksUiPlugin.getRepositoryManager().getRepositoryConnector(repository.getKind());
+
+ setSite(site);
+ setInput(input);
+
+ taskOutlineModel = RepositoryTaskOutlineNode.parseBugReport(editorInput.getTaskData());
+
+ // restoreBug();
+ isDirty = false;
+ updateEditorTitle();
}
public String getNewCommentText() {
@@ -1155,13 +1171,16 @@ public abstract class AbstractRepositoryTaskEditor extends TaskFormPage {
"Task not synchronized or dirty editor",
"Commit edits or synchronize task before adding attachments.");
return;
+ } else {
+ AttachFileAction attachFileAction = new AttachFileAction();
+ attachFileAction.selectionChanged(new StructuredSelection(task));
+ attachFileAction.run();
}
-
- NewAttachmentWizard naw = new NewAttachmentWizard(repository, (AbstractRepositoryTask) task);
- NewAttachmentWizardDialog dialog = new NewAttachmentWizardDialog(attachmentsComposite.getShell(), naw);
- naw.setDialog(dialog);
- dialog.create();
- dialog.open();
+// NewAttachmentWizard naw = new NewAttachmentWizard(repository, (AbstractRepositoryTask) task);
+// NewAttachmentWizardDialog dialog = new NewAttachmentWizardDialog(attachmentsComposite.getShell(), naw);
+// naw.setDialog(dialog);
+// dialog.create();
+// dialog.open();
}
});
diff --git a/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/editor/TracTaskEditor.java b/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/editor/TracTaskEditor.java
index 282c75a0c..fd006a6cc 100644
--- a/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/editor/TracTaskEditor.java
+++ b/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/editor/TracTaskEditor.java
@@ -27,9 +27,6 @@ import org.eclipse.mylar.internal.trac.ui.TracUiPlugin;
import org.eclipse.mylar.tasks.core.AbstractRepositoryTask;
import org.eclipse.mylar.tasks.ui.TasksUiPlugin;
import org.eclipse.mylar.tasks.ui.editors.AbstractRepositoryTaskEditor;
-import org.eclipse.mylar.tasks.ui.editors.AbstractTaskEditorInput;
-import org.eclipse.mylar.tasks.ui.editors.RepositoryTaskEditorInput;
-import org.eclipse.mylar.tasks.ui.editors.RepositoryTaskOutlineNode;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorSite;
import org.eclipse.ui.PlatformUI;
@@ -49,21 +46,24 @@ public class TracTaskEditor extends AbstractRepositoryTaskEditor {
@Override
public void init(IEditorSite site, IEditorInput input) {
- if (!(input instanceof RepositoryTaskEditorInput))
- return;
-
- editorInput = (AbstractTaskEditorInput) input;
- repository = editorInput.getRepository();
- connector = TasksUiPlugin.getRepositoryManager().getRepositoryConnector(
- repository.getKind());
-
- setSite(site);
- setInput(input);
-
- taskOutlineModel = RepositoryTaskOutlineNode.parseBugReport(editorInput.getTaskData());
-
- isDirty = false;
- updateEditorTitle();
+ super.init(site, input);
+// if (!(input instanceof RepositoryTaskEditorInput)) {
+// return;
+// }
+// super.init(site, input);
+//
+// editorInput = (AbstractTaskEditorInput) input;
+// repository = editorInput.getRepository();
+// connector = TasksUiPlugin.getRepositoryManager().getRepositoryConnector(
+// repository.getKind());
+//
+// setSite(site);
+// setInput(input);
+//
+// taskOutlineModel = RepositoryTaskOutlineNode.parseBugReport(editorInput.getTaskData());
+//
+// isDirty = false;
+// updateEditorTitle();
}
@Override

Back to the top