Example usage for com.google.gwt.event.shared HandlerManager fireEvent

List of usage examples for com.google.gwt.event.shared HandlerManager fireEvent

Introduction

In this page you can find the example usage for com.google.gwt.event.shared HandlerManager fireEvent.

Prototype

public void fireEvent(GwtEvent<?> event) 

Source Link

Document

Fires the given event to the handlers listening to the event's type.

Usage

From source file:com.ait.lienzo.client.core.event.AbstractAccumulatingAttributesChangedBatcher.java

License:Open Source License

protected final void dispatch() {
    if ((null != m_manager) && (false == m_changed.isEmpty())) {
        final NFastStringSet changed = new NFastStringSet(m_changed);

        m_changed = new NFastStringSet();

        final HandlerManager manager = m_manager;

        m_manager = null;//  w w w. j a  va2s . c o m

        manager.fireEvent(new AttributesChangedEvent(changed));
    }
}

From source file:com.ait.lienzo.client.core.event.AttributesChangedManager.java

License:Open Source License

public final void fireChanged(final NFastStringSet changed, final long begtime, final long endtime) {
    if ((null != m_ctr) && (null != m_map) && (null != changed) && (false == m_ctr.isEmpty())
            && (false == changed.isEmpty())) {
        final AttributesChangedEvent event = new AttributesChangedEvent(changed, begtime, endtime);

        for (String name : changed) {
            if (m_ctr.contains(name)) {
                final HandlerManager entry = m_map.get(name);

                if (null != entry) {
                    entry.fireEvent(event);
                }//from  w  ww. j av a 2  s  .c  om
            }
        }
    }
}

From source file:com.ait.lienzo.client.core.event.ImmediateAttributesChangedBatcher.java

License:Open Source License

@Override
public void bufferAttributeWithManager(final String name, final HandlerManager manager) {
    Scheduler.get().scheduleFixedDelay(new RepeatingCommand() {
        @Override/* w  ww.j a  v  a  2 s  .  c  o  m*/
        public boolean execute() {
            manager.fireEvent(new AttributesChangedEvent(name));

            return false;
        }
    }, 0);
}

From source file:com.ephesoft.dcma.gwt.foldermanager.client.view.widget.DisplayDialogBox.java

License:Open Source License

public DisplayDialogBox(Map<Integer, String> fileIndexVsNameMap, final HandlerManager eventBus) {
    super();//  w  ww.j  a va  2 s  .  c  om
    setWidget(BINDER.createAndBindUi(this));
    this.eventBus = eventBus;
    final VerticalPanel labelPanel = new VerticalPanel();
    if (fileIndexVsNameMap != null && !fileIndexVsNameMap.isEmpty()) {
        for (final Entry<Integer, String> labelString : fileIndexVsNameMap.entrySet()) {
            totalCounter++;
            final HorizontalPanel horizontalPanel = new HorizontalPanel();
            HTML html = new HTML(FolderManagementConstants.REMOVE_ICON_FOLDER_GIF);
            Label label = new Label(labelString.getValue());
            horizontalPanel.add(html);
            horizontalPanel.add(label);
            horizontalPanel.setSpacing(3);
            labelPanel.add(horizontalPanel);
            html.addClickHandler(new ClickHandler() {

                @Override
                public void onClick(ClickEvent arg0) {
                    labelPanel.remove(horizontalPanel);
                    if (--totalCounter == 0) {
                        addNoFilesLabel(labelPanel);
                    }
                    eventBus.fireEvent(new RemoveAttachmentEvent(labelString.getKey()));
                }

            });

        }
    } else {
        addNoFilesLabel(labelPanel);
    }
    addStyleName(FolderManagementConstants.CSS_CONFIGURABLE_DIALOG_BOX);
    Button closeButton = new Button(LocaleDictionary.get().getConstantValue(FolderManagementConstants.CLOSE),
            new ClickHandler() {

                @Override
                public void onClick(ClickEvent arg0) {
                    hide();
                }
            });
    HorizontalPanel horizontalButtonPanel = new HorizontalPanel();
    horizontalButtonPanel.add(closeButton);
    horizontalButtonPanel.setCellHorizontalAlignment(closeButton, HasHorizontalAlignment.ALIGN_CENTER);
    ScrollPanel scrollPanel = new ScrollPanel();
    scrollPanel.add(labelPanel);
    scrollPanel.setWidth(_200PX);
    scrollPanel.setHeight(_200PX);
    scrollPanel.addStyleName(FolderManagementConstants.BORDER);
    setHeight(_100PX);
    verticalPanel.add(scrollPanel);
    verticalPanel.add(horizontalButtonPanel);
    verticalPanel.setCellHorizontalAlignment(horizontalButtonPanel, HasHorizontalAlignment.ALIGN_CENTER);
    setModal(true);
    setVisible(true);
    show();
    center();
    closeButton.setFocus(true);
}

