Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfbecker2010-07-11 14:33:25 +0000
committerfbecker2010-07-11 14:33:25 +0000
commit4d5bf6fc55b38b21ebdaa1c09664fc6f37530e21 (patch)
treeaa33cfccaa5875fe594d7dcb0a43596549b25e7d /org.eclipse.mylyn.bugzilla.ui
parent0f4320cb705a930e33f87a07d76e245fd545d52a (diff)
downloadorg.eclipse.mylyn.tasks-4d5bf6fc55b38b21ebdaa1c09664fc6f37530e21.tar.gz
org.eclipse.mylyn.tasks-4d5bf6fc55b38b21ebdaa1c09664fc6f37530e21.tar.xz
org.eclipse.mylyn.tasks-4d5bf6fc55b38b21ebdaa1c09664fc6f37530e21.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.xml52
-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, 391 insertions, 261 deletions
diff --git a/org.eclipse.mylyn.bugzilla.ui/plugin.properties b/org.eclipse.mylyn.bugzilla.ui/plugin.properties
index 7a591a01c..b85d0c50d 100644
--- a/org.eclipse.mylyn.bugzilla.ui/plugin.properties
+++ b/org.eclipse.mylyn.bugzilla.ui/plugin.properties
@@ -14,4 +14,12 @@ Bundle-Name = Mylyn Bugzilla Connector UI
bugzilla.repository.name=Bugzilla Repository
BugzillaRepositoryConnector.name=Bugzilla Repository Connector
-tasklist.BugzillaConnectorUi.name=Bugzilla Repository UI \ No newline at end of file
+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
diff --git a/org.eclipse.mylyn.bugzilla.ui/plugin.xml b/org.eclipse.mylyn.bugzilla.ui/plugin.xml
index 1c04bd415..1515650f1 100644
--- a/org.eclipse.mylyn.bugzilla.ui/plugin.xml
+++ b/org.eclipse.mylyn.bugzilla.ui/plugin.xml
@@ -85,4 +85,56 @@
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">
+ <enablement>
+ <and>
+ <objectClass name="org.eclipse.mylyn.tasks.core.ITaskAttachment"/>
+ <objectState name="ConnectorKind" value="bugzilla"/>
+ </and>
+ </enablement>
+ </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">
+ <enablement>
+ <and>
+ <objectClass name="org.eclipse.mylyn.tasks.core.ITaskAttachment"/>
+ <objectState name="ConnectorKind" value="bugzilla"/>
+ </and>
+ </enablement>
+ </action>
+ <action
+ class="org.eclipse.mylyn.internal.bugzilla.ui.action.BugzillaAttachmentUpdateAction"
+ enablesFor="1"
+ 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>
+ <visibility>
+ <objectState name="ConnectorKind" value="bugzilla"></objectState>
+ </visibility>
+ <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
new file mode 100644
index 000000000..a9fdbb26c
--- /dev/null
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/action/BugzillaAttachmentUpdateAction.java
@@ -0,0 +1,168 @@
+/*******************************************************************************
+ * 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
new file mode 100644
index 000000000..9f7652d4e
--- /dev/null
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/action/BugzillaNotObsoleteAttachmentAction.java
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * 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
new file mode 100644
index 000000000..2e6eab3e2
--- /dev/null
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/action/BugzillaObsoleteAttachmentAction.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * 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
new file mode 100644
index 000000000..6f3445ebc
--- /dev/null
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/action/BugzillaUpdateAttachmentAction.java
@@ -0,0 +1,115 @@
+/*******************************************************************************
+ * 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
deleted file mode 100644
index f6dc82e0f..000000000
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaAttachmentPart.java
+++ /dev/null
@@ -1,246 +0,0 @@
-/*******************************************************************************
- * 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 47db5c67f..7d9cd444d 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,12 +95,6 @@ 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 {
@@ -129,14 +123,6 @@ 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