1 /**********************************************************************
2 * Copyright (c) 2005, 2008 IBM Corporation and others.
3 * Copyright (c) 2011, 2012 Ericsson.
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
10 * IBM - Initial API and implementation
11 * Bernd Hufmann - Updated for TMF
12 **********************************************************************/
13 package org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
;
15 import java
.util
.ArrayList
;
16 import java
.util
.List
;
18 import org
.eclipse
.jface
.viewers
.ISelection
;
19 import org
.eclipse
.jface
.viewers
.ISelectionChangedListener
;
20 import org
.eclipse
.jface
.viewers
.ISelectionProvider
;
21 import org
.eclipse
.jface
.viewers
.SelectionChangedEvent
;
25 * Informs all registered listeners of graph node selection change in the Frame.
31 public class SDWidgetSelectionProvider
implements ISelectionProvider
{
33 // ------------------------------------------------------------------------
35 // ------------------------------------------------------------------------
40 protected List
<ISelectionChangedListener
> fListenerList
= null;
42 * The current selection
44 protected ISelection fCurrentSelection
= null;
46 // ------------------------------------------------------------------------
48 // ------------------------------------------------------------------------
50 * Standard constructor
52 protected SDWidgetSelectionProvider() {
53 fListenerList
= new ArrayList
<ISelectionChangedListener
>();
56 // ------------------------------------------------------------------------
58 // ------------------------------------------------------------------------
62 * @see org.eclipse.jface.viewers.ISelectionProvider#addSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener)
65 public void addSelectionChangedListener(ISelectionChangedListener listener
) {
66 if (!fListenerList
.contains(listener
)) {
67 fListenerList
.add(listener
);
73 * @see org.eclipse.jface.viewers.ISelectionProvider#removeSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener)
76 public void removeSelectionChangedListener(ISelectionChangedListener listener
) {
77 fListenerList
.remove(listener
);
82 * @see org.eclipse.jface.viewers.ISelectionProvider#setSelection(org.eclipse.jface.viewers.ISelection)
85 public void setSelection(ISelection selection
) {
86 fCurrentSelection
= selection
;
87 for (int i
= 0; i
< fListenerList
.size(); i
++) {
88 ISelectionChangedListener list
= fListenerList
.get(i
);
89 list
.selectionChanged(new SelectionChangedEvent(this, fCurrentSelection
));
95 * @see org.eclipse.jface.viewers.ISelectionProvider#getSelection()
98 public ISelection
getSelection() {
99 return fCurrentSelection
;