1 package org.simantics.selectionview;
3 import java.util.ArrayList;
4 import java.util.Collection;
5 import java.util.Collections;
6 import java.util.HashMap;
9 import org.simantics.ui.selection.WorkbenchSelectionElement;
11 final public class StandardSelectionInput implements SelectionInput {
13 private final Collection<WorkbenchSelectionElement> elements;
14 private final Map<String, Object> parameters;
16 public StandardSelectionInput(Collection<WorkbenchSelectionElement> elements, Map<String, Object> parameters) {
17 this.parameters = new HashMap<String, Object>(parameters);
18 this.elements = new ArrayList<WorkbenchSelectionElement>(elements);
21 public StandardSelectionInput(WorkbenchSelectionElement element, Map<String, Object> parameters) {
22 this.parameters = new HashMap<String, Object>(parameters);
23 this.elements = Collections.singletonList(element);
26 public StandardSelectionInput(WorkbenchSelectionElement element) {
27 this.parameters = Collections.emptyMap();
28 this.elements = Collections.singletonList(element);
31 public Collection<WorkbenchSelectionElement> getElements() {
35 public <T> T getParameter(String key) {
36 return (T)parameters.get(key);
40 public int hashCode() {
41 return elements.hashCode() + 31 * parameters.hashCode();
45 public boolean equals(Object object) {
48 else if (object == null)
50 else if (!(object instanceof StandardSelectionInput))
52 StandardSelectionInput ssi = (StandardSelectionInput)object;
53 if(!elements.equals(ssi.elements)) return false;
54 return parameters.equals(ssi.parameters);
58 public String toString() {
59 return "StandardSelectionInput[es=" + elements + ", par=" + parameters + "]";