tmf: Switch tmf.ui to Java 7 + fix warnings
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / views / uml2sd / SDWidgetSelectionProvider.java
CommitLineData
73005152 1/**********************************************************************
11252342 2 * Copyright (c) 2005, 2013 IBM Corporation, Ericsson
73005152
BH
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
013a5f1c
AM
7 *
8 * Contributors:
c8422608
AM
9 * IBM - Initial API and implementation
10 * Bernd Hufmann - Updated for TMF
73005152 11 **********************************************************************/
c8422608 12
73005152
BH
13package org.eclipse.linuxtools.tmf.ui.views.uml2sd;
14
15import java.util.ArrayList;
eb63f5ff 16import java.util.List;
73005152
BH
17
18import org.eclipse.jface.viewers.ISelection;
19import org.eclipse.jface.viewers.ISelectionChangedListener;
20import org.eclipse.jface.viewers.ISelectionProvider;
21import org.eclipse.jface.viewers.SelectionChangedEvent;
22
23/**
df0b8ff4
BH
24 * <p>
25 * Informs all registered listeners of graph node selection change in the Frame.
26 * </p>
013a5f1c
AM
27 *
28 * @version 1.0
73005152 29 * @author sveyrier
73005152
BH
30 */
31public class SDWidgetSelectionProvider implements ISelectionProvider {
32
df0b8ff4
BH
33 // ------------------------------------------------------------------------
34 // Attributes
35 // ------------------------------------------------------------------------
36
73005152
BH
37 /**
38 * The listener list
39 */
cab6c8ff 40 private List<ISelectionChangedListener> fListenerList = null;
11252342 41
73005152
BH
42 /**
43 * The current selection
44 */
cab6c8ff 45 private ISelection fCurrentSelection = null;
73005152 46
df0b8ff4
BH
47 // ------------------------------------------------------------------------
48 // Constructor
49 // ------------------------------------------------------------------------
11252342 50
df0b8ff4
BH
51 /**
52 * Standard constructor
53 */
73005152 54 protected SDWidgetSelectionProvider() {
507b1336 55 fListenerList = new ArrayList<>();
73005152
BH
56 }
57
df0b8ff4
BH
58 // ------------------------------------------------------------------------
59 // Methods
60 // ------------------------------------------------------------------------
61
73005152
BH
62 @Override
63 public void addSelectionChangedListener(ISelectionChangedListener listener) {
013a5f1c 64 if (!fListenerList.contains(listener)) {
eb63f5ff 65 fListenerList.add(listener);
013a5f1c 66 }
73005152
BH
67 }
68
73005152
BH
69 @Override
70 public void removeSelectionChangedListener(ISelectionChangedListener listener) {
eb63f5ff 71 fListenerList.remove(listener);
73005152
BH
72 }
73
73005152
BH
74 @Override
75 public void setSelection(ISelection selection) {
eb63f5ff
BH
76 fCurrentSelection = selection;
77 for (int i = 0; i < fListenerList.size(); i++) {
abbdd66a 78 ISelectionChangedListener list = fListenerList.get(i);
eb63f5ff 79 list.selectionChanged(new SelectionChangedEvent(this, fCurrentSelection));
73005152
BH
80 }
81 }
82
73005152
BH
83 @Override
84 public ISelection getSelection() {
eb63f5ff 85 return fCurrentSelection;
73005152
BH
86 }
87
88}
This page took 0.044561 seconds and 5 git commands to generate.