1 /*******************************************************************************
2 * Copyright (c) 2010, 2011 Association for Decentralized Information Management in
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.modeling.ui.chart.property;
14 import org.eclipse.swt.events.SelectionEvent;
15 import org.eclipse.swt.widgets.Widget;
16 import org.simantics.browsing.ui.swt.widgets.Scale;
17 import org.simantics.browsing.ui.swt.widgets.impl.SelectionListenerImpl;
18 import org.simantics.databoard.Bindings;
19 import org.simantics.db.Resource;
20 import org.simantics.db.WriteGraph;
21 import org.simantics.db.exception.DatabaseException;
22 import org.simantics.db.management.ISessionContext;
25 * @author Tuukka Lehtonen
27 public class DelayedIntegerToDoublePropertyModifier extends SelectionListenerImpl<Resource> {
29 private final Scale slider;
30 private final String propertyURI;
31 private int selection;
33 public DelayedIntegerToDoublePropertyModifier(Scale slider, ISessionContext context, String propertyURI) {
36 this.propertyURI = propertyURI;
40 public void beforeApply() {
41 this.selection = slider.getWidget().getSelection();
45 public void apply(WriteGraph graph, Resource input) throws DatabaseException {
46 graph.claimLiteral(input, graph.getResource(propertyURI), (double) selection, Bindings.DOUBLE);
49 private void super$widgetSelected(SelectionEvent e) {
50 super.widgetSelected(e);
56 public void widgetSelected(final SelectionEvent e) {
57 final int mod = ++modCount;
58 final Widget widget = slider.getWidget();
59 widget.getDisplay().timerExec(250, new Runnable() {
62 if (widget.isDisposed() || mod != modCount)
64 super$widgetSelected(e);