Search in sources :

Example 6 with ButtonEvent

use of com.extjs.gxt.ui.client.event.ButtonEvent in project activityinfo by bedatadriven.

the class LocationFilterPanel method createFilterToolBar.

private void createFilterToolBar() {
    filterToolBar = new FilterToolBar();
    filterToolBar.add(removeSelectedItem);
    filterToolBar.addApplyFilterHandler(new ApplyFilterHandler() {

        @Override
        public void onApplyFilter(ApplyFilterEvent deleteEvent) {
            applyFilter();
        }
    });
    filterToolBar.addRemoveFilterHandler(new RemoveFilterHandler() {

        @Override
        public void onRemoveFilter(RemoveFilterEvent deleteEvent) {
            clearFilter();
            ValueChangeEvent.fire(LocationFilterPanel.this, value);
        }
    });
    setTopComponent(filterToolBar);
    removeSelectedItem.setEnabled(false);
    removeSelectedItem.addSelectionListener(new SelectionListener<ButtonEvent>() {

        @Override
        public void componentSelected(ButtonEvent ce) {
            for (LocationDTO location : listSelectionModel.getSelection()) {
                store.remove(location);
            }
        }
    });
    listSelectionModel.addSelectionChangedListener(new SelectionChangedListener<LocationDTO>() {

        @Override
        public void selectionChanged(SelectionChangedEvent<LocationDTO> se) {
            removeSelectedItem.setEnabled(se.getSelectedItem() != null);
        }
    });
}
Also used : ButtonEvent(com.extjs.gxt.ui.client.event.ButtonEvent) RemoveFilterEvent(org.activityinfo.ui.client.component.filter.FilterToolBar.RemoveFilterEvent) ApplyFilterHandler(org.activityinfo.ui.client.component.filter.FilterToolBar.ApplyFilterHandler) ApplyFilterEvent(org.activityinfo.ui.client.component.filter.FilterToolBar.ApplyFilterEvent) RemoveFilterHandler(org.activityinfo.ui.client.component.filter.FilterToolBar.RemoveFilterHandler) LocationDTO(org.activityinfo.legacy.shared.model.LocationDTO)

Example 7 with ButtonEvent

use of com.extjs.gxt.ui.client.event.ButtonEvent in project activityinfo by bedatadriven.

the class DbUserEditorActions method showDialog.

private void showDialog(final UserForm form, final boolean newUser) {
    final FormDialogImpl dlg = new FormDialogImpl(form);
    dlg.setHeadingText(newUser ? I18N.CONSTANTS.newUser() : I18N.CONSTANTS.editUser());
    dlg.setWidth(400);
    dlg.setHeight(300);
    dlg.getCancelButton().addSelectionListener(new SelectionListener<ButtonEvent>() {

        @Override
        public void componentSelected(ButtonEvent buttonEvent) {
            panel.setModified(false);
        }
    });
    final String host = Window.Location.getHostName();
    dlg.show(new FormDialogCallback() {

        @Override
        public void onValidated() {
            try {
                UpdateUserPermissions command = new UpdateUserPermissions(db, form.getUser(), host);
                command.setNewUser(newUser);
                dispatcher.execute(command, new AsyncCallback<VoidResult>() {

                    @Override
                    public void onFailure(Throwable caught) {
                        if (caught instanceof UserExistsException) {
                            MessageBox.alert(I18N.CONSTANTS.userExistsTitle(), I18N.CONSTANTS.userExistsMessage(), null);
                        } else {
                            MessageBox.alert(I18N.CONSTANTS.serverError(), I18N.CONSTANTS.errorUnexpectedOccured(), null);
                        }
                    }

                    @Override
                    public void onSuccess(VoidResult result) {
                        loader.load();
                        panel.setModified(false);
                        dlg.hide();
                    }
                });
            } catch (FolderAssignmentException excp) {
                MessageBox.alert(I18N.CONSTANTS.noFolderAssignmentTitle(), excp.getMessage(), null);
            } catch (PermissionAssignmentException excp) {
                MessageBox.alert(I18N.CONSTANTS.permissionAssignmentErrorTitle(), excp.getMessage(), null);
            }
        }
    });
}
Also used : FormDialogImpl(org.activityinfo.ui.client.page.common.dialog.FormDialogImpl) FormDialogCallback(org.activityinfo.ui.client.page.common.dialog.FormDialogCallback) VoidResult(org.activityinfo.legacy.shared.command.result.VoidResult) UpdateUserPermissions(org.activityinfo.legacy.shared.command.UpdateUserPermissions) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) PermissionAssignmentException(org.activityinfo.ui.client.page.config.form.PermissionAssignmentException) UserExistsException(org.activityinfo.legacy.shared.command.result.UserExistsException) FolderAssignmentException(org.activityinfo.ui.client.page.config.form.FolderAssignmentException) ButtonEvent(com.extjs.gxt.ui.client.event.ButtonEvent)

