Minor update
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-widgetx@101782 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
03670a230d
commit
6dad9dae6c
13
pom.xml
13
pom.xml
|
@ -28,11 +28,16 @@
|
|||
<gwtLogVersion>3.2.1</gwtLogVersion>
|
||||
<gxtVersion>3.0.1</gxtVersion> -->
|
||||
|
||||
<!-- Next -->
|
||||
<!-- Next
|
||||
<gwtVersion>2.6.1</gwtVersion>
|
||||
<gwtLogVersion>3.3.2</gwtLogVersion>
|
||||
<gxtVersion>3.1.1</gxtVersion> -->
|
||||
|
||||
<gwtVersion>2.6.1</gwtVersion>
|
||||
<gwtLogVersion>3.3.2</gwtLogVersion>
|
||||
<gxtVersion>3.1.1</gxtVersion>
|
||||
|
||||
|
||||
<webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
|
||||
|
||||
<KEYS>${env.KEYS}</KEYS>
|
||||
|
@ -83,7 +88,7 @@
|
|||
<dependency>
|
||||
<groupId>com.google.gwt</groupId>
|
||||
<artifactId>gwt-user</artifactId>
|
||||
<!-- <version>2.6.1</version> -->
|
||||
<version>${gwtVersion}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.portal</groupId>
|
||||
|
@ -92,7 +97,7 @@
|
|||
<dependency>
|
||||
<groupId>com.sencha.gxt</groupId>
|
||||
<artifactId>gxt</artifactId>
|
||||
<version>3.0.1</version>
|
||||
<version>${gxtVersion}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
@ -126,7 +131,7 @@
|
|||
<dependency>
|
||||
<groupId>com.allen-sauer.gwt.log</groupId>
|
||||
<artifactId>gwt-log</artifactId>
|
||||
<version>3.2.1</version>
|
||||
<version>${gwtLogVersion}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
|
|
@ -802,7 +802,7 @@ public class TabularDataXGridPanel extends ContentPanel {
|
|||
|
||||
toolBar = new ToolBar();
|
||||
toolBar.add(new LiveToolItem(grid));
|
||||
toolBar.addStyleName(ThemeStyles.getStyle().borderTop());
|
||||
toolBar.addStyleName(ThemeStyles.get().style().borderTop());
|
||||
toolBar.getElement().getStyle().setProperty("borderBottom", "none");
|
||||
|
||||
container.add(toolBar,
|
||||
|
|
|
@ -23,6 +23,8 @@ import com.sencha.gxt.widget.core.client.selection.CellSelection;
|
|||
public class GridAndCellSelectionModel<M> extends GridSelectionModel<M> {
|
||||
|
||||
protected CellSelection<M> cellSelected;
|
||||
private boolean focusCellCalled;
|
||||
private int indexOnSelectNoShift;
|
||||
|
||||
public GridAndCellSelectionModel() {
|
||||
super();
|
||||
|
@ -36,12 +38,13 @@ public class GridAndCellSelectionModel<M> extends GridSelectionModel<M> {
|
|||
* the row click event
|
||||
*/
|
||||
@Override
|
||||
protected void handleRowClick(RowClickEvent event) {
|
||||
protected void onRowClick(RowClickEvent event) {
|
||||
if (Element.is(event.getEvent().getEventTarget())
|
||||
&& !grid.getView().isSelectableTarget(
|
||||
Element.as(event.getEvent().getEventTarget()))) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isLocked()) {
|
||||
return;
|
||||
}
|
||||
|
@ -59,21 +62,67 @@ public class GridAndCellSelectionModel<M> extends GridSelectionModel<M> {
|
|||
deselectAll();
|
||||
return;
|
||||
}
|
||||
|
||||
M sel = listStore.get(rowIndex);
|
||||
|
||||
boolean isSelected = isSelected(sel);
|
||||
boolean isControl = xe.getCtrlOrMetaKey();
|
||||
boolean isShift = xe.getShiftKey();
|
||||
|
||||
// we only handle multi select with control key here
|
||||
if (selectionMode == SelectionMode.MULTI) {
|
||||
M sel = listStore.get(rowIndex);
|
||||
cellSelected = new CellSelection<M>(sel, rowIndex, colIndex);
|
||||
if (xe.getCtrlOrMetaKey() && isSelected(sel)) {
|
||||
if (isSelected && isControl) {
|
||||
grid.getView().focusCell(rowIndex, colIndex, false);
|
||||
focusCellCalled = true;
|
||||
// reset the starting location of the click
|
||||
indexOnSelectNoShift = rowIndex;
|
||||
doDeselect(Collections.singletonList(sel), false);
|
||||
} else if (xe.getCtrlOrMetaKey()) {
|
||||
} else if (isControl) {
|
||||
grid.getView().focusCell(rowIndex, colIndex, false);
|
||||
focusCellCalled = true;
|
||||
// reset the starting location of the click
|
||||
indexOnSelectNoShift = rowIndex;
|
||||
doSelect(Collections.singletonList(sel), true, false);
|
||||
} else if (isSelected(sel) && !event.getEvent().getShiftKey()
|
||||
&& !xe.getCtrlOrMetaKey() && selected.size() > 1) {
|
||||
grid.getView().focusCell(rowIndex, colIndex, false);
|
||||
} else if (isSelected && !isControl && !isShift
|
||||
&& selected.size() > 1) {
|
||||
doSelect(Collections.singletonList(sel), false, false);
|
||||
}
|
||||
|
||||
if (!focusCellCalled) {
|
||||
grid.getView().focusCell(rowIndex, colIndex, false);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Old GXT 2.5.1 if (Element.is(event.getEvent().getEventTarget()) &&
|
||||
* !grid.getView().isSelectableTarget(
|
||||
* Element.as(event.getEvent().getEventTarget()))) { return; } if
|
||||
* (isLocked()) { return; }
|
||||
*
|
||||
* if (fireSelectionChangeOnClick) { fireSelectionChange();
|
||||
* fireSelectionChangeOnClick = false; }
|
||||
*
|
||||
* XEvent xe = event.getEvent().<XEvent> cast();
|
||||
*
|
||||
* int rowIndex = event.getRowIndex(); int colIndex =
|
||||
* event.getColumnIndex(); if (rowIndex == -1) { deselectAll(); return;
|
||||
* }
|
||||
*
|
||||
*
|
||||
*
|
||||
* // we only handle multi select with control key here if
|
||||
* (selectionMode == SelectionMode.MULTI) { M sel =
|
||||
* listStore.get(rowIndex); cellSelected = new CellSelection<M>(sel,
|
||||
* rowIndex, colIndex); if (xe.getCtrlOrMetaKey() && isSelected(sel)) {
|
||||
* doDeselect(Collections.singletonList(sel), false); } else if
|
||||
* (xe.getCtrlOrMetaKey()) { grid.getView().focusCell(rowIndex,
|
||||
* colIndex, false); doSelect(Collections.singletonList(sel), true,
|
||||
* false); } else if (isSelected(sel) && !event.getEvent().getShiftKey()
|
||||
* && !xe.getCtrlOrMetaKey() && selected.size() > 1) {
|
||||
* grid.getView().focusCell(rowIndex, colIndex, false);
|
||||
* doSelect(Collections.singletonList(sel), false, false); } }
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -84,7 +133,114 @@ public class GridAndCellSelectionModel<M> extends GridSelectionModel<M> {
|
|||
* the row mouse down event
|
||||
*/
|
||||
@Override
|
||||
protected void handleRowMouseDown(RowMouseDownEvent event) {
|
||||
protected void onRowMouseDown(RowMouseDownEvent event) {
|
||||
if (Element.is(event.getEvent().getEventTarget())
|
||||
&& !grid.getView().isSelectableTarget(
|
||||
Element.as(event.getEvent().getEventTarget()))) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isLocked()) {
|
||||
return;
|
||||
}
|
||||
|
||||
int rowIndex = event.getRowIndex();
|
||||
int colIndex = event.getColumnIndex();
|
||||
if (rowIndex == -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
focusCellCalled = false;
|
||||
mouseDown = true;
|
||||
|
||||
XEvent e = event.getEvent().<XEvent> cast();
|
||||
|
||||
// it is important the focusCell be called once, and only once in
|
||||
// onRowMouseDown and onRowMouseClick
|
||||
// everything but multi select with the control key pressed is handled
|
||||
// in mouse down
|
||||
|
||||
if (event.getEvent().getButton() == Event.BUTTON_RIGHT) {
|
||||
if (selectionMode != SelectionMode.SINGLE
|
||||
&& isSelected(listStore.get(rowIndex))) {
|
||||
return;
|
||||
}
|
||||
M sel = listStore.get(rowIndex);
|
||||
cellSelected = new CellSelection<M>(sel, rowIndex, colIndex);
|
||||
grid.getView().focusCell(rowIndex, colIndex, false);
|
||||
select(rowIndex, false);
|
||||
focusCellCalled = true;
|
||||
} else {
|
||||
M sel = listStore.get(rowIndex);
|
||||
if (sel == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean isSelected = isSelected(sel);
|
||||
boolean isMeta = e.getCtrlOrMetaKey();
|
||||
boolean isShift = event.getEvent().getShiftKey();
|
||||
|
||||
switch (selectionMode) {
|
||||
case SIMPLE:
|
||||
grid.getView().focusCell(rowIndex, colIndex, false);
|
||||
focusCellCalled = true;
|
||||
if (!isSelected) {
|
||||
cellSelected = new CellSelection<M>(sel, rowIndex, colIndex);
|
||||
select(sel, true);
|
||||
} else if (isSelected && deselectOnSimpleClick) {
|
||||
deselect(sel);
|
||||
}
|
||||
break;
|
||||
|
||||
case SINGLE:
|
||||
grid.getView().focusCell(rowIndex, colIndex, false);
|
||||
focusCellCalled = true;
|
||||
if (isSelected && isMeta) {
|
||||
deselect(sel);
|
||||
} else if (!isSelected) {
|
||||
cellSelected = new CellSelection<M>(sel, rowIndex, colIndex);
|
||||
select(sel, false);
|
||||
}
|
||||
break;
|
||||
|
||||
case MULTI:
|
||||
if (isMeta) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (isShift && lastSelected != null) {
|
||||
int last = listStore.indexOf(lastSelected);
|
||||
grid.getView().focusCell(last, colIndex, false);
|
||||
|
||||
int start;
|
||||
int end;
|
||||
// This deals with flipping directions
|
||||
if (indexOnSelectNoShift < rowIndex) {
|
||||
start = indexOnSelectNoShift;
|
||||
end = rowIndex;
|
||||
} else {
|
||||
start = rowIndex;
|
||||
end = indexOnSelectNoShift;
|
||||
}
|
||||
|
||||
focusCellCalled = true;
|
||||
select(start, end, false);
|
||||
} else if (!isSelected) {
|
||||
cellSelected = new CellSelection<M>(sel, rowIndex, colIndex);
|
||||
// reset the starting location of multi select
|
||||
indexOnSelectNoShift = rowIndex;
|
||||
|
||||
grid.getView().focusCell(rowIndex, colIndex, false);
|
||||
focusCellCalled = true;
|
||||
doSelect(Collections.singletonList(sel), false, false);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
mouseDown = false;
|
||||
|
||||
/* GXT 3.0.1
|
||||
if (Element.is(event.getEvent().getEventTarget())
|
||||
&& !grid.getView().isSelectableTarget(
|
||||
Element.as(event.getEvent().getEventTarget()))) {
|
||||
|
@ -155,6 +311,7 @@ public class GridAndCellSelectionModel<M> extends GridSelectionModel<M> {
|
|||
}
|
||||
|
||||
mouseDown = false;
|
||||
*/
|
||||
}
|
||||
|
||||
public CellSelection<M> getCellSelected() {
|
||||
|
@ -165,6 +322,4 @@ public class GridAndCellSelectionModel<M> extends GridSelectionModel<M> {
|
|||
this.cellSelected = cellSelected;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue