Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/* SelectEvent.java
Purpose:
Description:
History:
Thu Jun 16 18:05:51 2005, Created by tomyeh
Copyright (C) 2005 Potix Corporation. All Rights Reserved.
{{IS_RIGHT
This program is distributed under LGPL Version 2.1 in the hope that
it will be useful, but WITHOUT ANY WARRANTY.
}}IS_RIGHT
*/
package org.zkoss.zk.ui.event;
import static org.zkoss.lang.Generics.cast;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.zkoss.zk.au.AuRequest;
import org.zkoss.zk.au.AuRequests;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.Desktop;
/**
* Represents an event cause by user's the list selection is changed
* at the client.
*
* @author tomyeh
*/
@SuppressWarnings("serial")
public class SelectEvent extends Event {
private final Set _selectedItems;
private final Set _prevSelectedItems;
private final Set _unselectedItems;
private final Set _prevSelectedObjects;
private final Set _selectedObjects;
private final Set _unselectedObjects;
private final T _ref;
private final int _keys;
/** Indicates whether the Alt key is pressed.
* It might be returned as part of {@link #getKeys}.
*/
public static final int ALT_KEY = MouseEvent.ALT_KEY;
/** Indicates whether the Ctrl key is pressed.
* It might be returned as part of {@link #getKeys}.
*/
public static final int CTRL_KEY = MouseEvent.CTRL_KEY;
/** Indicates whether the Shift key is pressed.
* It might be returned as part of {@link #getKeys}.
*/
public static final int SHIFT_KEY = MouseEvent.SHIFT_KEY;
/** Converts an AU request to a select event.
* @since 5.0.0
*/
public static final SelectEvent getSelectEvent(AuRequest request) {
return getSelectEvent(request, null);
}
/** Converts an AU request to a select event.
* @since 6.0.0
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
public static final SelectEvent getSelectEvent(AuRequest request,
SelectedObjectHandler handler) {
final Map data = request.getData();
final Desktop desktop = request.getDesktop();
final List sitems = cast((List) data.get("items"));
final Set items = AuRequests.convertToItems(desktop, sitems);
final Set prevSelectedItems = (Set) (handler == null ? null : handler.getPreviousSelectedItems());
final Set unselectedItems = (Set) (handler == null ? null : handler.getUnselectedItems());
final Set prevSelectedObjects = (Set) (handler == null ? null : handler.getPreviousSelectedObjects());
final Set unselectedObjects = (Set) (handler == null ? null : handler.getUnselectedObjects());
final Set objs = (Set) (handler == null ? null : handler.getObjects(items));
return new SelectEvent(request.getCommand(), request.getComponent(), items, prevSelectedItems,
unselectedItems, objs, prevSelectedObjects, unselectedObjects,
(T) desktop.getComponentByUuidIfAny((String) data.get("reference")), null, AuRequests.parseKeys(data));
}
/**
* A handle to retrieve selected objects from selected items (components)
* if possible.
*/
public interface SelectedObjectHandler {
/**
* Return selected objects from selected items if possible.
*/
public Set