public class ControlMovedObservable extends ControlObservable {

	public ControlMovedObservable(Control control) {
		super(control);
	}

	@Override
	protected AbstractControlListener getControlListener(Control control, Observer<? super ControlEvent> observer) {
		return new AbstractControlListener(control) {
			@Override
			public void controlMoved(ControlEvent e) {
				if (!isDisposed()) {
					observer.onNext(e);
				}
			}
		};
	}

} public class ControlResizedObservable extends ControlObservable {

	public ControlResizedObservable(Control control) {
		super(control);
	}

	@Override
	protected AbstractControlListener getControlListener(Control control, Observer<? super ControlEvent> observer) {
		return new AbstractControlListener(control) {
			@Override
			public void controlResized(ControlEvent e) {
				if (!isDisposed()) {
					observer.onNext(e);
				}
			}
		};
	}

} public abstract class DisplayObservable extends Observable<Event> {

	private Display display;
	private int eventType;

	public DisplayObservable(Display display, int eventType) {
		this.display = display;
		this.eventType = eventType;
	}

	@Override
	protected void subscribeActual(Observer<? super Event> observer) {
		if (!Preconditions.checkDisplay(observer, display)) {
			return;
		}
		DisplayListener listener = new DisplayListener(display, eventType, observer);
		observer.onSubscribe(listener);
		display.addListener(SWT.Dispose, e -> listener.dispose());
		addlistener(listener);
	}

	protected abstract void addlistener(Listener listener);

	static final class DisplayListener extends MainThreadDisposable implements Listener {
		private final Display display;
		private final Observer<? super Event> observer;
		private final int eventType;

		DisplayListener(Display display, int eventType, Observer<? super Event> observer) {
			this.display = display;
			this.eventType = eventType;
			this.observer = observer;
		}

		@Override
		protected void onDispose() {
			display.removeListener(eventType, this);
		}

		@Override
		public void handleEvent(Event event) {
			if (!isDisposed()) {
				observer.onNext(event);
			}
		}
	}
} public class DisposeObservable extends Observable<DisposeEvent> {

	private Widget widget;

	public DisposeObservable(Widget widget) {
		this.widget = widget;
	}

	@Override
	protected void subscribeActual(Observer<? super DisposeEvent> observer) {
		if (!Preconditions.checkWidget(observer, widget)) {
			return;
		}
		RxDisposeListener listener = new RxDisposeListener(widget, observer);
		observer.onSubscribe(listener);
		widget.addDisposeListener(e -> listener.dispose());
		widget.addDisposeListener(listener);
	}

	static final class RxDisposeListener extends MainThreadDisposable implements DisposeListener {
		private final Widget widget;
		private final Observer<? super DisposeEvent> observer;

		RxDisposeListener(Widget widget, Observer<? super DisposeEvent> observer) {
			this.widget = widget;
			this.observer = observer;
		}

		@Override
		protected void onDispose() {
			widget.removeDisposeListener(this);
		}

		@Override
		public void widgetDisposed(DisposeEvent e) {
			if (!isDisposed()) {
				observer.onNext(e);
				observer.onComplete();
			}
		}
	}
} public class FocusGainedObservable extends FocusObservable {

	public FocusGainedObservable(Control control) {
		super(control);
	}

	@Override
	protected AbstractFocusListener getFocusListener(Control control, Observer<? super FocusEvent> observer) {
		return new AbstractFocusListener(control) {
			@Override
			public void focusGained(FocusEvent e) {
				if (!isDisposed()) {
					observer.onNext(e);
				}
			}
		};
	}

} public class FocusLostObservable extends FocusObservable {

	public FocusLostObservable(Control control) {
		super(control);
	}

	@Override
	protected AbstractFocusListener getFocusListener(Control control, Observer<? super FocusEvent> observer) {
		return new AbstractFocusListener(control) {
			@Override
			public void focusLost(FocusEvent e) {
				if (!isDisposed()) {
					observer.onNext(e);
				}
			}
		};
	}

} public class KeyPressedObservable extends KeyObservable {

	public KeyPressedObservable(Control control) {
		super(control);
	}

	@Override
	protected AbstractKeyListener getMouseListener(Control control, Observer<? super KeyEvent> observer) {
		return new AbstractKeyListener(control) {
			@Override
			public void keyPressed(KeyEvent e) {
				if (!isDisposed()) {
					observer.onNext(e);
				}
			}
		};
	}

} public class KeyReleasedObservable extends KeyObservable {

	public KeyReleasedObservable(Control control) {
		super(control);
	}

	@Override
	protected AbstractKeyListener getMouseListener(Control control, Observer<? super KeyEvent> observer) {
		return new AbstractKeyListener(control) {
			@Override
			public void keyReleased(KeyEvent e) {
				if (!isDisposed()) {
					observer.onNext(e);
				}
			}
		};
	}

} public class TraverseObservable extends Observable<TraverseEvent> {

	private Control control;

	public TraverseObservable(Control control) {
		this.control = control;
	}

	@Override
	protected void subscribeActual(Observer<? super TraverseEvent> observer) {
		if (!Preconditions.checkWidget(observer, control)) {
			return;
		}
		RxTraverseListener listener = new RxTraverseListener(control, observer);
		observer.onSubscribe(listener);
		control.addDisposeListener(e -> listener.dispose());
		control.addTraverseListener(listener);
	}

	static final class RxTraverseListener extends MainThreadDisposable implements TraverseListener {
		private final Control control;
		private final Observer<? super TraverseEvent> observer;

		RxTraverseListener(Control control, Observer<? super TraverseEvent> observer) {
			this.control = control;
			this.observer = observer;
		}

		@Override
		protected void onDispose() {
			control.removeTraverseListener(this);
		}

		@Override
		public void keyTraversed(TraverseEvent e) {
			if (!isDisposed()) {
				observer.onNext(e);
			}
		}
	}
} public class MouseDoubleClickObservable extends MouseObservable {

	public MouseDoubleClickObservable(Control control) {
		super(control);
	}

	@Override
	protected AbstractMouseListener getMouseListener(Control control, Observer<? super MouseEvent> observer) {
		return new AbstractMouseListener(control) {
			@Override
			public void mouseDoubleClick(MouseEvent e) {
				if (!isDisposed()) {
					observer.onNext(e);
				}
			}
		};
	}

} public class MouseDownObservable extends MouseObservable {

	public MouseDownObservable(Control control) {
		super(control);
	}

	@Override
	protected AbstractMouseListener getMouseListener(Control control, Observer<? super MouseEvent> observer) {
		return new AbstractMouseListener(control) {
			@Override
			public void mouseDown(MouseEvent e) {
				if (!isDisposed()) {
					observer.onNext(e);
				}
			}
		};
	}

} public class MouseEnterObservable extends MouseTrackObservable {

	public MouseEnterObservable(Control control) {
		super(control);
	}

	@Override
	protected AbstractMouseTrackListener getMouseListener(Control control, Observer<? super MouseEvent> observer) {
		return new AbstractMouseTrackListener(control) {
			@Override
			public void mouseEnter(MouseEvent e) {
				observer.onNext(e);
			}
		};
	}
} public class MouseExitObservable extends MouseTrackObservable {

	public MouseExitObservable(Control control) {
		super(control);
	}

	@Override
	protected AbstractMouseTrackListener getMouseListener(Control control, Observer<? super MouseEvent> observer) {
		return new AbstractMouseTrackListener(control) {
			@Override
			public void mouseExit(MouseEvent e) {
				if (!isDisposed()) {
					observer.onNext(e);
				}
			}
		};
	}

} public class MouseUpObservable extends MouseObservable {

	public MouseUpObservable(Control control) {
		super(control);
	}

	@Override
	protected AbstractMouseListener getMouseListener(Control control, Observer<? super MouseEvent> observer) {
		return new AbstractMouseListener(control) {
			@Override
			public void mouseUp(MouseEvent e) {
				if (!isDisposed()) {
					observer.onNext(e);
				}
			}
		};
	}

} public class MouseWheelObservable extends Observable<MouseEvent> {

	private Control control;

	public MouseWheelObservable(Control control) {
		this.control = control;
	}

	@Override
	protected void subscribeActual(Observer<? super MouseEvent> observer) {
		if (!Preconditions.checkWidget(observer, control)) {
			return;
		}
		RxMouseWheelListener listener = new RxMouseWheelListener(control, observer);
		observer.onSubscribe(listener);
		control.addDisposeListener(e -> listener.dispose());
		control.addMouseWheelListener(listener);

	}

	static class RxMouseWheelListener extends MainThreadDisposable implements MouseWheelListener {
		private final Control control;
		private Observer<? super MouseEvent> observer;

		RxMouseWheelListener(Control control, Observer<? super MouseEvent> observer) {
			this.control = control;
			this.observer = observer;
		}

		@Override
		protected void onDispose() {
			control.removeMouseWheelListener(this);
		}

		@Override
		public void mouseScrolled(MouseEvent e) {
			if (!isDisposed()) {
				observer.onNext(e);
			}
		}
	}
} public class PaintObservable extends Observable<PaintEvent> {

	private Control control;

	public PaintObservable(Control control) {
		this.control = control;
	}

	@Override
	protected void subscribeActual(Observer<? super PaintEvent> observer) {
		if (!Preconditions.checkWidget(observer, control)) {
			return;
		}
		RxPaintListener listener = new RxPaintListener(control, observer);
		observer.onSubscribe(listener);
		control.addDisposeListener(e -> listener.dispose());
		control.addPaintListener(listener);
	}

	static final class RxPaintListener extends MainThreadDisposable implements PaintListener {
		private final Control control;
		private final Observer<? super PaintEvent> observer;

		RxPaintListener(Control control, Observer<? super PaintEvent> observer) {
			this.control = control;
			this.observer = observer;
		}

		@Override
		protected void onDispose() {
			control.removePaintListener(this);
		}

		@Override
		public void paintControl(PaintEvent e) {
			if (!isDisposed()) {
				observer.onNext(e);
			}
		}
	}
} public class SelectionObservable extends Observable<SelectionEvent> {

	private Widget widget;
	private SelectionAdapter selectionAdapter;

	public SelectionObservable(Widget widget) {
		this.widget = widget;
		selectionAdapter = SelectionAdapter.create(widget);
	}

	@Override
	protected void subscribeActual(Observer<? super SelectionEvent> observer) {
		if (!Preconditions.checkWidget(observer, widget)) {
			return;
		}

		RxSelectionListener listener = new RxSelectionListener(selectionAdapter, observer);
		observer.onSubscribe(listener);
		widget.addDisposeListener(e -> listener.dispose());
		selectionAdapter.addSelectionListener(listener);
	}

	static final class RxSelectionListener extends MainThreadDisposable implements SelectionListener {
		private final SelectionAdapter selectionAdapter;
		private final Observer<? super SelectionEvent> observer;

		RxSelectionListener(SelectionAdapter selectionAdapter, Observer<? super SelectionEvent> observer) {
			this.selectionAdapter = selectionAdapter;
			this.observer = observer;
		}

		@Override
		protected void onDispose() {
			selectionAdapter.removeSelectionListener(this);
		}

		@Override
		public void widgetSelected(SelectionEvent e) {
			if (!isDisposed()) {
				observer.onNext(e);
			}
		}

		@Override
		public void widgetDefaultSelected(SelectionEvent e) {
		}
	}
} public class WidgetObservable extends Observable<Event> {

	private Widget widget;
	private int eventType;

	public WidgetObservable(Widget widget, int eventType) {
		this.widget = widget;
		this.eventType = eventType;
	}

	@Override
	protected void subscribeActual(Observer<? super Event> observer) {
		if (!Preconditions.checkWidget(observer, widget)) {
			return;
		}
		WidgetListener listener = new WidgetListener(widget, eventType, observer);
		observer.onSubscribe(listener);
		widget.addDisposeListener(e -> listener.dispose());
		widget.addListener(eventType, listener);
	}

	static final class WidgetListener extends MainThreadDisposable implements Listener {
		private final Widget widget;
		private final Observer<? super Event> observer;
		private final int eventType;

		WidgetListener(Widget widget, int eventType, Observer<? super Event> observer) {
			this.widget = widget;
			this.eventType = eventType;
			this.observer = observer;
		}

		@Override
		protected void onDispose() {
			widget.removeListener(eventType, this);
		}

		@Override
		public void handleEvent(Event event) {
			if (!isDisposed()) {
				observer.onNext(event);
			}
		}
	}
}
import javax.swing.table.TableColumn;
import org.eclipse.swt.custom.CCombo;
import org.eclipse.swt.custom.CTabFolder;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.custom.TableCursor;
import org.eclipse.swt.custom.TreeCursor;
import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.TraverseEvent;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.CoolItem;
import org.eclipse.swt.widgets.DateTime;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Link;
import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.Sash;
import org.eclipse.swt.widgets.Scale;
import org.eclipse.swt.widgets.Slider;
import org.eclipse.swt.widgets.Spinner;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.ToolItem;
import org.eclipse.swt.widgets.ToolTip;
import org.eclipse.swt.widgets.TrayItem;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeColumn;
import org.eclipse.swt.widgets.Widget;
import io.reactivex.Observable;
import io.reactivex.swt.listener.control.ControlMovedObservable;
import io.reactivex.swt.listener.control.ControlResizedObservable;
import io.reactivex.swt.listener.display.DisplayObservable;
import io.reactivex.swt.listener.dispose.DisposeObservable;
import io.reactivex.swt.listener.focus.FocusGainedObservable;
import io.reactivex.swt.listener.focus.FocusLostObservable;
import io.reactivex.swt.listener.key.KeyPressedObservable;
import io.reactivex.swt.listener.key.KeyReleasedObservable;
import io.reactivex.swt.listener.key.TraverseObservable;
import io.reactivex.swt.listener.mouse.MouseDoubleClickObservable;
import io.reactivex.swt.listener.mouse.MouseDownObservable;
import io.reactivex.swt.listener.mouse.MouseEnterObservable;
import io.reactivex.swt.listener.mouse.MouseExitObservable;
import io.reactivex.swt.listener.mouse.MouseUpObservable;
import io.reactivex.swt.listener.mouse.MouseWheelObservable;
import io.reactivex.swt.listener.paint.PaintObservable;
import io.reactivex.swt.listener.selection.SelectionObservable;
import io.reactivex.swt.listener.widget.WidgetObservable;
/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package io.reactivex.swt.listener;




