blob: fdf717a1f559d3442c57f59f7f2c0fe3222cf2a6 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
/*******************************************************************************
* Copyright (c) 2010 Boeing.
* 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:
* Boeing - initial API and implementation
*******************************************************************************/
package org.eclipse.osee.coverage.action;
import java.util.ArrayList;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.osee.coverage.editor.CoverageEditorWorkProductTab;
import org.eclipse.osee.coverage.model.WorkProductAction;
import org.eclipse.osee.framework.plugin.core.util.Jobs;
import org.eclipse.osee.framework.ui.plugin.util.AWorkbench;
import org.eclipse.osee.framework.ui.skynet.FrameworkImage;
import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.framework.ui.swt.ImageManager;
import org.eclipse.swt.widgets.Display;
/**
* @author Donald G. Dunne
*/
public class RemoveRelatedWorkProductAction extends Action {
private final CoverageEditorWorkProductTab coverageEditorWorkProductTab;
public RemoveRelatedWorkProductAction(CoverageEditorWorkProductTab coverageEditorWorkProductTab) {
super("Remove Related Work Product Action");
this.coverageEditorWorkProductTab = coverageEditorWorkProductTab;
}
@Override
public ImageDescriptor getImageDescriptor() {
return ImageManager.getImageDescriptor(FrameworkImage.DELETE);
}
@Override
public void run() {
final ArrayList<WorkProductAction> selActions = coverageEditorWorkProductTab.getSelectedActions();
if (selActions.isEmpty()) {
AWorkbench.popup("Please select work product to remove");
return;
}
if (MessageDialog.openConfirm(Display.getCurrent().getActiveShell(), getText(),
"Remove selected work product actions?")) {
Job job = new Job(getText()) {
@Override
protected IStatus run(IProgressMonitor monitor) {
coverageEditorWorkProductTab.getCoveragePackage().getWorkProductTaskProvider().removeWorkProductAction(
selActions.iterator().next());
Displays.ensureInDisplayThread(new Runnable() {
@Override
public void run() {
coverageEditorWorkProductTab.getCoveragePackage().getWorkProductTaskProvider().reload();
coverageEditorWorkProductTab.refresh();
}
});
return Status.OK_STATUS;
}
};
Jobs.startJob(job);
}
}
}
|