Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfbecker2010-07-10 14:42:22 +0000
committerfbecker2010-07-10 14:42:22 +0000
commit0f4320cb705a930e33f87a07d76e245fd545d52a (patch)
tree1120600442a414a788e99df4255c7a896cf2b2ca /org.eclipse.mylyn.bugzilla.ui
parent8e9e05a294f4d6f47156726fc4afb3c0778cda8d (diff)
downloadorg.eclipse.mylyn.tasks-0f4320cb705a930e33f87a07d76e245fd545d52a.tar.gz
org.eclipse.mylyn.tasks-0f4320cb705a930e33f87a07d76e245fd545d52a.tar.xz
org.eclipse.mylyn.tasks-0f4320cb705a930e33f87a07d76e245fd545d52a.zip
ASSIGNED - bug 317751: Details and Mark as menu on attachment shows on all connectors
https://bugs.eclipse.org/bugs/show_bug.cgi?id=317751
Diffstat (limited to 'org.eclipse.mylyn.bugzilla.ui')
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/plugin.properties10
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/plugin.xml39
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/action/BugzillaAttachmentUpdateAction.java168
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/action/BugzillaNotObsoleteAttachmentAction.java24
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/action/BugzillaObsoleteAttachmentAction.java23
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/action/BugzillaUpdateAttachmentAction.java115
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaAttachmentPart.java246
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditorPage.java14
8 files changed, 261 insertions, 378 deletions
diff --git a/org.eclipse.mylyn.bugzilla.ui/plugin.properties b/org.eclipse.mylyn.bugzilla.ui/plugin.properties
index b85d0c50d..7a591a01c 100644
--- a/org.eclipse.mylyn.bugzilla.ui/plugin.properties
+++ b/org.eclipse.mylyn.bugzilla.ui/plugin.properties
@@ -14,12 +14,4 @@ Bundle-Name = Mylyn Bugzilla Connector UI
bugzilla.repository.name=Bugzilla Repository
BugzillaRepositoryConnector.name=Bugzilla Repository Connector
-tasklist.BugzillaConnectorUi.name=Bugzilla Repository UI
-
-Mark_not_obsolete_Action_Label = Mark not obsolete
-Mark_not_obsolete_Action_Tooltip = Mark attachment as not obsolete
-Mark_obsolete_Action_Label = Mark obsolete
-Mark_obsolete_Action_Tooltip = Mark attachment as obsolete
-Details_Action_Label = Details...
-Details_Action_Tooltip = Attachment Details
-Mark_as_Menu_Label = Mark as \ No newline at end of file
+tasklist.BugzillaConnectorUi.name=Bugzilla Repository UI \ No newline at end of file
diff --git a/org.eclipse.mylyn.bugzilla.ui/plugin.xml b/org.eclipse.mylyn.bugzilla.ui/plugin.xml
index 29d438f41..1c04bd415 100644
--- a/org.eclipse.mylyn.bugzilla.ui/plugin.xml
+++ b/org.eclipse.mylyn.bugzilla.ui/plugin.xml
@@ -85,43 +85,4 @@
id="org.eclipse.mylyn.bugzilla.ui.pageFactory">
</pageFactory>
</extension>
-
- <extension point = "org.eclipse.ui.popupMenus">
- <objectContribution
- adaptable="false"
- id="org.eclipse.mylyn.bugzilla.ui.contribution.attachment"
- objectClass="org.eclipse.mylyn.tasks.core.ITaskAttachment">
- <action
- class="org.eclipse.mylyn.internal.bugzilla.ui.action.BugzillaNotObsoleteAttachmentAction"
- enablesFor="*"
- id="org.eclipse.mylyn.bugzilla.ui.contribution.attachment.notobsolete"
- label="%Mark_not_obsolete_Action_Label"
- menubarPath="org.eclipse.mylyn.bugzilla.ui.attachments.mark/markadditions"
- tooltip="%Mark_not_obsolete_Action_Tooltip">
- </action>
- <action
- class="org.eclipse.mylyn.internal.bugzilla.ui.action.BugzillaObsoleteAttachmentAction"
- enablesFor="*"
- id="org.eclipse.mylyn.bugzilla.ui.contribution.attachment.obsolete"
- label="%Mark_obsolete_Action_Label"
- menubarPath="org.eclipse.mylyn.bugzilla.ui.attachments.mark/markadditions"
- tooltip="%Mark_obsolete_Action_Tooltip">
- </action>
- <action
- class="org.eclipse.mylyn.internal.bugzilla.ui.action.BugzillaAttachmentUpdateAction"
- enablesFor="*"
- id="org.eclipse.mylyn.bugzilla.ui.contribution.attachment.update"
- label="%Details_Action_Label"
- menubarPath="org.eclipse.mylyn.bugzilla.ui.attachments.mark"
- tooltip="%Details_Action_Tooltip">
- </action>
- <menu
- id="org.eclipse.mylyn.bugzilla.ui.attachments.mark"
- label="%Mark_as_Menu_Label"
- path="markadditions">
- </menu>
- </objectContribution>
- </extension>
-
-
</plugin>
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/action/BugzillaAttachmentUpdateAction.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/action/BugzillaAttachmentUpdateAction.java
deleted file mode 100644
index a9fdbb26c..000000000
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/action/BugzillaAttachmentUpdateAction.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 Frank Becker 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:
- * Frank Becker - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.mylyn.internal.bugzilla.ui.action;
-
-import java.util.List;
-
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants;
-import org.eclipse.mylyn.internal.bugzilla.ui.editor.BugzillaTaskEditorPage;
-import org.eclipse.mylyn.internal.bugzilla.ui.editor.FlagAttributeEditor;
-import org.eclipse.mylyn.internal.bugzilla.ui.wizard.BugzillaAttachmentWizard;
-import org.eclipse.mylyn.internal.tasks.core.TaskTask;
-import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
-import org.eclipse.mylyn.internal.tasks.ui.wizards.NewAttachmentWizardDialog;
-import org.eclipse.mylyn.tasks.core.ITask;
-import org.eclipse.mylyn.tasks.core.ITaskAttachment;
-import org.eclipse.mylyn.tasks.core.TaskRepository;
-import org.eclipse.mylyn.tasks.core.data.ITaskDataWorkingCopy;
-import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
-import org.eclipse.mylyn.tasks.core.data.TaskAttributeMetaData;
-import org.eclipse.mylyn.tasks.core.data.TaskData;
-import org.eclipse.mylyn.tasks.core.data.TaskDataModel;
-import org.eclipse.mylyn.tasks.core.data.TaskDataModelEvent;
-import org.eclipse.mylyn.tasks.core.data.TaskDataModelListener;
-import org.eclipse.mylyn.tasks.ui.TasksUi;
-import org.eclipse.mylyn.tasks.ui.editors.AbstractAttributeEditor;
-import org.eclipse.mylyn.tasks.ui.editors.AttributeEditorFactory;
-import org.eclipse.mylyn.tasks.ui.editors.TaskEditor;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IViewActionDelegate;
-import org.eclipse.ui.IViewPart;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPartSite;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.actions.BaseSelectionListenerAction;
-import org.eclipse.ui.forms.editor.IFormPage;
-
-/**
- * @author Frank Becker
- */
-@SuppressWarnings("restriction")
-public class BugzillaAttachmentUpdateAction extends BaseSelectionListenerAction implements IViewActionDelegate {
-
- private ISelection currentSelection;
-
- public BugzillaAttachmentUpdateAction() {
- super("BugzillaAttachmentDetailAction"); //$NON-NLS-1$
- }
-
- public void init(IViewPart view) {
- // ignore
- }
-
- public void run(IAction action) {
- IStructuredSelection selection = null;
- if (currentSelection instanceof IStructuredSelection) {
- selection = (IStructuredSelection) currentSelection;
- }
- if (selection == null || selection.isEmpty() || selection.size() != 1) {
- return;
- }
- ITaskAttachment attachment = (ITaskAttachment) selection.getFirstElement();
- IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- IWorkbenchPage page = window.getActivePage();
- IEditorPart activeEditor = page.getActiveEditor();
- IWorkbenchPartSite site = activeEditor.getSite();
- Shell shell = site.getShell();
- if (activeEditor instanceof TaskEditor) {
- final TaskEditor taskEditor = (TaskEditor) activeEditor;
- IFormPage taskEditorPage = taskEditor.findPage("id"); //$NON-NLS-1$
- if (taskEditorPage instanceof BugzillaTaskEditorPage) {
- BugzillaTaskEditorPage bugzillaTaskEditorPage = (BugzillaTaskEditorPage) taskEditorPage;
-
- ITask attachmentTask = attachment.getTask();
- ITask nTask = new TaskTask(attachmentTask.getConnectorKind(), attachmentTask.getRepositoryUrl(),
- attachmentTask.getTaskId() + "attachment"); //$NON-NLS-1$
-
- TaskData editTaskData = new TaskData(attachment.getTaskAttribute().getTaskData().getAttributeMapper(),
- attachment.getTaskAttribute().getTaskData().getConnectorKind(), attachment.getTaskAttribute()
- .getTaskData()
- .getRepositoryUrl(), attachment.getTaskAttribute().getTaskData().getTaskId());
- editTaskData.setVersion(attachment.getTaskAttribute().getTaskData().getVersion());
- TaskAttribute target0 = editTaskData.getRoot();
- TaskAttribute temp = attachment.getTaskAttribute();
- target0.setValues(temp.getValues());
- for (TaskAttribute child : temp.getAttributes().values()) {
- target0.deepAddCopy(child);
- }
-
- TaskAttribute comment = target0.createAttribute("comment"); //$NON-NLS-1$
- TaskAttributeMetaData commentMeta = comment.getMetaData();
- commentMeta.setType(TaskAttribute.TYPE_LONG_RICH_TEXT);
- commentMeta.setLabel(Messages.BugzillaAttachmentUpdateAction_Comment);
-
- ITaskDataWorkingCopy workingCopy = TasksUi.getTaskDataManager().createWorkingCopy(nTask, editTaskData);
- TaskRepository repository = TasksUiPlugin.getRepositoryManager().getRepository(
- attachment.getTaskAttribute().getTaskData().getRepositoryUrl());
- final TaskDataModel model = new TaskDataModel(repository, nTask, workingCopy);
- AttributeEditorFactory factory = new AttributeEditorFactory(model, repository,
- bugzillaTaskEditorPage.getEditorSite()) {
- @Override
- public AbstractAttributeEditor createEditor(String type, final TaskAttribute taskAttribute) {
- AbstractAttributeEditor editor;
- if (IBugzillaConstants.EDITOR_TYPE_FLAG.equals(type)) {
- editor = new FlagAttributeEditor(model, taskAttribute, 350);
- } else {
- editor = super.createEditor(type, taskAttribute);
- if (TaskAttribute.TYPE_BOOLEAN.equals(type)) {
- editor.setDecorationEnabled(false);
- }
- }
- return editor;
- }
- };
-
- TaskAttribute target = workingCopy.getLocalData().getRoot();
- target.setValue(target0.getValue());
-
- final BugzillaAttachmentWizard attachmentWizard = new BugzillaAttachmentWizard(shell, factory, target,
- taskEditor, attachment);
- final NewAttachmentWizardDialog dialog = new NewAttachmentWizardDialog(shell, attachmentWizard, false);
- model.addModelListener(new TaskDataModelListener() {
-
- @Override
- public void attributeChanged(TaskDataModelEvent event) {
- attachmentWizard.setChanged(true);
- dialog.updateButtons();
- }
- });
-
- dialog.setBlockOnOpen(false);
- dialog.create();
- dialog.open();
- }
- }
- }
-
- @SuppressWarnings("unchecked")
- public void selectionChanged(IAction action, ISelection selection) {
- this.currentSelection = selection;
- IStructuredSelection sructuredSelection = null;
- if (selection instanceof IStructuredSelection) {
- sructuredSelection = (IStructuredSelection) currentSelection;
- }
- if (sructuredSelection == null || sructuredSelection.isEmpty()) {
- return;
- }
- List<ITaskAttachment> attachmentList = sructuredSelection.toList();
- if (attachmentList != null && attachmentList.size() == 1) {
- action.setEnabled(true);
- } else {
- action.setEnabled(false);
- }
- }
-}
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/action/BugzillaNotObsoleteAttachmentAction.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/action/BugzillaNotObsoleteAttachmentAction.java
deleted file mode 100644
index 9f7652d4e..000000000
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/action/BugzillaNotObsoleteAttachmentAction.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2009 Tasktop Technologies 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:
- * Tasktop Technologies - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.mylyn.internal.bugzilla.ui.action;
-
-/**
- * @author Frank Becker
- */
-public class BugzillaNotObsoleteAttachmentAction extends BugzillaUpdateAttachmentAction {
-
- public BugzillaNotObsoleteAttachmentAction() {
- super(false);
- // ignore
- }
-
-}
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/action/BugzillaObsoleteAttachmentAction.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/action/BugzillaObsoleteAttachmentAction.java
deleted file mode 100644
index 2e6eab3e2..000000000
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/action/BugzillaObsoleteAttachmentAction.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2009 Tasktop Technologies 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:
- * Tasktop Technologies - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.mylyn.internal.bugzilla.ui.action;
-
-/**
- * @author Frank Becker
- */
-public class BugzillaObsoleteAttachmentAction extends BugzillaUpdateAttachmentAction {
-
- public BugzillaObsoleteAttachmentAction() {
- super(true);
- }
-
-}
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/action/BugzillaUpdateAttachmentAction.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/action/BugzillaUpdateAttachmentAction.java
deleted file mode 100644
index 6f3445ebc..000000000
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/action/BugzillaUpdateAttachmentAction.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2009 Tasktop Technologies 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:
- * Tasktop Technologies - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.mylyn.internal.bugzilla.ui.action;
-
-import java.util.List;
-
-import org.eclipse.core.runtime.jobs.IJobChangeEvent;
-import org.eclipse.core.runtime.jobs.JobChangeAdapter;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.dialogs.IMessageProvider;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.mylyn.internal.bugzilla.ui.editor.BugzillaTaskEditorPage;
-import org.eclipse.mylyn.tasks.core.ITaskAttachment;
-import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
-import org.eclipse.mylyn.tasks.ui.editors.TaskEditor;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IViewActionDelegate;
-import org.eclipse.ui.IViewPart;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.actions.BaseSelectionListenerAction;
-import org.eclipse.ui.forms.editor.IFormPage;
-
-/**
- * @author Frank Becker
- */
-public class BugzillaUpdateAttachmentAction extends BaseSelectionListenerAction implements IViewActionDelegate {
-
- private ISelection currentSelection;
-
- private final boolean obsolete;
-
- public BugzillaUpdateAttachmentAction(boolean obsolete) {
- super("UpdateAttachmentAction"); //$NON-NLS-1$
- this.obsolete = obsolete;
- }
-
- public void init(IViewPart view) {
- // ignore
- }
-
- @SuppressWarnings("unchecked")
- public void run(IAction action) {
- IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- IWorkbenchPage page = window.getActivePage();
- IEditorPart activeEditor = page.getActiveEditor();
- if (activeEditor instanceof TaskEditor) {
- final TaskEditor taskEditor = (TaskEditor) activeEditor;
- IStructuredSelection selection = null;
- if (currentSelection instanceof IStructuredSelection) {
- selection = (IStructuredSelection) currentSelection;
- }
- if (selection == null || selection.isEmpty()) {
- return;
- }
- List<ITaskAttachment> attachment = selection.toList();
- if (attachment != null) {
- final UpdateAttachmentJob job = new UpdateAttachmentJob(attachment, taskEditor, obsolete);
- job.setUser(true);
- job.addJobChangeListener(new JobChangeAdapter() {
-
- @Override
- public void done(IJobChangeEvent event) {
- if (job.getError() != null) {
- IFormPage formPage = taskEditor.getActivePageInstance();
- if (formPage instanceof BugzillaTaskEditorPage) {
- final BugzillaTaskEditorPage bugzillaPage = (BugzillaTaskEditorPage) formPage;
- PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
- public void run() {
- bugzillaPage.getTaskEditor().setMessage(job.getError().getMessage(),
- IMessageProvider.ERROR);
- }
- });
- }
- }
- }
- });
- job.schedule();
- }
- }
- }
-
- @SuppressWarnings("unchecked")
- public void selectionChanged(IAction action, ISelection selection) {
- this.currentSelection = selection;
- IStructuredSelection sructuredSelection = null;
- if (selection instanceof IStructuredSelection) {
- sructuredSelection = (IStructuredSelection) currentSelection;
- }
- if (sructuredSelection == null || sructuredSelection.isEmpty()) {
- return;
- }
- List<ITaskAttachment> attachmentList = sructuredSelection.toList();
- action.setEnabled(false);
- for (ITaskAttachment taskAttachment : attachmentList) {
- TaskAttribute taskAttribute = taskAttachment.getTaskAttribute();
- TaskAttribute deprecated = taskAttribute.getMappedAttribute(TaskAttribute.ATTACHMENT_IS_DEPRECATED);
- if (deprecated != null && deprecated.getValue().equals("1") != obsolete) { //$NON-NLS-1$
- action.setEnabled(true);
- break;
- }
- }
- }
-}
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaAttachmentPart.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaAttachmentPart.java
new file mode 100644
index 000000000..f6dc82e0f
--- /dev/null
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaAttachmentPart.java
@@ -0,0 +1,246 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Frank Becker 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:
+ * Frank Becker - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.internal.bugzilla.ui.editor;
+
+import java.util.List;
+
+import org.eclipse.core.runtime.jobs.IJobChangeEvent;
+import org.eclipse.core.runtime.jobs.JobChangeAdapter;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants;
+import org.eclipse.mylyn.internal.bugzilla.ui.action.UpdateAttachmentJob;
+import org.eclipse.mylyn.internal.bugzilla.ui.wizard.BugzillaAttachmentWizard;
+import org.eclipse.mylyn.internal.tasks.core.TaskTask;
+import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
+import org.eclipse.mylyn.internal.tasks.ui.editors.TaskEditorAttachmentPart;
+import org.eclipse.mylyn.internal.tasks.ui.util.AttachmentUtil;
+import org.eclipse.mylyn.internal.tasks.ui.wizards.NewAttachmentWizardDialog;
+import org.eclipse.mylyn.tasks.core.ITask;
+import org.eclipse.mylyn.tasks.core.ITaskAttachment;
+import org.eclipse.mylyn.tasks.core.TaskRepository;
+import org.eclipse.mylyn.tasks.core.data.ITaskDataWorkingCopy;
+import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
+import org.eclipse.mylyn.tasks.core.data.TaskAttributeMetaData;
+import org.eclipse.mylyn.tasks.core.data.TaskData;
+import org.eclipse.mylyn.tasks.core.data.TaskDataModel;
+import org.eclipse.mylyn.tasks.core.data.TaskDataModelEvent;
+import org.eclipse.mylyn.tasks.core.data.TaskDataModelListener;
+import org.eclipse.mylyn.tasks.ui.TasksUi;
+import org.eclipse.mylyn.tasks.ui.editors.AbstractAttributeEditor;
+import org.eclipse.mylyn.tasks.ui.editors.AttributeEditorFactory;
+import org.eclipse.mylyn.tasks.ui.editors.TaskEditor;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPartSite;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.forms.editor.IFormPage;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+
+@SuppressWarnings("restriction")
+public class BugzillaAttachmentPart extends TaskEditorAttachmentPart {
+
+ @Override
+ protected void createAttachmentTable(FormToolkit toolkit, Composite attachmentsComposite) {
+ // ignore
+ super.createAttachmentTable(toolkit, attachmentsComposite);
+ final TaskEditor taskEditor = this.getTaskEditorPage().getTaskEditor();
+ menuManager.addMenuListener(new IMenuListener() {
+ public void menuAboutToShow(IMenuManager manager) {
+
+ final Action detailAction = new Action("Details...") {
+ @Override
+ public void run() {
+ ITaskAttachment attachment = AttachmentUtil.getSelectedAttachment();
+ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ IWorkbenchPage page = window.getActivePage();
+ IEditorPart activeEditor = page.getActiveEditor();
+ IWorkbenchPartSite site = activeEditor.getSite();
+ Shell shell = site.getShell();
+ if (activeEditor instanceof TaskEditor) {
+ final TaskEditor taskEditor = (TaskEditor) activeEditor;
+ IFormPage taskEditorPage = taskEditor.findPage("id"); //$NON-NLS-1$
+ if (taskEditorPage instanceof BugzillaTaskEditorPage) {
+ BugzillaTaskEditorPage bugzillaTaskEditorPage = (BugzillaTaskEditorPage) taskEditorPage;
+
+ ITask attachmentTask = attachment.getTask();
+ ITask nTask = new TaskTask(attachmentTask.getConnectorKind(),
+ attachmentTask.getRepositoryUrl(), attachmentTask.getTaskId() + "attachment"); //$NON-NLS-1$
+
+ TaskData editTaskData = new TaskData(attachment.getTaskAttribute()
+ .getTaskData()
+ .getAttributeMapper(), attachment.getTaskAttribute()
+ .getTaskData()
+ .getConnectorKind(), attachment.getTaskAttribute()
+ .getTaskData()
+ .getRepositoryUrl(), attachment.getTaskAttribute().getTaskData().getTaskId());
+ editTaskData.setVersion(attachment.getTaskAttribute().getTaskData().getVersion());
+ TaskAttribute target0 = editTaskData.getRoot();
+ TaskAttribute temp = attachment.getTaskAttribute();
+ target0.setValues(temp.getValues());
+ for (TaskAttribute child : temp.getAttributes().values()) {
+ target0.deepAddCopy(child);
+ }
+
+ TaskAttribute comment = target0.createAttribute("comment"); //$NON-NLS-1$
+ TaskAttributeMetaData commentMeta = comment.getMetaData();
+ commentMeta.setType(TaskAttribute.TYPE_LONG_RICH_TEXT);
+ commentMeta.setLabel("Messages.BugzillaAttachmentUpdateAction_Comment");
+
+ ITaskDataWorkingCopy workingCopy = TasksUi.getTaskDataManager().createWorkingCopy(
+ nTask, editTaskData);
+ TaskRepository repository = TasksUiPlugin.getRepositoryManager().getRepository(
+ attachment.getTaskAttribute().getTaskData().getRepositoryUrl());
+ final TaskDataModel model = new TaskDataModel(repository, nTask, workingCopy);
+ AttributeEditorFactory factory = new AttributeEditorFactory(model, repository,
+ bugzillaTaskEditorPage.getEditorSite()) {
+ @Override
+ public AbstractAttributeEditor createEditor(String type,
+ final TaskAttribute taskAttribute) {
+ AbstractAttributeEditor editor;
+ if (IBugzillaConstants.EDITOR_TYPE_FLAG.equals(type)) {
+ editor = new FlagAttributeEditor(model, taskAttribute, 350);
+ } else {
+ editor = super.createEditor(type, taskAttribute);
+ if (TaskAttribute.TYPE_BOOLEAN.equals(type)) {
+ editor.setDecorationEnabled(false);
+ }
+ }
+ return editor;
+ }
+ };
+
+ TaskAttribute target = workingCopy.getLocalData().getRoot();
+ target.setValue(target0.getValue());
+
+ final BugzillaAttachmentWizard attachmentWizard = new BugzillaAttachmentWizard(shell,
+ factory, target, taskEditor, attachment);
+ final NewAttachmentWizardDialog dialog = new NewAttachmentWizardDialog(shell,
+ attachmentWizard, false);
+ model.addModelListener(new TaskDataModelListener() {
+
+ @Override
+ public void attributeChanged(TaskDataModelEvent event) {
+ attachmentWizard.setChanged(true);
+ dialog.updateButtons();
+ }
+ });
+
+ dialog.setBlockOnOpen(false);
+ dialog.create();
+ dialog.open();
+ }
+ }
+ }
+ };
+
+ final Action obsoleteAction = new Action("obsolete") {
+ @Override
+ public void run() {
+ List<ITaskAttachment> attachment = AttachmentUtil.getSelectedAttachments(null);
+ if (attachment != null) {
+ final UpdateAttachmentJob job = new UpdateAttachmentJob(attachment, taskEditor, true);
+ job.setUser(true);
+ job.addJobChangeListener(new JobChangeAdapter() {
+
+ @Override
+ public void done(IJobChangeEvent event) {
+ if (job.getError() != null) {
+ IFormPage formPage = taskEditor.getActivePageInstance();
+ if (formPage instanceof BugzillaTaskEditorPage) {
+ final BugzillaTaskEditorPage bugzillaPage = (BugzillaTaskEditorPage) formPage;
+ PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ bugzillaPage.getTaskEditor().setMessage(
+ job.getError().getMessage(), IMessageProvider.ERROR);
+ }
+ });
+ }
+ }
+ }
+ });
+ job.schedule();
+ }
+ }
+ };
+ final Action notObsoleteAction = new Action("not obsolete") {
+ @Override
+ public void run() {
+ List<ITaskAttachment> attachment = AttachmentUtil.getSelectedAttachments(null);
+ if (attachment != null) {
+ final UpdateAttachmentJob job = new UpdateAttachmentJob(attachment, taskEditor, false);
+ job.setUser(true);
+ job.addJobChangeListener(new JobChangeAdapter() {
+
+ @Override
+ public void done(IJobChangeEvent event) {
+ if (job.getError() != null) {
+ IFormPage formPage = taskEditor.getActivePageInstance();
+ if (formPage instanceof BugzillaTaskEditorPage) {
+ final BugzillaTaskEditorPage bugzillaPage = (BugzillaTaskEditorPage) formPage;
+ PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ bugzillaPage.getTaskEditor().setMessage(
+ job.getError().getMessage(), IMessageProvider.ERROR);
+ }
+ });
+ }
+ }
+ }
+ });
+ job.schedule();
+ }
+ }
+ };
+ MenuManager subMenu = new MenuManager("Mark as");
+ subMenu.add(obsoleteAction);
+ subMenu.add(notObsoleteAction);
+
+ manager.add(subMenu);
+ manager.add(detailAction);
+
+ List<ITaskAttachment> attachments = AttachmentUtil.getSelectedAttachments(null);
+ if (attachments != null) {
+ detailAction.setEnabled(attachments.size() == 1);
+ } else {
+ detailAction.setEnabled(false);
+ }
+ notObsoleteAction.setEnabled(false);
+ obsoleteAction.setEnabled(false);
+ for (ITaskAttachment taskAttachment : attachments) {
+ TaskAttribute taskAttribute = taskAttachment.getTaskAttribute();
+ TaskAttribute deprecated = taskAttribute.getMappedAttribute(TaskAttribute.ATTACHMENT_IS_DEPRECATED);
+ if (deprecated != null && deprecated.getValue().equals("1")) { //$NON-NLS-1$
+ notObsoleteAction.setEnabled(true);
+ break;
+ }
+ }
+ for (ITaskAttachment taskAttachment : attachments) {
+ TaskAttribute taskAttribute = taskAttachment.getTaskAttribute();
+ TaskAttribute deprecated = taskAttribute.getMappedAttribute(TaskAttribute.ATTACHMENT_IS_DEPRECATED);
+ if (deprecated != null && !deprecated.getValue().equals("1")) { //$NON-NLS-1$
+ obsoleteAction.setEnabled(true);
+ break;
+ }
+ }
+
+ }
+ });
+ }
+
+}
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditorPage.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditorPage.java
index 7d9cd444d..47db5c67f 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditorPage.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditorPage.java
@@ -95,6 +95,12 @@ public class BugzillaTaskEditorPage extends AbstractTaskEditorPage {
break;
}
}
+ for (TaskEditorPartDescriptor taskEditorPartDescriptor : descriptors) {
+ if (taskEditorPartDescriptor.getId().equals(ID_PART_ATTACHMENTS)) {
+ descriptors.remove(taskEditorPartDescriptor);
+ break;
+ }
+ }
// Add Bugzilla Planning part
try {
@@ -123,6 +129,14 @@ public class BugzillaTaskEditorPage extends AbstractTaskEditorPage {
}
}.setPath(PATH_PEOPLE));
+ // Add the updated Bugzilla attachment part
+ descriptors.add(new TaskEditorPartDescriptor(ID_PART_ATTACHMENTS) {
+ @Override
+ public AbstractTaskEditorPart createPart() {
+ return new BugzillaAttachmentPart();
+ }
+ }.setPath(PATH_ATTACHMENTS));
+
return descriptors;
}

Back to the top