public class SwtObservables {

	public static Observable<DisposeEvent> widgetDisposed(Widget widget) {
		checkNotNull(widget, "widget == null");
		return new DisposeObservable(widget);
	}

	public static Observable<Event> displayFilter(Display display, int eventType) {
		checkNotNull(display, "display == null");
		return new DisplayObservable(display, eventType) {

			@Override
			protected void addlistener(Listener listener) {
				display.addFilter(eventType, listener);
			}
		};
	}

	public static Observable<Event> displayListener(Display display, int eventType) {
		checkNotNull(display, "display == null");
		return new DisplayObservable(display, eventType) {

			@Override
			protected void addlistener(Listener listener) {
				display.addListener(eventType, listener);
			}
		};
	}

	public static Observable<Event> from(Widget widget, int eventType) {
		checkNotNull(widget, "widget == null");
		return new WidgetObservable(widget, eventType);
	}

	public static Observable<FocusEvent> focusGained(Control control) {
		checkNotNull(control, "control == null");
		return new FocusGainedObservable(control);
	}

	public static Observable<FocusEvent> focusLost(Control control) {
		checkNotNull(control, "control == null");
		return new FocusLostObservable(control);
	}

	public static Observable<ControlEvent> controlResized(Control control) {
		checkNotNull(control, "control == null");
		return new ControlResizedObservable(control);
	}