From source file:com.ephesoft.dcma.gwt.foldermanager.client.view.widget.FolderSelectionWidget.java

License:Open Source License

public FolderSelectionWidget(final Map<String, String> batchClassesNameMap, final HandlerManager eventBus) {
    super();//  w  ww. ja va2  s  .  com
    initWidget(BINDER.createAndBindUi(this));
    mainPanel.addStyleName(FolderManagementConstants.OPTIONS_BOX);
    batchClassSelectionListBox.setWidth(_150PX);
    batchClassSelectionListBox.addStyleName(FolderManagementConstants.CUSTOM_LIST_BOX);
    if (null != batchClassesNameMap && !batchClassesNameMap.isEmpty()) {
        Set<Entry<String, String>> entrySet = batchClassesNameMap.entrySet();
        for (Entry<String, String> entry : entrySet) {
            batchClassSelectionListBox.addItem(entry.getKey());
        }
        fireEventForFolderSelection(batchClassesNameMap, eventBus);
        batchClassSelectionListBox.addChangeHandler(new ChangeHandler() {

            @Override
            public void onChange(ChangeEvent event) {
                fireEventForFolderSelection(batchClassesNameMap, eventBus);
            }
        });
    } else {
        eventBus.fireEvent(new BatchClassChangeEvent());
    }
}

From source file:com.ephesoft.dcma.gwt.foldermanager.client.view.widget.FolderSelectionWidget.java

License:Open Source License

private void fireEventForFolderSelection(final Map<String, String> batchClassesNameMap,
        final HandlerManager eventBus) {
    String itemText = batchClassSelectionListBox.getItemText(batchClassSelectionListBox.getSelectedIndex());
    if (eventBus != null) {
        eventBus.fireEvent(new BatchClassChangeEvent(itemText, batchClassesNameMap.get(itemText)));
    }//from w  w w . ja v  a 2 s.  c  o  m
}

From source file:com.ephesoft.dcma.gwt.foldermanager.client.view.widget.FolderUploadWidget.java

License:Open Source License

