All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.eclipse.jface.databinding.viewers.ViewerSetProperty Maven / Gradle / Ivy

The newest version!
/*******************************************************************************
 * Copyright (c) 2008, 2015 Matthew Hall and others.
 *
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *     Matthew Hall - initial API and implementation (bug 194734)
 *     Matthew Hall - bugs 263413, 264286
 ******************************************************************************/

package org.eclipse.jface.databinding.viewers;

import org.eclipse.core.databinding.observable.Realm;
import org.eclipse.core.databinding.observable.set.IObservableSet;
import org.eclipse.core.databinding.property.set.SimpleSetProperty;
import org.eclipse.jface.databinding.swt.DisplayRealm;
import org.eclipse.jface.internal.databinding.viewers.ViewerObservableSetDecorator;
import org.eclipse.jface.viewers.Viewer;

/**
 * Abstract set property implementation for {@link Viewer} properties. This
 * class implements some basic behavior that viewer properties are generally
 * expected to have, namely:
 * 
    *
  • Calling {@link #observe} should create the observable on the display * realm of the viewer's control, rather than the current default realm *
  • All observe() methods should return an * {@link IViewerObservableSet} *
* * @param * type of the source object * @param * type of the elements in the set * * @since 1.3 */ public abstract class ViewerSetProperty extends SimpleSetProperty implements IViewerSetProperty { @Override public IObservableSet observe(S source) { if (source instanceof Viewer) { return observe((Viewer) source); } return super.observe(source); } @Override public IObservableSet observe(Realm realm, S source) { IObservableSet observable = super.observe(realm, source); if (source instanceof Viewer) { return new ViewerObservableSetDecorator<>(observable, (Viewer) source); } return observable; } @SuppressWarnings("unchecked") @Override public IViewerObservableSet observe(Viewer viewer) { return (IViewerObservableSet) observe(DisplayRealm.getRealm(viewer.getControl().getDisplay()), (S) viewer); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy