X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.document.swt.core%2Fsrc%2Forg%2Fsimantics%2Fdocument%2Fswt%2Fcore%2Fwidget%2FButtonSelectionListener.java;fp=bundles%2Forg.simantics.document.swt.core%2Fsrc%2Forg%2Fsimantics%2Fdocument%2Fswt%2Fcore%2Fwidget%2FButtonSelectionListener.java;h=303460deab8fc6b1474887e4bc73c0453a08d7e5;hb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;hp=021ba711215d94a472801db100a76ca0de2cf343;hpb=24e2b34260f219f0d1644ca7a138894980e25b14;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.document.swt.core/src/org/simantics/document/swt/core/widget/ButtonSelectionListener.java b/bundles/org.simantics.document.swt.core/src/org/simantics/document/swt/core/widget/ButtonSelectionListener.java index 021ba7112..303460dea 100644 --- a/bundles/org.simantics.document.swt.core/src/org/simantics/document/swt/core/widget/ButtonSelectionListener.java +++ b/bundles/org.simantics.document.swt.core/src/org/simantics/document/swt/core/widget/ButtonSelectionListener.java @@ -1,50 +1,50 @@ -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 data; - - public ButtonSelectionListener(LinkedHashMap 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 commands = new ArrayList(); - 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(); - - } - +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 data; + + public ButtonSelectionListener(LinkedHashMap 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 commands = new ArrayList(); + 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