1 /**********************************************************************
2 * Copyright (c) 2005, 2013 IBM Corporation, Ericsson
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
9 * IBM - Initial API and implementation
10 * Bernd Hufmann - Updated for TMF
11 **********************************************************************/
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 private List
<ISelectionChangedListener
> fListenerList
= null;
43 * The current selection
45 private ISelection fCurrentSelection
= null;
47 // ------------------------------------------------------------------------
49 // ------------------------------------------------------------------------
52 * Standard constructor
54 protected SDWidgetSelectionProvider() {
55 fListenerList
= new ArrayList
<ISelectionChangedListener
>();
58 // ------------------------------------------------------------------------
60 // ------------------------------------------------------------------------
63 public void addSelectionChangedListener(ISelectionChangedListener listener
) {
64 if (!fListenerList
.contains(listener
)) {
65 fListenerList
.add(listener
);
70 public void removeSelectionChangedListener(ISelectionChangedListener listener
) {
71 fListenerList
.remove(listener
);
75 public void setSelection(ISelection selection
) {
76 fCurrentSelection
= selection
;
77 for (int i
= 0; i
< fListenerList
.size(); i
++) {
78 ISelectionChangedListener list
= fListenerList
.get(i
);
79 list
.selectionChanged(new SelectionChangedEvent(this, fCurrentSelection
));
84 public ISelection
getSelection() {
85 return fCurrentSelection
;