use of com.google.gwt.event.dom.client.ClickHandler in project activityinfo by bedatadriven.
the class EnumCheckboxWidget method createClearButton.
private Button createClearButton() {
final Button clearButton = new Button();
clearButton.setHTML(ButtonWithIcon.TEMPLATES.withIcon(Icons.INSTANCE.remove()));
clearButton.setStyleName("btn btn-default btn-xs pull-right");
clearButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
for (int i = 0; i < boxPanel.getWidgetCount(); i++) {
Widget widget = boxPanel.getWidget(i);
if (widget instanceof CheckBox) {
CheckBox checkBox = (CheckBox) widget;
if (checkBox.getValue() != null && checkBox.getValue()) {
checkBox.setValue(false, true);
}
}
}
}
});
clearButton.setVisible(false);
return clearButton;
}
use of com.google.gwt.event.dom.client.ClickHandler in project activityinfo by bedatadriven.
the class RepeatingSubFormPanel method addForm.
private void addForm(final FormInstance instance, int panelIndex) {
final SimpleFormPanel formPanel = new SimpleFormPanel(formModel.getLocator(), formModel.getStateProvider());
formPanel.asWidget().addStyleName(FormPanelStyles.INSTANCE.subformPanel());
formPanel.addDeleteButton().addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
panel.remove(formPanel);
forms.remove(instance);
if (loader.isPersisted(instance)) {
// schedule deletion only if instance is persisted
formModel.getPersistedInstanceToRemoveByLocator().add(instance);
}
getInstances().remove(instance);
formModel.getChangedInstances().remove(instance);
setDeleteButtonsState();
}
});
formPanel.show(instance);
forms.put(instance, formPanel);
if (panelIndex == -1) {
panel.add(formPanel);
} else {
panel.insert(formPanel, panelIndex);
}
setDeleteButtonsState();
}
use of com.google.gwt.event.dom.client.ClickHandler in project activityinfo by bedatadriven.
the class FieldPanel method setOnRemoveConfirmationCallback.
public void setOnRemoveConfirmationCallback(final ClickHandler onRemoveConfirmationCallback) {
removeButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(final ClickEvent event) {
ConfirmDialog.confirm(new DeleteWidgetContainerAction(getFocusPanel(), formDesigner) {
@Override
public void onComplete() {
super.onComplete();
onRemoveConfirmationCallback.onClick(event);
}
});
}
});
}
use of com.google.gwt.event.dom.client.ClickHandler in project activityinfo by bedatadriven.
the class FieldsHolderWidgetContainer method subform.
public static FieldsHolderWidgetContainer subform(final FormDesigner formDesigner, FormField formField, final FormClass subForm, ResourceId parentId) {
FieldsHolderWidgetContainer container = new FieldsHolderWidgetContainer(formDesigner, subForm, parentId);
container.isSubform = true;
container.subFormField = formField;
container.getPanel().getPanel().setOnRemoveConfirmationCallback(new ClickHandler() {
@Override
public void onClick(final ClickEvent event) {
formDesigner.getModel().removeSubform(subForm);
formDesigner.getDropControllerRegistry().unregister(subForm.getId());
formDesigner.getContainerPresenter().reset();
}
});
container.getPanel().getPanel().getWidgetContainer().setVisible(false);
if (subForm.getSubFormKind().isPeriod()) {
container.getPanel().getPanel().getSubformTabContainer().add(new PeriodTabStrip(subForm.getSubFormKind()));
}
// force ui update
container.syncWithModel();
return container;
}
use of com.google.gwt.event.dom.client.ClickHandler in project lienzo-core by ahome-it.
the class LienzoHandlerManager method addHandlers.
private final void addHandlers() {
m_lienzo.addClickHandler(new ClickHandler() {
@Override
public void onClick(final ClickEvent event) {
if (!m_viewport.getOnEventHandlers().getOnMouseClickEventHandle().onMouseEventBefore(event)) {
// could have been set previously by a mousedown, it will need cleaning up
m_dragging_mouse_pressed = false;
m_dragging_ignore_clicks = false;
m_dragging = false;
return;
}
onNodeMouseClick(new NodeMouseClickEvent(event));
m_mouse_button_left = (event.getNativeButton() == NativeEvent.BUTTON_LEFT);
m_mouse_button_middle = (event.getNativeButton() == NativeEvent.BUTTON_MIDDLE);
m_mouse_button_right = (event.getNativeButton() == NativeEvent.BUTTON_RIGHT);
event.preventDefault();
m_viewport.getOnEventHandlers().getOnMouseClickEventHandle().onMouseEventAfter(event);
}
});
m_lienzo.addDoubleClickHandler(new DoubleClickHandler() {
@Override
public void onDoubleClick(final DoubleClickEvent event) {
if (!m_viewport.getOnEventHandlers().getOnMouseDoubleClickEventHandle().onMouseEventBefore(event)) {
return;
}
onNodeMouseDoubleClick(new NodeMouseDoubleClickEvent(event));
m_mouse_button_left = (event.getNativeButton() == NativeEvent.BUTTON_LEFT);
m_mouse_button_middle = (event.getNativeButton() == NativeEvent.BUTTON_MIDDLE);
m_mouse_button_right = (event.getNativeButton() == NativeEvent.BUTTON_RIGHT);
event.preventDefault();
m_viewport.getOnEventHandlers().getOnMouseDoubleClickEventHandle().onMouseEventBefore(event);
}
});
m_lienzo.addMouseMoveHandler(new MouseMoveHandler() {
@Override
public void onMouseMove(final MouseMoveEvent event) {
if (!m_viewport.getOnEventHandlers().getOnMouseMoveEventHandle().onMouseEventBefore(event)) {
return;
}
if ((m_dragging) && (m_dragging_using_touches)) {
event.preventDefault();
// Ignore weird Mouse Move (0,0) in the middle of a Touch Drag on iOS/Safari
return;
}
final NodeMouseMoveEvent nevent = new NodeMouseMoveEvent(event);
if (m_mediators.handleEvent(nevent)) {
event.preventDefault();
return;
}
m_mouse_button_left = (event.getNativeButton() == NativeEvent.BUTTON_LEFT);
m_mouse_button_middle = (event.getNativeButton() == NativeEvent.BUTTON_MIDDLE);
m_mouse_button_right = (event.getNativeButton() == NativeEvent.BUTTON_RIGHT);
onNodeMouseMove(nevent);
event.preventDefault();
m_viewport.getOnEventHandlers().getOnMouseMoveEventHandle().onMouseEventBefore(event);
}
});
m_lienzo.addMouseUpHandler(new MouseUpHandler() {
@Override
public void onMouseUp(final MouseUpEvent event) {
if (!m_viewport.getOnEventHandlers().getOnMouseUpEventHandle().onMouseEventBefore(event)) {
// could have been set previously by a mousedown, it will need cleaning up
m_dragging_mouse_pressed = false;
m_dragging_ignore_clicks = false;
m_dragging = false;
return;
}
final NodeMouseUpEvent nevent = new NodeMouseUpEvent(event);
if (m_mediators.handleEvent(nevent)) {
return;
}
m_mouse_button_left = (event.getNativeButton() == NativeEvent.BUTTON_LEFT);
m_mouse_button_middle = (event.getNativeButton() == NativeEvent.BUTTON_MIDDLE);
m_mouse_button_right = (event.getNativeButton() == NativeEvent.BUTTON_RIGHT);
onNodeMouseUp(nevent);
m_viewport.getOnEventHandlers().getOnMouseUpEventHandle().onMouseEventBefore(event);
}
});
m_lienzo.addMouseDownHandler(new MouseDownHandler() {
@Override
public void onMouseDown(final MouseDownEvent event) {
if (!m_viewport.getOnEventHandlers().getOnMouseDownEventHandle().onMouseEventBefore(event)) {
return;
}
final NodeMouseDownEvent nevent = new NodeMouseDownEvent(event);
if (m_mediators.handleEvent(nevent)) {
event.preventDefault();
return;
}
m_mouse_button_left = (event.getNativeButton() == NativeEvent.BUTTON_LEFT);
m_mouse_button_middle = (event.getNativeButton() == NativeEvent.BUTTON_MIDDLE);
m_mouse_button_right = (event.getNativeButton() == NativeEvent.BUTTON_RIGHT);
onNodeMouseDown(nevent);
event.preventDefault();
m_viewport.getOnEventHandlers().getOnMouseDownEventHandle().onMouseEventBefore(event);
}
});
m_lienzo.addMouseOutHandler(new MouseOutHandler() {
@Override
public void onMouseOut(final MouseOutEvent event) {
final NodeMouseOutEvent nevent = new NodeMouseOutEvent(event);
if (m_mediators.handleEvent(nevent)) {
return;
}
onNodeMouseOut(nevent);
}
});
m_lienzo.addMouseOverHandler(new MouseOverHandler() {
@Override
public void onMouseOver(final MouseOverEvent event) {
final NodeMouseOverEvent nevent = new NodeMouseOverEvent(event);
if (m_mediators.handleEvent(nevent)) {
return;
}
onNodeMouseOver(nevent);
}
});
m_lienzo.addMouseWheelHandler(new MouseWheelHandler() {
@Override
public void onMouseWheel(final MouseWheelEvent event) {
final NodeMouseWheelEvent nevent = new NodeMouseWheelEvent(event);
if (m_mediators.handleEvent(nevent)) {
event.preventDefault();
event.stopPropagation();
} else {
fireEvent(nevent);
}
}
});
m_lienzo.addTouchCancelHandler(new TouchCancelHandler() {
@Override
public void onTouchCancel(final TouchCancelEvent event) {
final NodeTouchCancelEvent nevent = new NodeTouchCancelEvent(event, getTouches(event));
if (m_mediators.handleEvent(event)) {
event.preventDefault();
return;
}
onNodeMouseOut(nevent);
event.preventDefault();
}
});
m_lienzo.addTouchEndHandler(new TouchEndHandler() {
@Override
public void onTouchEnd(final TouchEndEvent event) {
final NodeTouchEndEvent nevent = new NodeTouchEndEvent(event, m_touches);
if (m_mediators.handleEvent(nevent)) {
event.preventDefault();
return;
}
onNodeMouseUp(nevent);
event.preventDefault();
}
});
m_lienzo.addTouchMoveHandler(new TouchMoveHandler() {
@Override
public void onTouchMove(final TouchMoveEvent event) {
m_touches = getTouches(event);
final NodeTouchMoveEvent nevent = new NodeTouchMoveEvent(event, m_touches);
if (m_mediators.handleEvent(nevent)) {
event.preventDefault();
return;
}
onNodeMouseMove(nevent);
event.preventDefault();
}
});
m_lienzo.addTouchStartHandler(new TouchStartHandler() {
@Override
public void onTouchStart(final TouchStartEvent event) {
m_touches = getTouches(event);
final NodeTouchStartEvent nevent = new NodeTouchStartEvent(event, m_touches);
if (m_mediators.handleEvent(nevent)) {
event.preventDefault();
return;
}
onNodeMouseDown(nevent);
event.preventDefault();
}
});
m_lienzo.addGestureStartHandler(new GestureStartHandler() {
@Override
public void onGestureStart(final GestureStartEvent event) {
final NodeGestureStartEvent nevent = new NodeGestureStartEvent(event.getScale(), event.getRotation());
if (m_mediators.handleEvent(nevent)) {
event.preventDefault();
return;
}
fireEvent(nevent);
event.preventDefault();
}
});
m_lienzo.addGestureEndHandler(new GestureEndHandler() {
@Override
public void onGestureEnd(final GestureEndEvent event) {
final NodeGestureEndEvent nevent = new NodeGestureEndEvent(event.getScale(), event.getRotation());
if (m_mediators.handleEvent(nevent)) {
event.preventDefault();
return;
}
fireEvent(nevent);
event.preventDefault();
}
});
m_lienzo.addGestureChangeHandler(new GestureChangeHandler() {
@Override
public void onGestureChange(final GestureChangeEvent event) {
final NodeGestureChangeEvent nevent = new NodeGestureChangeEvent(event.getScale(), event.getRotation());
if (m_mediators.handleEvent(nevent)) {
event.preventDefault();
return;
}
fireEvent(nevent);
event.preventDefault();
}
});
}
Aggregations