1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
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 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.utils.ui.jface;
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;
21 * @author Tuukka Lehtonen
23 public class PostSelectionProvider extends BaseSelectionProvider implements IPostSelectionProvider {
25 private ListenerList postSelectionListeners = new ListenerList();
28 public void addPostSelectionChangedListener(ISelectionChangedListener listener) {
29 postSelectionListeners.add(listener);
33 public void removePostSelectionChangedListener(ISelectionChangedListener listener) {
34 postSelectionListeners.remove(listener);
37 protected Object[] getPostListeners() {
38 return postSelectionListeners.getListeners();
42 * Notify other UIs that selection has changed
43 * @param selection new selection
45 public void firePostSelection(ISelection selection) {
46 SelectionChangedEvent e = new SelectionChangedEvent(this, selection);
47 for (Object l : getPostListeners())
48 ((ISelectionChangedListener) l).selectionChanged(e);