/*******************************************************************************
- * Copyright (c) 2007, 2010 Association for Decentralized Information Management
+ * Copyright (c) 2007, 2018 Association for Decentralized Information Management
* in Industry THTH ry.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
+import org.simantics.utils.ObjectUtils;
/**
* BaseSelectionProvider is a base implementation ISelectionProvider -interface.
*/
public class BaseSelectionProvider implements ISelectionProvider {
- protected ListenerList selectionListeners = new ListenerList();
+ protected ListenerList<ISelectionChangedListener> selectionListeners = new ListenerList<>();
protected ISelection selection = StructuredSelection.EMPTY;
return selection;
}
+ public void clearListeners() {
+ clearSelectionChangedListeners();
+ }
+
+ public void clearSelectionChangedListeners() {
+ selectionListeners.clear();
+ }
+
public void removeSelectionChangedListener(ISelectionChangedListener listener) {
selectionListeners.remove(listener);
}
*
* @param selection the new selection
*/
- public void setAndFireNonEqualSelection(ISelection selection) {
+ public boolean setAndFireNonEqualSelection(ISelection selection) {
ISelection old = getSelection();
- if (selection == old)
- return;
+ if (ObjectUtils.objectEquals(old, selection))
+ return false;
this.selection = selection;
- if (selection != null && !selection.equals(old))
+ if (selection != null)
fireSelection(selection);
+ return true;
}
public boolean selectionEquals(ISelection s) {