Java Doc and API clean up of TMF UML Sequence diagram framework
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / views / uml2sd / SDWidgetSelectionProvider.java
CommitLineData
73005152 1/**********************************************************************
df0b8ff4
BH
2 * Copyright (c) 2005, 2008 IBM Corporation and others.
3 * Copyright (c) 2011, 2012 Ericsson.
73005152
BH
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
73005152
BH
8 *
9 * Contributors:
10 * IBM - Initial API and implementation
11 * Bernd Hufmann - Updated for TMF
12 **********************************************************************/
13package org.eclipse.linuxtools.tmf.ui.views.uml2sd;
14
15import java.util.ArrayList;
16
17import org.eclipse.jface.viewers.ISelection;
18import org.eclipse.jface.viewers.ISelectionChangedListener;
19import org.eclipse.jface.viewers.ISelectionProvider;
20import org.eclipse.jface.viewers.SelectionChangedEvent;
21
22/**
df0b8ff4
BH
23 * <p>
24 * Informs all registered listeners of graph node selection change in the Frame.
25 * </p>
73005152 26 *
df0b8ff4 27 * @version 1.0
73005152
BH
28 * @author sveyrier
29 *
30 */
31public class SDWidgetSelectionProvider implements ISelectionProvider {
32
df0b8ff4
BH
33 // ------------------------------------------------------------------------
34 // Attributes
35 // ------------------------------------------------------------------------
36
73005152
BH
37 /**
38 * The listener list
39 */
40 protected ArrayList<ISelectionChangedListener> listenerList = null;
73005152
BH
41 /**
42 * The current selection
43 */
44 protected ISelection currentSelection = null;
45
df0b8ff4
BH
46 // ------------------------------------------------------------------------
47 // Constructor
48 // ------------------------------------------------------------------------
49 /**
50 * Standard constructor
51 */
73005152
BH
52 protected SDWidgetSelectionProvider() {
53 listenerList = new ArrayList<ISelectionChangedListener>();
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) {
66 if (!listenerList.contains(listener))
67 listenerList.add(listener);
68 }
69
df0b8ff4
BH
70 /*
71 * (non-Javadoc)
72 * @see org.eclipse.jface.viewers.ISelectionProvider#removeSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener)
73005152
BH
73 */
74 @Override
75 public void removeSelectionChangedListener(ISelectionChangedListener listener) {
76 listenerList.remove(listener);
77 }
78
df0b8ff4
BH
79 /*
80 * (non-Javadoc)
81 * @see org.eclipse.jface.viewers.ISelectionProvider#setSelection(org.eclipse.jface.viewers.ISelection)
73005152
BH
82 */
83 @Override
84 public void setSelection(ISelection selection) {
85 currentSelection = selection;
86 for (int i = 0; i < listenerList.size(); i++) {
87 ISelectionChangedListener list = (ISelectionChangedListener) listenerList.get(i);
88 list.selectionChanged(new SelectionChangedEvent(this, currentSelection));
89 }
90 }
91
df0b8ff4
BH
92 /*
93 * (non-Javadoc)
94 * @see org.eclipse.jface.viewers.ISelectionProvider#getSelection()
73005152
BH
95 */
96 @Override
97 public ISelection getSelection() {
98 return currentSelection;
99 }
100
101}
This page took 0.034285 seconds and 5 git commands to generate.