| 1 | package de.uka.ipd.sdq.reliability.solver.popup.actions; |
| 2 | |
| 3 | import org.eclipse.core.resources.IFile; |
| 4 | import org.eclipse.jface.action.IAction; |
| 5 | import org.eclipse.jface.viewers.ISelection; |
| 6 | import org.eclipse.jface.viewers.IStructuredSelection; |
| 7 | import org.eclipse.ui.IActionDelegate; |
| 8 | import org.eclipse.ui.IObjectActionDelegate; |
| 9 | import org.eclipse.ui.IWorkbenchPart; |
| 10 | |
| 11 | import de.uka.ipd.sdq.reliability.solver.compare.MarkovComparator; |
| 12 | import de.uka.ipd.sdq.reliability.solver.helper.LoggingHelper; |
| 13 | |
| 14 | public class CompareAction implements IObjectActionDelegate { |
| 15 | |
| 16 | /** |
| 17 | * Supports logging functionality. |
| 18 | */ |
| 19 | private LoggingHelper loggingHelper = LoggingHelper.getSingletonInstance(); |
| 20 | |
| 21 | /** |
| 22 | * The user's selection. |
| 23 | */ |
| 24 | private ISelection selection; |
| 25 | |
| 26 | /** |
| 27 | * Constructor for CompareAction. |
| 28 | */ |
| 29 | public CompareAction() { |
| 30 | super(); |
| 31 | } |
| 32 | |
| 33 | /** |
| 34 | * @see IActionDelegate#run(IAction) |
| 35 | */ |
| 36 | public void run(IAction action) { |
| 37 | |
| 38 | // Setup logging: |
| 39 | loggingHelper.initializeLogging(); |
| 40 | |
| 41 | // We assume exactly two *.markov files to be selected: |
| 42 | Object[] selectedObjects = ((IStructuredSelection) selection).toArray(); |
| 43 | new MarkovComparator().compare(((IFile) selectedObjects[0]) |
| 44 | .getLocation().toString(), // first file |
| 45 | ((IFile) selectedObjects[1]).getLocation().toString()); // second |
| 46 | // file |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * @see IActionDelegate#selectionChanged(IAction, ISelection) |
| 51 | */ |
| 52 | public void selectionChanged(IAction action, ISelection selection) { |
| 53 | this.selection = selection; |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart) |
| 58 | */ |
| 59 | public void setActivePart(IAction action, IWorkbenchPart targetPart) { |
| 60 | |
| 61 | } |
| 62 | } |