-package org.simantics.document.swt.core.widget;\r
-\r
-import java.util.ArrayList;\r
-import java.util.LinkedHashMap;\r
-\r
-import org.eclipse.swt.events.SelectionEvent;\r
-import org.eclipse.swt.events.SelectionListener;\r
-import org.simantics.document.server.IEventCommand;\r
-import org.simantics.document.server.client.WidgetData;\r
-import org.simantics.document.swt.core.SWTDocument;\r
-\r
-public class ButtonSelectionListener implements SelectionListener {\r
- \r
- private LinkedHashMap<WidgetData, String> data;\r
- \r
- public ButtonSelectionListener(LinkedHashMap<WidgetData, String> data) {\r
- this.data = data;\r
- }\r
-\r
- @Override\r
- public void widgetSelected(SelectionEvent e) {\r
- widgetDefaultSelected(e);\r
- }\r
-\r
- @Override\r
- public void widgetDefaultSelected(SelectionEvent e) {\r
- SWTDocument document = null;\r
- // Build a linked list of commands\r
- ArrayList<IEventCommand> commands = new ArrayList<IEventCommand>();\r
- for(WidgetData d : data.keySet()) {\r
- document = (SWTDocument)d.document; // assume that all widgets are from the same document\r
- IEventCommand p = d.eventCommand(data.get(d));\r
- if(p != null) {\r
- if(!commands.isEmpty())\r
- commands.get(commands.size()-1).setNext(p);\r
- commands.add(p);\r
- }\r
- }\r
-\r
- // empty errors\r
-// if(document != null)\r
-// document.displayError("");\r
-\r
- // Execute the first command, the linked list handles the rest of them\r
- if(!commands.isEmpty())\r
- commands.get(0).handleCommand();\r
- \r
- }\r
- \r
+package org.simantics.document.swt.core.widget;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.simantics.document.server.IEventCommand;
+import org.simantics.document.server.client.WidgetData;
+import org.simantics.document.swt.core.SWTDocument;
+
+public class ButtonSelectionListener implements SelectionListener {
+
+ private LinkedHashMap<WidgetData, String> data;
+
+ public ButtonSelectionListener(LinkedHashMap<WidgetData, String> data) {
+ this.data = data;
+ }
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ widgetDefaultSelected(e);
+ }
+
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ SWTDocument document = null;
+ // Build a linked list of commands
+ ArrayList<IEventCommand> commands = new ArrayList<IEventCommand>();
+ for(WidgetData d : data.keySet()) {
+ document = (SWTDocument)d.document; // assume that all widgets are from the same document
+ IEventCommand p = d.eventCommand(data.get(d));
+ if(p != null) {
+ if(!commands.isEmpty())
+ commands.get(commands.size()-1).setNext(p);
+ commands.add(p);
+ }
+ }
+
+ // empty errors
+// if(document != null)
+// document.displayError("");
+
+ // Execute the first command, the linked list handles the rest of them
+ if(!commands.isEmpty())
+ commands.get(0).handleCommand();
+
+ }
+
}
\ No newline at end of file