1 /*******************************************************************************
2 * Copyright (c) 2019 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 * Semantum Oy - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.document.swt.core.widget;
14 import java.util.List;
16 import org.eclipse.swt.events.SelectionEvent;
17 import org.eclipse.swt.events.SelectionListener;
18 import org.simantics.document.server.client.WidgetData;
19 import org.simantics.document.server.io.CommandContextImpl;
20 import org.simantics.document.server.io.CommandContextMutable;
21 import org.simantics.document.server.io.ICommand;
22 import org.simantics.document.swt.core.SWTDocument;
23 import org.simantics.document.swt.core.base.PropertyWidgetManager;
24 import org.simantics.utils.datastructures.Pair;
26 public class ButtonSelectionListener implements SelectionListener {
28 private WidgetData wd;
29 private List<Pair<WidgetData, ICommand>> data;
31 public ButtonSelectionListener(WidgetData wd, List<Pair<WidgetData, ICommand>> data) {
37 public void widgetSelected(SelectionEvent e) {
38 widgetDefaultSelected(e);
42 public void widgetDefaultSelected(SelectionEvent e) {
44 CommandContextMutable context = new CommandContextImpl();
45 context.putValue("event", "onPress");
48 ((SWTDocument)wd.document).handleCommands(data, context, e.widget);
51 PropertyWidgetManager.sendEvent((SWTDocument)wd.document, wd, "onPress", e.widget, context);