diff options
author | relves | 2008-12-12 23:58:29 +0000 |
---|---|---|
committer | relves | 2008-12-12 23:58:29 +0000 |
commit | 8e9590aedd576994989f6e1753ebe8c1ded6307d (patch) | |
tree | cf9ca8b729fb029ba431916bb790f5dba393cdac /org.eclipse.mylyn.bugzilla.ui | |
parent | 117c3fe32442b5e354fde49317906900ff548b65 (diff) | |
download | org.eclipse.mylyn.tasks-8e9590aedd576994989f6e1753ebe8c1ded6307d.tar.gz org.eclipse.mylyn.tasks-8e9590aedd576994989f6e1753ebe8c1ded6307d.tar.xz org.eclipse.mylyn.tasks-8e9590aedd576994989f6e1753ebe8c1ded6307d.zip |
ASSIGNED - bug 152065: [patch] add support for deprecating patches
https://bugs.eclipse.org/bugs/show_bug.cgi?id=152065
Diffstat (limited to 'org.eclipse.mylyn.bugzilla.ui')
3 files changed, 230 insertions, 0 deletions
diff --git a/org.eclipse.mylyn.bugzilla.ui/plugin.xml b/org.eclipse.mylyn.bugzilla.ui/plugin.xml index aaff35ece..e7762c9f8 100644 --- a/org.eclipse.mylyn.bugzilla.ui/plugin.xml +++ b/org.eclipse.mylyn.bugzilla.ui/plugin.xml @@ -67,5 +67,21 @@ 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.BugzillaUpdateAttachmentAction" + enablesFor="*" + id="org.eclipse.mylyn.bugzilla.ui.contribution.attachment.obsolete" + label="Mark obsolete" + menubarPath="actions" + tooltip="Toggle the attachment as obsolete or not"> + </action> + </objectContribution> + </extension> </plugin> 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..be7c1131e --- /dev/null +++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/action/BugzillaUpdateAttachmentAction.java @@ -0,0 +1,74 @@ +/******************************************************************************* + * Copyright (c) 2004, 2008 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.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.mylyn.tasks.core.ITaskAttachment; +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; + +/** + * @author Frank Becker + */ +public class BugzillaUpdateAttachmentAction extends BaseSelectionListenerAction implements IViewActionDelegate { + + private ISelection currentSelection; + + public BugzillaUpdateAttachmentAction() { + super("UPdateAttachmentAction"); + } + + protected BugzillaUpdateAttachmentAction(String text) { + super(text); + } + + 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) { + 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) { + UpdateAttachmentJob job = new UpdateAttachmentJob(attachment, taskEditor); + job.setUser(true); + job.schedule(); + } + } + } + + public void selectionChanged(IAction action, ISelection selection) { + this.currentSelection = selection; + } +} diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/action/UpdateAttachmentJob.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/action/UpdateAttachmentJob.java new file mode 100644 index 000000000..fa88fa894 --- /dev/null +++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/action/UpdateAttachmentJob.java @@ -0,0 +1,140 @@ +/******************************************************************************* + * Copyright (c) 2004, 2008 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.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.IJobChangeEvent; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.core.runtime.jobs.JobChangeAdapter; +import org.eclipse.jface.dialogs.IMessageProvider; +import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin; +import org.eclipse.mylyn.internal.bugzilla.core.BugzillaTaskDataHandler; +import org.eclipse.mylyn.internal.bugzilla.ui.editor.BugzillaTaskEditorPage; +import org.eclipse.mylyn.internal.tasks.ui.editors.EditorUtil; +import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal; +import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector; +import org.eclipse.mylyn.tasks.core.ITask; +import org.eclipse.mylyn.tasks.core.ITaskAttachment; +import org.eclipse.mylyn.tasks.core.data.TaskAttribute; +import org.eclipse.mylyn.tasks.ui.TasksUi; +import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPage; +import org.eclipse.mylyn.tasks.ui.editors.TaskEditor; +import org.eclipse.swt.widgets.Control; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.forms.editor.IFormPage; +import org.eclipse.ui.forms.widgets.Section; + +/** + * @author Frank Becker + */ +public class UpdateAttachmentJob extends Job { + + private final List<ITaskAttachment> attachment; + + private final TaskEditor editor; + + public UpdateAttachmentJob(List<ITaskAttachment> attachment, TaskEditor editor) { + super("Update attachment"); + this.attachment = attachment; + this.editor = editor; + } + + @SuppressWarnings("restriction") + @Override + protected IStatus run(IProgressMonitor monitor) { + final ITask task; + task = editor.getTaskEditorInput().getTask(); + + if (!task.getConnectorKind().equals(BugzillaCorePlugin.CONNECTOR_KIND)) { + return Status.OK_STATUS; + } + AbstractRepositoryConnector connector = TasksUi.getRepositoryManager().getRepositoryConnector( + task.getConnectorKind()); + monitor.beginTask("Update attachments", attachment.size() * 10 + 10); + try { + for (ITaskAttachment taskAttachment : attachment) { + TaskAttribute taskAttribute = taskAttachment.getTaskAttribute(); + TaskAttribute deprecated = taskAttribute.getMappedAttribute(TaskAttribute.ATTACHMENT_IS_DEPRECATED); + if (deprecated.getValue().equals("1")) { + deprecated.setValue("0"); + } else { + deprecated.setValue("1"); + } + monitor.worked(10); + ((BugzillaTaskDataHandler) connector.getTaskDataHandler()).postUpdateAttachment( + taskAttachment.getTaskRepository(), taskAttribute, "update", monitor); + } + if (task != null) { + if (connector != null) { + TasksUiInternal.synchronizeTask(connector, task, true, new JobChangeAdapter() { + @Override + public void done(IJobChangeEvent event) { + PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { + public void run() { + try { + if (editor != null) { + editor.refreshPages(); + editor.getEditorSite().getPage().activate(editor); + IFormPage formPage = editor.getActivePageInstance(); + if (formPage instanceof BugzillaTaskEditorPage) { + BugzillaTaskEditorPage bugzillaPage = (BugzillaTaskEditorPage) formPage; + Control control = bugzillaPage.getPart( + AbstractTaskEditorPage.ID_PART_ATTACHMENTS).getControl(); + if (control instanceof Section) { + Section section = (Section) control; + EditorUtil.toggleExpandableComposite(true, section); + } + bugzillaPage.getTaskEditor().setMessage("Obsolete toggeled successful", + IMessageProvider.INFORMATION); + } + + } + } finally { + if (editor != null) { + editor.showBusy(false); + } + } + } + }); + } + }); + } + monitor.worked(10); + PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { + public void run() { + if (editor != null) { + editor.showBusy(true); + } + } + }); + } + } catch (Exception e) { + IFormPage formPage = editor.getActivePageInstance(); + if (formPage instanceof BugzillaTaskEditorPage) { + final BugzillaTaskEditorPage bugzillaPage = (BugzillaTaskEditorPage) formPage; + PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { + public void run() { + bugzillaPage.getTaskEditor().setMessage("Obsolete toggeled was not successful", + IMessageProvider.ERROR); + } + }); + } + } finally { + monitor.done(); + } + return Status.OK_STATUS; + } +} |