Skip to main content
summaryrefslogtreecommitdiffstats
blob: 09b61d02f8ca27f998866d84e3e4e6cc29a6db5b (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
/*******************************************************************************
 * Copyright (c) 2013 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.ote.ui.markers;

import java.util.ArrayList;
import java.util.Iterator;

import org.eclipse.core.resources.IResource;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.ui.IViewActionDelegate;
import org.eclipse.ui.IViewPart;

public class ClearOteMarkerActionView implements IViewActionDelegate {

	ArrayList<IResource> selections;
	
	public ClearOteMarkerActionView()  {
		selections = new ArrayList<>();
	}

	@Override
	public void run(IAction action) {
		for(IResource resource:selections){
			MarkerPlugin.findAndRemoveOteMarkers(resource);
		}
	}

	@Override
	public void selectionChanged(IAction action, ISelection selection) {
		selections.clear();
		if(selection instanceof StructuredSelection){
			Iterator<?> i = ((StructuredSelection)selection).iterator();
			while (i.hasNext()) {
				Object obj = i.next();
				if (obj instanceof IResource) {
					IResource resource = (IResource) obj;
					if (resource != null) {
						selections.add(resource);
					}
				} 
			}
		} 
	}

	@Override
	public void init(IViewPart view) {

	}
}

Back to the top