]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.utils.ui/src/org/simantics/utils/ui/jface/PostSelectionProvider.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.utils.ui / src / org / simantics / utils / ui / jface / PostSelectionProvider.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
3  * in Industry THTH ry.
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
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.utils.ui.jface;
13
14 import org.eclipse.core.runtime.ListenerList;
15 import org.eclipse.jface.viewers.IPostSelectionProvider;
16 import org.eclipse.jface.viewers.ISelection;
17 import org.eclipse.jface.viewers.ISelectionChangedListener;
18 import org.eclipse.jface.viewers.SelectionChangedEvent;
19
20 /**
21  * @author Tuukka Lehtonen
22  */
23 public class PostSelectionProvider extends BaseSelectionProvider implements IPostSelectionProvider {
24
25     private ListenerList postSelectionListeners = new ListenerList();
26
27     @Override
28     public void addPostSelectionChangedListener(ISelectionChangedListener listener) {
29         postSelectionListeners.add(listener);
30     }
31
32     @Override
33     public void removePostSelectionChangedListener(ISelectionChangedListener listener) {
34         postSelectionListeners.remove(listener);
35     }
36
37     protected Object[] getPostListeners() {
38         return postSelectionListeners.getListeners();
39     }
40
41     /**
42      * Notify other UIs that selection has changed
43      * @param selection new selection
44      */
45     public void firePostSelection(ISelection selection) {
46         SelectionChangedEvent e = new SelectionChangedEvent(this, selection); 
47         for (Object l : getPostListeners())
48             ((ISelectionChangedListener) l).selectionChanged(e);
49     }
50
51 }