	public static Observable<ControlEvent> controlMoved(Control control) {
		checkNotNull(control, "control == null");
		return new ControlMovedObservable(control);
	}

	public static Observable<KeyEvent> keyPressed(Control control) {
		checkNotNull(control, "control == null");
		return new KeyPressedObservable(control);
	}

	public static Observable<KeyEvent> keyReleased(Control control) {
		checkNotNull(control, "control == null");
		return new KeyReleasedObservable(control);
	}

	public static Observable<TraverseEvent> keyTraversed(Control control) {
		checkNotNull(control, "control == null");
		return new TraverseObservable(control);
	}

	public static Observable<MouseEvent> mouseEnter(Control control) {
		checkNotNull(control, "control == null");
		return new MouseEnterObservable(control);
	}

	public static Observable<MouseEvent> mouseExit(Control control) {
		checkNotNull(control, "control == null");
		return new MouseExitObservable(control);
	}

	public static Observable<MouseEvent> mouseHover(Control control) {
		checkNotNull(control, "control == null");
		return new MouseExitObservable(control);
	}

	public static Observable<MouseEvent> mouseUp(Control control) {
		checkNotNull(control, "control == null");
		return new MouseUpObservable(control);
	}

	public static Observable<MouseEvent> mouseDown(Control control) {
		checkNotNull(control, "control == null");
		return new MouseDownObservable(control);