Search in sources :

Example 86 with Subscribe

use of com.google.common.eventbus.Subscribe in project mica2 by obiba.

the class FileIndexer method reIndexAll.

@Async
@Subscribe
public void reIndexAll(IndexFilesEvent event) {
    if (indexer.hasIndex(Indexer.ATTACHMENT_DRAFT_INDEX))
        indexer.dropIndex(Indexer.ATTACHMENT_DRAFT_INDEX);
    if (indexer.hasIndex(Indexer.ATTACHMENT_PUBLISHED_INDEX))
        indexer.dropIndex(Indexer.ATTACHMENT_PUBLISHED_INDEX);
    Pageable pageRequest = new PageRequest(0, 100);
    Page<AttachmentState> attachments;
    do {
        attachments = attachmentStateRepository.findAll(pageRequest);
        attachments.forEach(a -> {
            if (FileUtils.isDirectory(a))
                return;
            indexer.index(Indexer.ATTACHMENT_DRAFT_INDEX, a);
            if (a.getPublishedAttachment() != null) {
                indexer.index(Indexer.ATTACHMENT_PUBLISHED_INDEX, a);
            }
        });
    } while ((pageRequest = attachments.nextPageable()) != null);
}
Also used : PageRequest(org.springframework.data.domain.PageRequest) AttachmentState(org.obiba.mica.file.AttachmentState) Pageable(org.springframework.data.domain.Pageable) Async(org.springframework.scheduling.annotation.Async) Subscribe(com.google.common.eventbus.Subscribe)

Example 87 with Subscribe

use of com.google.common.eventbus.Subscribe in project mica2 by obiba.

the class ProjectService method dataAccessRequestUpdated.

// 
// Event handling
// 
@Async
@Subscribe
public void dataAccessRequestUpdated(DataAccessRequestUpdatedEvent event) {
    DataAccessRequest request = event.getPersistable();
    if (!projectRepository.exists(request.getId()) && request.getStatus() == DataAccessRequest.Status.APPROVED) {
        Project project = new Project();
        project.setId(event.getPersistable().getId());
        project.setDataAccessRequestId(event.getPersistable().getId());
        String title = dataAccessRequestUtilService.getRequestTitle(request);
        if (!Strings.isNullOrEmpty(title)) {
            project.setTitle(LocalizedString.from(micaConfigService.getConfig().getLocales(), title));
        }
        String summary = dataAccessRequestUtilService.getRequestSummary(request);
        if (!Strings.isNullOrEmpty(summary)) {
            project.setSummary(LocalizedString.from(micaConfigService.getConfig().getLocales(), summary));
        }
        save(project, "Created from Data Access Request");
    }
}
Also used : Project(org.obiba.mica.project.domain.Project) DataAccessRequest(org.obiba.mica.access.domain.DataAccessRequest) LocalizedString(org.obiba.mica.core.domain.LocalizedString) Async(org.springframework.scheduling.annotation.Async) Subscribe(com.google.common.eventbus.Subscribe)

Example 88 with Subscribe

use of com.google.common.eventbus.Subscribe in project Almura by AlmuraDev.

the class SimpleIngameMenu method onButtonClick.

@Subscribe
public void onButtonClick(UIButton.ClickEvent event) throws IOException, URISyntaxException, AWTException {
    switch(event.getComponent().getName().toLowerCase(Locale.ENGLISH)) {
        case "button.back":
            this.close();
            break;
        case "button.shop":
            Desktop.getDesktop().browse(new URI(GuiConfig.Url.SHOP));
            break;
        case "button.guide":
            if (this.mc.player != null) {
                this.close();
            }
            break;
        case "button.instance":
            Desktop.getDesktop().browse(new URI(GuiConfig.Url.MAP));
            break;
        case "button.statistics":
            Desktop.getDesktop().browse(new URI(GuiConfig.Url.STATISTICS));
            break;
        case "button.advancements":
            close();
            if (this.mc.player != null) {
                this.mc.displayGuiScreen(new GuiScreenAdvancements(this.mc.player.connection.getAdvancementManager()));
            }
            break;
        case "button.forums":
            Desktop.getDesktop().browse(new URI(GuiConfig.Url.FORUM));
            break;
        case "button.lan":
            this.mc.displayGuiScreen(new GuiShareToLan(this));
            break;
        case "button.options":
            this.mc.displayGuiScreen(new GuiOptions(this, this.mc.gameSettings));
            break;
        case "button.quit":
            close();
            this.mc.world.sendQuittingDisconnectingPacket();
            this.mc.loadWorld(null);
            this.mc.displayGuiScreen(new GuiMainMenu());
            break;
    }
}
Also used : GuiMainMenu(net.minecraft.client.gui.GuiMainMenu) GuiScreenAdvancements(net.minecraft.client.gui.advancements.GuiScreenAdvancements) GuiShareToLan(net.minecraft.client.gui.GuiShareToLan) GuiOptions(net.minecraft.client.gui.GuiOptions) URI(java.net.URI) Subscribe(com.google.common.eventbus.Subscribe)

