Skip to content
Open
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ...FirstColumnTest-overflowBasedOnFullMergedWidth_PhantomJS_mergedNarrowColumn.png
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import com.vaadin.event.Action;
import com.vaadin.event.Action.Handler;
import com.vaadin.server.KeyMapper;
import com.vaadin.shared.Registration;

/**
* ContextMenuManager is an utility class for the Spreadsheet component. This
Expand All @@ -51,6 +52,8 @@ public class ContextMenuManager implements Serializable {

private int contextMenuHeaderIndex = -1;

private Registration contextClickRegistration;

/**
* Constructs a new ContextMenuManager and ties it to the given Spreadsheet.
*
Expand All @@ -77,6 +80,7 @@ public void addActionHandler(Handler actionHandler) {
actionHandlers.add(actionHandler);
}
}
checkContextClickHandler();
}

/**
Expand All @@ -94,6 +98,7 @@ public void removeActionHandler(Handler actionHandler) {
actionMapper = null;
}
}
checkContextClickHandler();
}

/**
Expand All @@ -106,6 +111,21 @@ public boolean hasActionHandlers() {
return actionHandlers != null && actionHandlers.size() > 0;
}

private void checkContextClickHandler() {
if (hasActionHandlers()) {
if (contextClickRegistration == null) {
contextClickRegistration = spreadsheet
.addContextClickListener(event -> {
// this is never called, only here to tell the connector to
// watch for context events
});
}
} else if (contextClickRegistration != null) {
contextClickRegistration.remove();
contextClickRegistration = null;
}
}

/**
* This method is called when a context menu event has happened on any cell
* of the target Spreadsheet.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@
import com.vaadin.addon.spreadsheet.shared.SpreadsheetState;
import com.vaadin.event.Action;
import com.vaadin.event.Action.Handler;
import com.vaadin.event.ContextClickEvent;
import com.vaadin.server.Resource;
import com.vaadin.shared.MouseEventDetails;
import com.vaadin.ui.AbstractComponent;
import com.vaadin.ui.Component;
import com.vaadin.ui.Component.Focusable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -824,9 +824,6 @@ public void setPosition(int col1, int col2, int row1, int row2) {
setFillMode(false);
}

if (!dragging) {
showTouchActions();
}
}

public void setPaintPosition(int col1, int col2, int row1, int row2) {
Expand All @@ -847,128 +844,6 @@ public void setPaintPosition(int col1, int col2, int row1, int row2) {
}
}

private void showTouchActions() {
if (touchMode) {
// show touch actions in popup

if (touchActions != null) {
// remove old
touchActions.hide();
}

touchActions = new VOverlay(true);
touchActions.setOwner((Widget) sheetWidget.actionHandler);
touchActions.addStyleName("v-contextmenu");

final MenuBar m = new MenuBar();
m.addItem(new SafeHtmlBuilder().appendEscaped("Fill").toSafeHtml(),
new ScheduledCommand() {

@Override
public void execute() {
setFillMode(true);
touchActions.hide();
}
});

touchActions.add(m);

Scheduler.get().scheduleDeferred(new ScheduledCommand() {

@Override
public void execute() {
touchActions
.setPopupPositionAndShow(new PositionCallback() {

@Override
public void setPosition(int offsetWidth,
int offsetHeight) {
// above top border
int top = 0;
int left = 0;
int bottom = 0;
int width = 0;
int parentTop = 0;
if (topRight != null
&& topRight.isVisible()) {
top = topRight.top.getAbsoluteTop();
left = topRight.top.getAbsoluteLeft();
width = topRight.top.getClientWidth();
bottom = topRight.bottom
.getAbsoluteBottom() + 5;
if (topLeft.isVisible()) {
width += topLeft.top
.getClientWidth();
}
if (bottomRight.isVisible()) {
bottom = bottomRight.bottom
.getAbsoluteBottom() + 5;
}
} else if (topLeft != null
&& topLeft.isVisible()) {
top = topLeft.top.getAbsoluteTop();
left = topLeft.top.getAbsoluteLeft();
width = topLeft.top.getClientWidth();
bottom = topLeft.bottom
.getAbsoluteBottom() + 5;
if (bottomLeft.isVisible()) {
bottom = bottomLeft.bottom
.getAbsoluteBottom() + 5;
}
} else if (bottomLeft != null
&& bottomLeft.isVisible()) {
top = bottomLeft.top.getAbsoluteTop();
left = bottomLeft.top.getAbsoluteLeft();
width = bottomLeft.top.getClientWidth();
bottom = bottomLeft.bottom
.getAbsoluteBottom() + 5;
if (bottomRight.isVisible()) {
width += bottomRight.top
.getClientWidth();
}
} else {
top = bottomRight.top.getAbsoluteTop();
left = bottomRight.top
.getAbsoluteLeft();
width = bottomRight.top
.getClientWidth();
bottom = bottomRight.bottom
.getAbsoluteBottom() + 5;
}
if (width > sheetWidget.getElement()
.getClientWidth()) {
width = sheetWidget.getElement()
.getClientWidth();
}

if (sheetWidget.hasFrozenRows()) {
parentTop = sheetWidget
.getTopRightPane()
.getAbsoluteTop();
} else {
parentTop = sheetWidget
.getBottomRightPane()
.getAbsoluteTop();
}

top -= offsetHeight + 5;
left += (width / 2) - (offsetWidth / 2);

if (parentTop > top) {
// put under instead
top = bottom + 5;
}
touchActions.setPopupPosition(left, top);

// TODO check for room
}
});
touchActions.show();
}
});
}
}

@Override
public void setWidth(String width) {

Expand Down Expand Up @@ -1224,7 +1099,6 @@ private void stopSelectingCells(Event event) {
sheetWidget.getSelectedCellRow(), tempRow);

dragging = false;
showTouchActions();
}

protected void setFillMode(boolean fillMode) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,8 @@ public void onBrowserEvent(Event event) {
}
break;
case Event.ONMOUSEUP:
if (event.getButton() == NativeEvent.BUTTON_RIGHT) {
// Context menu is displayed on mouse up to prevent
// contextmenu event on VContextMenu
widget.onSheetMouseDown(event);
}
// now that context menus are handled with the contextMenuEvent
// this should do nothing.
break;
case Event.ONDBLCLICK:
onSheetDoubleClick(event);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,11 @@ void onScrollViewChanged(int firstRow, int lastRow, int firstColumn,
*/
void onCellRightClick(NativeEvent nativeEvent, int column, int row);

/**
* if there is a connector iOS context click timer running, cancel it
*/
void cancelContextClickTimer();

/**
* Called on right mouse button click on top of a row header
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1036,13 +1036,18 @@ protected void onSheetMouseMove(Event event) {
}

protected boolean isEventInCustomEditorCell(Event event) {
final Element target = event.getEventTarget().cast();
return isEventInCustomEditorCell(target);
}
protected boolean isEventInCustomEditorCell(Element target) {
if (customEditorWidget != null) {
final Element target = event.getEventTarget().cast();
final Element customWidgetElement = customEditorWidget.getElement();
return (customWidgetElement.isOrHasChild(target) || customWidgetElement
.getParentElement() != null
&& customWidgetElement.getParentElement().isOrHasChild(
target));
final Element customEditorParent = customWidgetElement.getParentElement();
boolean isEventInCustomEditorCell = customWidgetElement.isOrHasChild(target)
|| (customEditorParent != null
&& customEditorParent.isOrHasChild(
target) );
return isEventInCustomEditorCell;
}
return false;
}
Expand Down Expand Up @@ -1186,7 +1191,7 @@ protected void onSheetMouseDown(Event event) {
event.preventDefault();
if (event.getButton() == NativeEvent.BUTTON_RIGHT) {
Event.releaseCapture(sheet);
actionHandler.onCellRightClick(event, targetCol, targetRow);
// handled by ContextMenuEvent or iOS touch event with timer (SheetInputEventListener)
} else {
sheet.focus();
// quit input if active
Expand Down Expand Up @@ -1761,30 +1766,6 @@ private int isHeader(Element target) {
}
}
});
addDomHandler(new ContextMenuHandler() {

@Override
public void onContextMenu(ContextMenuEvent event) {
if (actionHandler.hasCustomContextMenu()) {
Element target = event.getNativeEvent().getEventTarget()
.cast();
String className = target.getAttribute("class");
int i = jsniUtil.isHeader(className);
if (i == 1 || i == 2) {
int index = jsniUtil.parseHeaderIndex(className);
if (i == 1) {
actionHandler.onRowHeaderRightClick(
event.getNativeEvent(), index);
} else {
actionHandler.onColumnHeaderRightClick(
event.getNativeEvent(), index);
}
}
event.preventDefault();
event.stopPropagation();
}
}
}, ContextMenuEvent.getType());
}

protected boolean isEditingCell() {
Expand Down Expand Up @@ -2928,6 +2909,7 @@ private void clearListOfCells(ArrayList<Cell> row) {
* handler (if needed).
*/
private void onSheetScroll() {
actionHandler.cancelContextClickTimer();
int scrollTop = sheet.getScrollTop();
int scrollLeft = sheet.getScrollLeft();
int vScrollDiff = scrollTop - previousScrollTop;
Expand Down
Loading