Example 8 with ButtonEvent

use of com.extjs.gxt.ui.client.event.ButtonEvent in project activityinfo by bedatadriven.

the class FormDialogImpl method createCancelButton.

private void createCancelButton() {
    cancelButton = new Button(I18N.CONSTANTS.cancel());
    cancelButton.setIcon(IconImageBundle.ICONS.cancel());
    addButton(cancelButton);
    cancelButton.addListener(Events.Select, new Listener<ButtonEvent>() {

        @Override
        public void handleEvent(ButtonEvent be) {
            hide();
            onCancel();
        }
    });
}
Also used : Button(com.extjs.gxt.ui.client.widget.button.Button) ButtonEvent(com.extjs.gxt.ui.client.event.ButtonEvent)

Example 9 with ButtonEvent

use of com.extjs.gxt.ui.client.event.ButtonEvent in project activityinfo by bedatadriven.

the class FormDialogImpl method createSaveButton.

private void createSaveButton() {
    saveButton = new Button(I18N.CONSTANTS.save());
    saveButton.setIcon(IconImageBundle.ICONS.save());
    saveButton.addListener(Events.Select, new Listener<ButtonEvent>() {

        @Override
        public void handleEvent(ButtonEvent be) {
            // use a deferred handler to make sure we get any change
            // events first
            Scheduler.get().scheduleDeferred(new ScheduledCommand() {

                @Override
                public void execute() {
                    if (!form.isValid()) {
                        MessageBox.alert(getHeadingHtml(), fromSafeConstant(I18N.CONSTANTS.pleaseCompleteForm()), null);
                    } else {
                        onValidated();
                    }
                }
            });
        }
    });
    addButton(saveButton);
}
Also used : ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) Button(com.extjs.gxt.ui.client.widget.button.Button) ButtonEvent(com.extjs.gxt.ui.client.event.ButtonEvent)

Aggregations

ButtonEvent (com.extjs.gxt.ui.client.event.ButtonEvent)9 Button (com.extjs.gxt.ui.client.widget.button.Button)7 SelectionListener (com.extjs.gxt.ui.client.event.SelectionListener)2 Margins (com.extjs.gxt.ui.client.util.Margins)1 ContentPanel (com.extjs.gxt.ui.client.widget.ContentPanel)1 Text (com.extjs.gxt.ui.client.widget.Text)1 RowData (com.extjs.gxt.ui.client.widget.layout.RowData)1 VBoxLayout (com.extjs.gxt.ui.client.widget.layout.VBoxLayout)1 ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)1 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)1 UpdateUserPermissions (org.activityinfo.legacy.shared.command.UpdateUserPermissions)1 UserExistsException (org.activityinfo.legacy.shared.command.result.UserExistsException)1 VoidResult (org.activityinfo.legacy.shared.command.result.VoidResult)1 LocationDTO (org.activityinfo.legacy.shared.model.LocationDTO)1 ApplyFilterEvent (org.activityinfo.ui.client.component.filter.FilterToolBar.ApplyFilterEvent)1 ApplyFilterHandler (org.activityinfo.ui.client.component.filter.FilterToolBar.ApplyFilterHandler)1 RemoveFilterEvent (org.activityinfo.ui.client.component.filter.FilterToolBar.RemoveFilterEvent)1 RemoveFilterHandler (org.activityinfo.ui.client.component.filter.FilterToolBar.RemoveFilterHandler)1 FormDialogCallback (org.activityinfo.ui.client.page.common.dialog.FormDialogCallback)1 FormDialogImpl (org.activityinfo.ui.client.page.common.dialog.FormDialogImpl)1