com.vaadin.client.widgets.Grid Java Examples

The following examples show how to use com.vaadin.client.widgets.Grid. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CubaSingleSelectionModelConnector.java    From cuba with Apache License 2.0 6 votes vote down vote up
@Override
protected BodyClickHandler createBodyClickHandler(Grid<JsonObject> grid) {
    return event -> {
        JsonObject row = grid.getEventCell().getRow();
        NativeEvent e = event.getNativeEvent();

        if (!e.getCtrlKey() && !e.getMetaKey()) {
            if (!grid.isSelected(row)) {
                grid.select(row);
            }
        } else {
            if (!grid.isSelected(row)) {
                grid.select(row);
            } else if (isDeselectAllowed()) {
                grid.deselect(row);
            }
        }
    };
}
 
Example #2
Source File: VPopupButton.java    From cuba with Apache License 2.0 6 votes vote down vote up
private void checkForRTE(Widget popupComponentWidget2) {
    if (popupComponentWidget2 instanceof VRichTextArea) {
        ComponentConnector rtaConnector = Util
                .findConnectorFor(popupComponentWidget2);
        if (rtaConnector != null) {
            rtaConnector.flush();
        }
    } else if (popupComponentWidget2 instanceof Grid) {
        // Grid implements HasWidgets but iterator() throws
        // UnsupportedOperationException so don't do anything
        // in case of Grid.
    } else if (popupComponentWidget2 instanceof HasWidgets) {
        HasWidgets hw = (HasWidgets) popupComponentWidget2;
        Iterator<Widget> iterator = hw.iterator();
        while (iterator.hasNext()) {
            checkForRTE(iterator.next());
        }
    }
}
 
Example #3
Source File: CubaTreeGridConnector.java    From cuba with Apache License 2.0 6 votes vote down vote up
@Override
protected void updateColumns() {
    super.updateColumns();

    if (getWidget().getColumnIds() != null) {
        getWidget().setColumnIds(null);
    }

    if (getState().columnIds != null) {
        List<Grid.Column<?, JsonObject>> currentColumns = getWidget().getColumns();

        for (Grid.Column<?, JsonObject> column : currentColumns) {
            String id = getColumnId(column);
            if (getState().columnIds.containsKey(id)) {
                getWidget().addColumnId(column, getState().columnIds.get(id));
            }
        }
    }
}
 
Example #4
Source File: TableSelectionModelConnector.java    From GridExtensionPack with Apache License 2.0 6 votes vote down vote up
@OnStateChange("selectionMode")
void setSelectionMode() {
	if (clickHandler != null) {
		clickHandler.removeHandler();
		clickHandler = null;
	}

	BodyClickHandler handler;
	Grid<JsonObject> grid = getGrid();
	switch (getState().selectionMode) {
	case CTRL:
		handler = new CtrlClickSelectionHandler(grid);
		break;
	case SIMPLE:
		handler = new SimpleClickSelectionHandler(grid);
		break;
	case SHIFT:
		handler = new ShiftCtrlClickSelectionHandler(grid, getRpcProxy(ShiftSelectRpc.class));
		break;
	case NONE:
	default:
		return;
	}

	clickHandler = grid.addBodyClickHandler(handler);
}
 
Example #5
Source File: CubaEditorEventHandler.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
protected boolean handleCloseEvent(Grid.EditorDomEvent<T> event) {
    boolean result = super.handleCloseEvent(event);
    if (result) {
        event.getDomEvent().stopPropagation();
    }
    return result;
}
 
Example #6
Source File: CubaMultiSelectionModelConnector.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
protected void extend(ServerConnector target) {
    super.extend(target);

    if (!Tools.isUseSimpleMultiselectForTouchDevice()) {
        if (clickHandler != null) {
            clickHandler.removeHandler();
            clickHandler = null;
        }

        Grid<JsonObject> grid = getGrid();
        BodyClickHandler handler = createBodyClickHandler(grid);
        clickHandler = grid.addBodyClickHandler(handler);
    }
}
 
Example #7
Source File: WrappingGridConnector.java    From GridExtensionPack with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
protected void extend(ServerConnector target) {
	grid = (Grid<?>) ((ComponentConnector) target).getWidget();

	wrappingEnabled = false;
	WrappingClientRPC rpc = new WrappingClientRPC() {
		@Override
		public void setWrapping(boolean enable, int defaultRowHeight) {
			if (wrappingEnabled != enable) {
				wrappingEnabled = enable;
				DEFAULT_HEIGHT = defaultRowHeight;
				if (enable) {
					// Figure out default header height
					applyStyle.execute(0);
				} else {
					disableWrapping();
				}
			}
		}
	};

	registerRpc(WrappingClientRPC.class, rpc);

	resizeHandler = grid.addColumnResizeHandler(new ColumnResizeHandler() {
		@Override
		public void onColumnResize(ColumnResizeEvent event) {
			Scheduler.get().scheduleFinally(new Scheduler.ScheduledCommand() {
				@Override
				public void execute() {
					AnimationScheduler.get().requestAnimationFrame(applyStyle);						
				}
			});
		}
	});
}
 
Example #8
Source File: CubaSingleSelectionModelConnector.java    From cuba with Apache License 2.0 4 votes vote down vote up
public CubaClickSelectHandler(Grid<JsonObject> grid) {
    super(grid);
}
 
Example #9
Source File: CubaMultiSelectionModelConnector.java    From cuba with Apache License 2.0 4 votes vote down vote up
protected MultiSelectionBodyClickHandler createBodyClickHandler(Grid<JsonObject> grid) {
    return new MultiSelectionBodyClickHandler(grid);
}
 
Example #10
Source File: CubaMultiSelectionModelConnector.java    From cuba with Apache License 2.0 4 votes vote down vote up
public MultiSelectionBodyClickHandler(Grid<JsonObject> grid) {
    this.grid = grid;
}
 
Example #11
Source File: SimpleClickSelectionHandler.java    From GridExtensionPack with Apache License 2.0 4 votes vote down vote up
public SimpleClickSelectionHandler(Grid<JsonObject> grid) {
    this.grid = grid;
}
 
Example #12
Source File: ShiftCtrlClickSelectionHandler.java    From GridExtensionPack with Apache License 2.0 4 votes vote down vote up
public ShiftCtrlClickSelectionHandler(Grid<JsonObject> grid, ShiftSelectRpc rpc) {
	super(grid);
	this.rpc = rpc;
}
 
Example #13
Source File: CtrlClickSelectionHandler.java    From GridExtensionPack with Apache License 2.0 4 votes vote down vote up
public CtrlClickSelectionHandler(Grid<JsonObject> grid) {
	this.grid = grid;
}
 
Example #14
Source File: SidebarMenuExtensionConnector.java    From GridExtensionPack with Apache License 2.0 4 votes vote down vote up
protected Grid<JsonObject> getGrid() {
	return ((GridConnector) getParent()).getWidget();
}
 
Example #15
Source File: CubaGridWidget.java    From cuba with Apache License 2.0 2 votes vote down vote up
/**
 * Creates a new instance for scrolling the given grid.
 *
 * @param grid the grid to auto scroll
 */
public CubaAutoScroller(Grid<?> grid) {
    super(grid);
}
 
Example #16
Source File: AbstractGridExtensionConnector.java    From GridExtensionPack with Apache License 2.0 2 votes vote down vote up
/**
 * Gets the Grid widget from parent connector.
 * 
 * @return grid
 */
public Grid<JsonObject> getGrid() {
	return getParent().getWidget();
}