use of com.vaadin.client.ui.VButton in project cuba by cuba-platform.
the class Tools method createContextMenu.
protected static VOverlay createContextMenu() {
return new TableOverlay() {
@Override
protected void onDetach() {
super.onDetach();
}
@Override
protected void onPreviewNativeEvent(Event.NativePreviewEvent event) {
super.onPreviewNativeEvent(event);
NativeEvent nativeEvent = event.getNativeEvent();
Element target = Element.as(nativeEvent.getEventTarget());
if (Event.ONKEYDOWN == event.getTypeInt()) {
if (KeyCodes.KEY_ESCAPE == event.getNativeEvent().getKeyCode()) {
event.cancel();
event.getNativeEvent().stopPropagation();
event.getNativeEvent().preventDefault();
hide();
} else {
VAbstractOrderedLayout verticalLayout = ((VVerticalLayout) getWidget());
Widget widget = WidgetUtil.findWidget(target, null);
if (isLayoutChild(verticalLayout, widget)) {
Widget widgetParent = widget.getParent();
VAbstractOrderedLayout layout = (VAbstractOrderedLayout) widgetParent.getParent();
Widget focusWidget = null;
int widgetIndex = layout.getWidgetIndex(widgetParent);
if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_DOWN) {
focusWidget = Tools.findNextWidget(layout, widgetIndex);
} else if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_UP) {
focusWidget = Tools.findPrevWidget(layout, widgetIndex);
}
if (focusWidget instanceof VButton) {
VButton button = (VButton) focusWidget;
focusSelectedItem(widgetParent.getParent(), button);
button.setFocus(true);
}
}
}
} else if (Event.ONMOUSEOVER == event.getTypeInt()) {
VAbstractOrderedLayout verticalLayout = ((VAbstractOrderedLayout) getWidget());
Widget widget = WidgetUtil.findWidget(target, null);
if (isLayoutChild(verticalLayout, widget)) {
if (widget instanceof VButton) {
VButton button = (VButton) widget;
Widget widgetParent = button.getParent();
if (!button.getStyleName().contains(SELECTED_ITEM_STYLE)) {
focusSelectedItem(widgetParent.getParent(), button);
button.setFocus(true);
}
}
}
}
}
};
}
use of com.vaadin.client.ui.VButton in project cuba by cuba-platform.
the class CubaCopyButtonExtensionConnector method extend.
@Override
protected void extend(ServerConnector target) {
final VButton button = (VButton) ((ComponentConnector) target).getWidget();
button.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
if (getState().copyTargetSelector != null) {
boolean success = copyToClipboard(getState().copyTargetSelector.startsWith(".") ? getState().copyTargetSelector : "." + getState().copyTargetSelector);
getRpcProxy(CubaCopyButtonExtensionServerRpc.class).copied(success);
}
}
});
}
use of com.vaadin.client.ui.VButton in project cuba by cuba-platform.
the class CubaPopupButtonWidget method resetSelectedItem.
protected void resetSelectedItem() {
for (Widget popupChild : getPopup()) {
if (popupChild instanceof VAbstractOrderedLayout) {
VAbstractOrderedLayout content = (VAbstractOrderedLayout) popupChild;
for (Widget slot : content) {
Widget contentChild = ((Slot) slot).getWidget();
VButton button = null;
if (contentChild instanceof CubaFileUploadWidget) {
button = ((CubaFileUploadWidget) contentChild).getSubmitButton();
} else if (contentChild instanceof VButton) {
button = (VButton) contentChild;
} else if (contentChild instanceof VUpload) {
button = ((VUpload) contentChild).submitButton;
}
if (button != null && button.getStyleName().contains(SELECTED_ITEM_STYLE)) {
button.removeStyleName(SELECTED_ITEM_STYLE);
}
}
}
}
}
use of com.vaadin.client.ui.VButton in project cuba by cuba-platform.
the class CubaPopupButtonWidget method onPopupOpened.
@Override
protected void onPopupOpened() {
super.onPopupOpened();
if (customLayout) {
return;
}
// find button, assign .v-selected style
for (Widget popupChild : getPopup()) {
if (popupChild instanceof VAbstractOrderedLayout) {
VAbstractOrderedLayout content = (VAbstractOrderedLayout) popupChild;
for (Widget slot : content) {
Widget contentChild = ((Slot) slot).getWidget();
if (contentChild instanceof VButton) {
VButton button = (VButton) contentChild;
if (button.isEnabled() && !button.getStyleName().contains(SELECTED_ITEM_STYLE)) {
button.addStyleName(SELECTED_ITEM_STYLE);
button.setFocus(true);
break;
}
}
}
}
}
// add focus handler
for (Widget popupChild : getPopup()) {
if (popupChild instanceof VAbstractOrderedLayout) {
VAbstractOrderedLayout content = (VAbstractOrderedLayout) popupChild;
for (Widget slot : content) {
Widget contentChild = ((Slot) slot).getWidget();
VButton button = null;
if (contentChild instanceof CubaFileUploadWidget) {
button = ((CubaFileUploadWidget) contentChild).getSubmitButton();
} else if (contentChild instanceof VUpload) {
button = ((VUpload) contentChild).submitButton;
} else if (contentChild instanceof VButton) {
button = (VButton) contentChild;
}
if (button != null) {
final VButton finalButton = button;
button.addFocusHandler(new FocusHandler() {
@Override
public void onFocus(FocusEvent event) {
childWidgetFocused(finalButton);
}
});
// sink mouse over
DOM.sinkEvents(button.getElement(), Event.ONMOUSEOVER | DOM.getEventsSunk(button.getElement()));
}
}
}
}
}
use of com.vaadin.client.ui.VButton in project cuba by cuba-platform.
the class CubaTwinColSelectWidget method enableAddAllBtn.
protected void enableAddAllBtn() {
HTML br1 = new HTML("<span/>");
br1.setStyleName(CLASSNAME + "-deco");
buttons.add(br1);
buttons.insert(br1, buttons.getWidgetIndex(addItemsLeftToRightButton) + 1);
addAll = new VButton();
addAll.setText(">>");
addAll.addStyleName("addAll");
addAllHandlerRegistration = addAll.addClickHandler(this);
buttons.insert(addAll, buttons.getWidgetIndex(br1) + 1);
HTML br2 = new HTML("<span/>");
br2.setStyleName(CLASSNAME + "-deco");
buttons.add(br2);
removeAll = new VButton();
removeAll.setText("<<");
removeAll.addStyleName("removeAll");
removeAllHandlerRegistration = removeAll.addClickHandler(this);
buttons.add(removeAll);
}
Aggregations