public FolderUploadWidget(final HandlerManager eventBus) {
    super();/*from   ww  w . j  a  v  a  2  s. c o  m*/
    initWidget(BINDER.createAndBindUi(this));
    this.eventBus = eventBus;
    this.eventBus.addHandler(PathRefreshEvent.type, new PathRefreshEventHandler() {

        @Override
        public void onFolderPathChange(PathRefreshEvent pathRefreshEvent) {
            folderPath = pathRefreshEvent.getFolderPath();
        }
    });

    this.eventBus.addHandler(RemoveAttachmentEvent.type, new RemoveAttachmentEventHandler() {

        @Override
        public void onRemoveAttachment(RemoveAttachmentEvent removeAttachedFolderEvent) {
            int fileIndex = removeAttachedFolderEvent.getFileIndex();
            fileIndexVsToUploadMap.put(fileIndex, false);
        }
    });

    uploadBuilder.requeueOnError(false);
    labelPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    buttonPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    buttonPanel.setSpacing(2);
    HTMLPanel panel = new HTMLPanel(FolderManagementConstants.DIV_ID_SWFUPLOAD_DIV);
    uploadFilePlaceholder.getElement().appendChild(panel.getElement());
    uploadFilePlaceholder.setHeight(FolderManagementConstants._25PX);
    RootPanel.get().add(this);
    viewAttachedFiles
            .setText(LocaleDictionary.get().getConstantValue(FolderManagementConstants.VIEW_ATTACHED_FILES));
    viewAttachedFiles
            .setTitle(LocaleDictionary.get().getMessageValue(FolderManagementMessages.VIEW_ATTACHED_FILES));

    upload.setText(LocaleDictionary.get().getConstantValue(FolderManagementConstants.UPLOAD));
    uploadHere.setText(LocaleDictionary.get().getConstantValue(FolderManagementConstants.UPLOAD_HERE));

    uploadBuilder.setButtonAction(ButtonAction.SELECT_FILES);
    uploadBuilder.setButtonCursor(ButtonCursor.HAND);
    uploadBuilder.setButtonImageURL(FolderManagementConstants.IMAGES_BROWSE_PNG);
    uploadBuilder.setButtonHeight(25);
    uploadBuilder.setButtonWidth(68);

    uploadBuilder.setButtonPlaceholderID(FolderManagementConstants.SWFUPLOAD);
    uploadBuilder.setFileTypes(FolderManagementConstants.FILE_TYPES);
    uploadBuilder.setFileTypesDescription(FolderManagementConstants.ALL_FILES);

    uploadBuilder.setUploadStartHandler(new UploadStartHandler() {

        @Override
        public void onUploadStart(UploadStartEvent event) {
            File file = event.getFile();
            fileIndexVsToUploadMap.put(file.getIndex(), false);
        }
    });

    uploadBuilder.setFileQueuedHandler(new FileQueuedHandler() {

        @Override
        public void onFileQueued(FileQueuedEvent event) {
            File file = event.getFile();
            fileIndexVsToUploadMap.put(file.getIndex(), true);
        }
    });

    uploadBuilder.setUploadCompleteHandler(new UploadCompleteHandler() {

        @Override
        public void onUploadComplete(UploadCompleteEvent event) {
            int fileLength = swfUpload.getStats().getFilesQueued();
            if (fileLength > 0) {
                eventBus.fireEvent(new FolderTreeRefreshEvent());
                swfUpload.startUpload();
            } else {
                ScreenMaskUtility.unmaskScreen();
                eventBus.fireEvent(new FolderTreeRefreshEvent());
            }
        }
    });
    uploadBuilder.requeueOnError(true);
    uploadBuilder.preventSWFCaching(true);
    swfUpload = uploadBuilder.build();
}

From source file:com.google.gwt.sample.dynatablemvp.client.widgets.NameLabel.java

License:Apache License

public NameLabel(final HandlerManager eventBus) {
    initWidget(nameEditor);/*from ww w  .  j  a va2 s . co m*/

    if (eventBus != null) {
        nameEditor.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                eventBus.fireEvent(new EditPersonEvent(person));
            }
        });
    }
}

From source file:com.google.mobile.trippy.web.client.presenter.TripListItemPresenter.java

License:Apache License

/**
 * Bind the presenter and the view./*w w w. ja v  a  2 s  .c o m*/
 * 
 * Listen for user events on display and take action. Also listen for
 * appropriate application events and update display accordingly
 * 
 * Events fired : 
 * 1) ShowTripScheduleEvent - Show the schedule page of this trip
 * 
 * Events listened : 
 * 1) TripUpdatedEvent -Check if the current trip has been
 * updated. If the current trip has been updated then Check if any of the
 * following attributes have been updated a) Trip name b) Start date b) End
 * date If trip name has been updated then update the display name If
 * Start/End date have been updated then update the display schedule.
 */
@Override
public void bind() {
    tripOptionsPresenter.bind(false); // Do not bind another HW search key.

    final HandlerManager eventBus = singletonComponents.getEventBus();

    handlers.add(display.getName().addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            eventBus.fireEvent(new ShowTripScheduleEvent(trip));
        }
    }));

    handlers.add(display.getOptions().addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            tripOptionsPresenter.getMenuPresenter().showMenu();
        }
    }));

    handlers.add(eventBus.addHandler(TripUpdatedEvent.getType(), new TripUpdatedEventHandler() {

        @Override
        public void onTripUpdated(TripUpdatedEvent event) {
            setTrip(event.getTrip());
        }
    }));
}

From source file:com.sencha.gxt.widget.core.client.event.CellBeforeSelectionEvent.java

License:sencha.com license

public static <T> CellBeforeSelectionEvent<T> fire(HandlerManager manager, Context context, T item) {
    if (manager.isEventHandled(BeforeSelectionEvent.getType())) {
        CellBeforeSelectionEvent<T> event = new CellBeforeSelectionEvent<T>(context, item);
        event.setItem(item);//from w ww .  j  a v a2s  . c  om
        if (manager != null) {
            manager.fireEvent(event);
        }
        return event;
    }
    return null;
}