Example 89 with Subscribe

use of com.google.common.eventbus.Subscribe in project Almura by AlmuraDev.

the class ServerMenu method onButtonClick.

@Subscribe
public void onButtonClick(UIButton.ClickEvent event) throws IOException, URISyntaxException {
    if (!event.getComponent().getName().toLowerCase().equals("button.server.web") || (!event.getComponent().getName().toLowerCase().equals("button.server.map"))) {
        // This doesn't close this screen when connecting to a server.
        close();
    }
    switch(event.getComponent().getName().toLowerCase()) {
        case "button.server.almura.live":
            FMLClientHandler.instance().setupServerList();
            FMLClientHandler.instance().connectToServer(this, DATA_LIVE_SERVER_CONNECT);
            break;
        case "button.server.almura.dev":
            FMLClientHandler.instance().setupServerList();
            FMLClientHandler.instance().connectToServer(this, DATA_DEV_SERVER_CONNECT);
            break;
        case "button.server.another":
            mc.displayGuiScreen(new GuiMultiplayer(this));
            break;
        case "button.server.map":
            Desktop.getDesktop().browse(new URI("http://srv1.almuramc.com:8123"));
            break;
        case "button.server.web":
            Desktop.getDesktop().browse(new URI("http://www.almuramc.com"));
            break;
    }
}
Also used : URI(java.net.URI) GuiMultiplayer(net.minecraft.client.gui.GuiMultiplayer) Subscribe(com.google.common.eventbus.Subscribe)

Example 90 with Subscribe

use of com.google.common.eventbus.Subscribe in project jesos by groupon.

the class LocalSchedulerMessageProcessor method frameworkError.

@Subscribe
public void frameworkError(final FrameworkErrorMessageEnvelope envelope) {
    checkState(envelope.getRecipient().equals(context.getDriverUPID()), "Received a remote message for local delivery");
    final UPID sender = envelope.getSender();
    if (!driverIsConnected(sender)) {
        return;
    }
    final FrameworkErrorMessage frameworkErrorMessage = envelope.getMessage();
    eventBus.post(new SchedulerCallback() {

        @Override
        public Runnable getCallback(final Scheduler scheduler, final SchedulerDriver schedulerDriver) {
            return new Runnable() {

                @Override
                public void run() {
                    schedulerDriver.abort();
                    scheduler.error(schedulerDriver, frameworkErrorMessage.getMessage());
                }
            };
        }
    });
}
Also used : UPID(com.groupon.mesos.util.UPID) Scheduler(org.apache.mesos.Scheduler) FrameworkErrorMessage(mesos.internal.Messages.FrameworkErrorMessage) SchedulerDriver(org.apache.mesos.SchedulerDriver) Subscribe(com.google.common.eventbus.Subscribe)

Aggregations

Subscribe (com.google.common.eventbus.Subscribe)179 GuildMessageReceivedEvent (net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent)46 SimpleCommand (net.kodehawa.mantarobot.core.modules.commands.SimpleCommand)44 MessageEmbed (net.dv8tion.jda.core.entities.MessageEmbed)29 EmoteReference (net.kodehawa.mantarobot.utils.commands.EmoteReference)26 MantaroData (net.kodehawa.mantarobot.data.MantaroData)25 List (java.util.List)23 Category (net.kodehawa.mantarobot.core.modules.commands.base.Category)22 Utils (net.kodehawa.mantarobot.utils.Utils)22 CommandRegistry (net.kodehawa.mantarobot.core.CommandRegistry)21 Module (net.kodehawa.mantarobot.core.modules.Module)21 EmbedBuilder (net.dv8tion.jda.core.EmbedBuilder)18 TimeUnit (java.util.concurrent.TimeUnit)16 Collectors (java.util.stream.Collectors)16 MantaroBot (net.kodehawa.mantarobot.MantaroBot)15 Player (net.kodehawa.mantarobot.db.entities.Player)15 DiscordUtils (net.kodehawa.mantarobot.utils.DiscordUtils)15 RateLimiter (net.kodehawa.mantarobot.utils.commands.RateLimiter)14 SubCommand (net.kodehawa.mantarobot.core.modules.commands.SubCommand)13 DBGuild (net.kodehawa.mantarobot.db.entities.DBGuild)13