/*
- * Copyright (c) 2011 Greek Research and Technology Network
+ * Copyright 2011 GRNET S.A. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and
+ * documentation are those of the authors and should not be
+ * interpreted as representing official policies, either expressed
+ * or implied, of GRNET S.A.
*/
package gr.grnet.pithos.web.client;
import com.google.gwt.view.client.SelectionModel;
/**
- * An implementation of {@link CellPreviewEvent.Handler} that adds selection
+ * An implementation of {@link com.google.gwt.view.client.CellPreviewEvent.Handler} that adds selection
* support via the spacebar and mouse clicks and handles the control key.
*
* <p>
CellPreviewEvent.Handler<T> {
/**
- * Implementation of {@link EventTranslator} that only triggers selection when
+ * Implementation of {@link gr.grnet.pithos.web.client.GSSSelectionEventManager.EventTranslator} that only triggers selection when
* any checkbox is selected.
*
* @param <T> the data type
private final int column;
/**
- * Construct a new {@link CheckboxEventTranslator} that will trigger
+ * Construct a new {@link gr.grnet.pithos.web.client.GSSSelectionEventManager.CheckboxEventTranslator} that will trigger
* selection when any checkbox in any column is selected.
*/
public CheckboxEventTranslator() {
}
/**
- * Construct a new {@link CheckboxEventTranslator} that will trigger
+ * Construct a new {@link gr.grnet.pithos.web.client.GSSSelectionEventManager.CheckboxEventTranslator} that will trigger
* selection when a checkbox in the specified column is selected.
*
* @param column the column index, or -1 for all columns
this.column = column;
}
- public boolean clearCurrentSelection(CellPreviewEvent<T> event) {
+ @Override
+ public boolean clearCurrentSelection(@SuppressWarnings("unused") CellPreviewEvent<T> event) {
return false;
}
- public SelectAction translateSelectionEvent(CellPreviewEvent<T> event) {
+ @Override
+ public SelectAction translateSelectionEvent(CellPreviewEvent<T> event) {
// Handle the event.
NativeEvent nativeEvent = event.getNativeEvent();
if ("click".equals(nativeEvent.getType())) {
case TOGGLE:
addToSelection = !selectionModel.isSelected(rowValue);
break;
+ case DEFAULT:
+ break;
}
}
}
}
- public void onCellPreview(CellPreviewEvent<T> event) {
+ @Override
+public void onCellPreview(CellPreviewEvent<T> event) {
// Early exit if selection is already handled or we are editing.
if (event.isCellEditing() || event.isSelectionHandled()) {
return;
NativeEvent nativeEvent = event.getNativeEvent();
String type = nativeEvent.getType();
boolean rightclick = "mousedown".equals(type) && nativeEvent.getButton()==NativeEvent.BUTTON_RIGHT;
+ SelectAction action1 = action;
if(rightclick){
boolean shift = nativeEvent.getShiftKey();
boolean ctrlOrMeta = nativeEvent.getCtrlKey() || nativeEvent.getMetaKey();
boolean clearOthers = (translator == null) ? !ctrlOrMeta
: translator.clearCurrentSelection(event);
if (action == null || action == SelectAction.DEFAULT) {
- action = ctrlOrMeta ? SelectAction.TOGGLE : SelectAction.SELECT;
+ action1 = ctrlOrMeta ? SelectAction.TOGGLE : SelectAction.SELECT;
}
//if the row is selected then do nothing
if(selectionModel.isSelected(event.getValue())){
return;
}
doMultiSelection(selectionModel, event.getDisplay(), event.getIndex(),
- event.getValue(), action, shift, clearOthers);
+ event.getValue(), action1, shift, clearOthers);
}
else if ("click".equals(type)) {
/*
boolean clearOthers = (translator == null) ? !ctrlOrMeta
: translator.clearCurrentSelection(event);
if (action == null || action == SelectAction.DEFAULT) {
- action = ctrlOrMeta ? SelectAction.TOGGLE : SelectAction.SELECT;
+ action1 = ctrlOrMeta ? SelectAction.TOGGLE : SelectAction.SELECT;
}
doMultiSelection(selectionModel, event.getDisplay(), event.getIndex(),
- event.getValue(), action, shift, clearOthers);
+ event.getValue(), action1, shift, clearOthers);
if(ctrlOrMeta){
event.setCanceled(true);
}
boolean clearOthers = (translator == null) ? false
: translator.clearCurrentSelection(event);
if (action == null || action == SelectAction.DEFAULT) {
- action = SelectAction.TOGGLE;
+ action1 = SelectAction.TOGGLE;
}
doMultiSelection(selectionModel, event.getDisplay(), event.getIndex(),
- event.getValue(), action, shift, clearOthers);
+ event.getValue(), action1, shift, clearOthers);
}
}
}
case TOGGLE:
selectionModel.setSelected(value, !selectionModel.isSelected(value));
return;
+ case DEFAULT:
+ break;
}
}
Range range, boolean addToSelection, boolean clearOthers) {
// Get the list of values to select.
List<T> toUpdate = new ArrayList<T>();
- int itemCount = display.getVisibleItemCount();
int start = range.getStart();
int end = start + range.getLength();
for (int i = start; i < end ; i++) {