tmf: Update copyright headers in tmf.ui
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / views / uml2sd / SDWidgetSelectionProvider.java
CommitLineData
73005152 1/**********************************************************************
c8422608 2 * Copyright (c) 2005, 2012 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 */
eb63f5ff 40 protected List<ISelectionChangedListener> fListenerList = null;
73005152
BH
41 /**
42 * The current selection
43 */
eb63f5ff 44 protected ISelection fCurrentSelection = null;
73005152 45
df0b8ff4
BH
46 // ------------------------------------------------------------------------
47 // Constructor
48 // ------------------------------------------------------------------------
49 /**
50 * Standard constructor
51 */
73005152 52 protected SDWidgetSelectionProvider() {
eb63f5ff 53 fListenerList = new ArrayList<ISelectionChangedListener>();
73005152
BH
54 }
55
df0b8ff4
BH
56 // ------------------------------------------------------------------------
57 // Methods
58 // ------------------------------------------------------------------------
59
60 /*
61 * (non-Javadoc)
62 * @see org.eclipse.jface.viewers.ISelectionProvider#addSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener)
73005152
BH
63 */
64 @Override
65 public void addSelectionChangedListener(ISelectionChangedListener listener) {
013a5f1c 66 if (!fListenerList.contains(listener)) {
eb63f5ff 67 fListenerList.add(listener);
013a5f1c 68 }
73005152
BH
69 }
70
df0b8ff4
BH
71 /*
72 * (non-Javadoc)
73 * @see org.eclipse.jface.viewers.ISelectionProvider#removeSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener)
73005152
BH
74 */
75 @Override
76 public void removeSelectionChangedListener(ISelectionChangedListener listener) {
eb63f5ff 77 fListenerList.remove(listener);
73005152
BH
78 }
79
df0b8ff4
BH
80 /*
81 * (non-Javadoc)
82 * @see org.eclipse.jface.viewers.ISelectionProvider#setSelection(org.eclipse.jface.viewers.ISelection)
73005152
BH
83 */
84 @Override
85 public void setSelection(ISelection selection) {
eb63f5ff
BH
86 fCurrentSelection = selection;
87 for (int i = 0; i < fListenerList.size(); i++) {
abbdd66a 88 ISelectionChangedListener list = fListenerList.get(i);
eb63f5ff 89 list.selectionChanged(new SelectionChangedEvent(this, fCurrentSelection));
73005152
BH
90 }
91 }
92
df0b8ff4
BH
93 /*
94 * (non-Javadoc)
95 * @see org.eclipse.jface.viewers.ISelectionProvider#getSelection()
73005152
BH
96 */
97 @Override
98 public ISelection getSelection() {
eb63f5ff 99 return fCurrentSelection;
73005152
BH
100 }
101
102}
This page took 0.04501 seconds and 5 git commands to generate.