BrightSide Workbench Full Report + Source Code
SelectEvent_506.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2011 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 package org.zkoss.zk.ui.event;
19 
20 import java.util.Collections;
21 import java.util.List;
22 import java.util.Map;
23 import java.util.Set;
24 import org.zkoss.json.JSONArray;
25 import org.zkoss.zk.au.AuRequest;
26 import org.zkoss.zk.au.AuRequests;
27 import org.zkoss.zk.ui.Component;
28 import org.zkoss.zk.ui.Desktop;
29 
36 public class SelectEvent_506 extends Event {
37  private final Set _selectedItems;
38  private final Component _ref;
39  private final int _keys;
40 
44  public static final int ALT_KEY = MouseEvent.ALT_KEY;
48  public static final int CTRL_KEY = MouseEvent.CTRL_KEY;
52  public static final int SHIFT_KEY = MouseEvent.SHIFT_KEY;
53 
57  public static final SelectEvent_506 getSelectEvent(AuRequest request) {
58  final Map data = request.getData();
59  final Desktop desktop = request.getDesktop();
60  Object obj = data.get("items");
61  if(obj instanceof String) {
62  String tmp = (String) data.get("items");
63  JSONArray ja = new JSONArray();
64  ja.add(tmp.replaceAll("^\\[\"", "")
65  .replaceAll("\"\\]$", "")
66  .replaceAll("^\\[", "")
67  .replaceAll("\\]$", ""));
68  data.put("items", ja);
69  }
70  return new SelectEvent_506(request.getCommand(), request.getComponent(),
71  AuRequests.convertToItems(desktop, (List)data.get("items")),
72  desktop.getComponentByUuidIfAny((String)data.get("reference")),
73  AuRequests.parseKeys(data));
74  }
75 
79  public SelectEvent_506(String name, Component target, Set selectedItems) {
80  this(name, target, selectedItems, null, 0);
81  }
82 
86  public SelectEvent_506(String name, Component target, Set selectedItems,
87  Component ref) {
88  this(name, target, selectedItems, ref, 0);
89  }
96  public SelectEvent_506(String name, Component target, Set selectedItems,
97  Component ref, int keys) {
98  super(name, target);
99  _selectedItems = selectedItems != null ?
100  selectedItems: Collections.EMPTY_SET;
101  _ref = ref;
102  _keys = keys;
103  }
106  public final Set getSelectedItems() {
107  return _selectedItems;
108  }
109 
117  public Component getReference() {
118  return _ref;
119  }
120 
127  public final int getKeys() {
128  return _keys;
129  }
130 }
static final SelectEvent_506 getSelectEvent(AuRequest request)
SelectEvent_506(String name, Component target, Set selectedItems, Component ref)
SelectEvent_506(String name, Component target, Set selectedItems)
SelectEvent_506(String name, Component target, Set selectedItems, Component ref, int keys)