当前位置: 首页>>代码示例>>Java>>正文


Java Subscribe类代码示例

本文整理汇总了Java中com.google.common.eventbus.Subscribe的典型用法代码示例。如果您正苦于以下问题:Java Subscribe类的具体用法?Java Subscribe怎么用?Java Subscribe使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Subscribe类属于com.google.common.eventbus包,在下文中一共展示了Subscribe类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onSelectionResized

import com.google.common.eventbus.Subscribe; //导入依赖的package包/类
@Subscribe
public void onSelectionResized(SelectionResizeEvent event) {
    if (timelineModel.getSelectedKeyFrame() == null) {
        return;
    }
    if (event.getType() == START) {
        startValues = new HashMap<>();
        filterByKeyAndForEach(getKeyValues(), NodeModel::isSelected, this::storeStartKeyValues);
    } else if (event.getType() == DRAG) {
        event.getNewPositions().keySet().forEach(node -> moveNode(node, event));
    } else if (event.getType() == FINISHED) {
        Map<KeyValueModel, Object> endValues = getEndValues(event);
        if (startValues != null && anyNodeMoved(endValues)) {
            commandStack.append(new NodeDragCommand(startValues, endValues, timelineModel, sceneModel));
        }
    }
}
 
开发者ID:rmfisher,项目名称:fx-animation-editor,代码行数:18,代码来源:SelectionResizeHandler.java

示例2: onTwitchHostInEvent

import com.google.common.eventbus.Subscribe; //导入依赖的package包/类
@Subscribe
public void onTwitchHostInEvent(TwitchHostInEvent event) {
  User channel = usersService.getUser(event.getChannelName());
  boolean isCooldownExpired = isCooldownExpired(channel);

  if (isCooldownExpired) {
    hostRecordService.recordIncomingHost(channel, event.isAuto());

    if (settings.getReward() > 0) {
      pointsService.give(channel, settings.getReward());
    }

    Template template = templateDao.getByKey(HostWatchComponent.INCOMING_HOST_NOTICE_TEMPLATE);
    assert template != null; // Template cannot be null since it's set during install/update
    if (StringUtils.isNotEmpty(template.getTemplate())) {
      chat.say(Templater.template(template.getTemplate())
          .add("username", channel::getDisplayName)
          .add("points", pointsService.asString(settings.getReward())));
    }
  }
}
 
开发者ID:Juraji,项目名称:Biliomi,代码行数:22,代码来源:HostWatchEventsService.java

示例3: applicationThemeRequestCallback

import com.google.common.eventbus.Subscribe; //导入依赖的package包/类
@Subscribe
public void applicationThemeRequestCallback(ThemeRequestCallback event)
{
	if (event.requestedTheme().isPresent())
	{
		Theme applicationTheme = event.requestedTheme().get();
		try
		{
			stage.getScene().getStylesheets().clear();
			stage.getScene().getStylesheets().add(applicationTheme.getPath());
			return;
		}
		catch (MalformedURLException e)
		{
			console.warning("Unable to load application theme "
					+ applicationTheme.getName());
			return;
		}
	}

	console.warning("Unable to load application theme.");
}
 
开发者ID:dhawal9035,项目名称:WebPLP,代码行数:23,代码来源:PLPWebController.java

示例4: testWatchOpen

import com.google.common.eventbus.Subscribe; //导入依赖的package包/类
@Test
public void testWatchOpen(@Mocked ServiceRegistryConfig serviceRegistryConfig,
    @Mocked ServiceRegistryClient srClient,
    @Mocked Microservice microservice) {
  initWatch(serviceRegistryConfig, srClient, microservice);

  new MockUp<ServiceRegistryClient>(srClient) {
    @Mock
    void watch(String selfMicroserviceId, AsyncResultCallback<MicroserviceInstanceChangedEvent> callback,
        AsyncResultCallback<Void> onOpen, AsyncResultCallback<Void> onClose) {
      onOpen.success(null);
    }
  };

  Holder<Boolean> openHolder = new Holder<>();
  eventBus.register(new Object() {
    @Subscribe
    public void onOpen(RecoveryEvent event) {
      openHolder.value = true;
    }
  });
  Assert.assertNull(openHolder.value);
  microserviceWatchTask.run();
  Assert.assertTrue(openHolder.value);
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:26,代码来源:TestMicroserviceWatchTask.java

示例5: testWatchFailed

import com.google.common.eventbus.Subscribe; //导入依赖的package包/类
@Test
public void testWatchFailed(@Mocked ServiceRegistryConfig serviceRegistryConfig,
    @Mocked ServiceRegistryClient srClient,
    @Mocked Microservice microservice) {
  initWatch(serviceRegistryConfig, srClient, microservice);

  new MockUp<ServiceRegistryClient>(srClient) {
    @Mock
    void watch(String selfMicroserviceId, AsyncResultCallback<MicroserviceInstanceChangedEvent> callback,
        AsyncResultCallback<Void> onOpen, AsyncResultCallback<Void> onClose) {
      callback.fail(new Error("test failed"));
    }
  };

  Holder<Throwable> holder = new Holder<>();
  eventBus.register(new Object() {
    @Subscribe
    public void onException(ExceptionEvent event) {
      holder.value = event.getThrowable();
    }
  });
  Assert.assertNull(holder.value);
  microserviceWatchTask.run();
  Assert.assertEquals("test failed", holder.value.getMessage());
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:26,代码来源:TestMicroserviceWatchTask.java

示例6: onShowGraph

import com.google.common.eventbus.Subscribe; //导入依赖的package包/类
@Subscribe
public void onShowGraph(ShowGraphEvent event) {
    Synset rootSynset = service.synsetRemote().findSynsetBySense(event.getSense(), Arrays.asList(1l, 2l, 3l));
    ui.releaseDataSetCache();

    if (rootSynset != null) {
        Map<Long, DataEntry> entries = service.synsetRemote()
                .prepareCacheForRootNode(rootSynset, Arrays.asList(1l, 2l, 3l),
                        new NodeDirection[]{NodeDirection.LEFT,NodeDirection.TOP, NodeDirection.BOTTOM, NodeDirection.RIGHT});

        if (entries != null) {
            ui.setEntrySets((HashMap<Long, DataEntry>) entries);
        }
        //pobieranie synsetu z wcześniej pobranej mapy, aby otrzymać obiekt, który ma relacje (nie są leniwymi kolekcjami)
        DataEntry dataEntry = entries.get(rootSynset.getId());
        if (dataEntry != null) {
            rootSynset = dataEntry.getSynset();
        }
        ui.refreshView(rootSynset);
    } else {
        ui.clear();
    }
}
 
开发者ID:CLARIN-PL,项目名称:WordnetLoom,代码行数:24,代码来源:GraphController.java

示例7: updateTileViewModel

import com.google.common.eventbus.Subscribe; //导入依赖的package包/类
@Subscribe
public final void updateTileViewModel( final BuildTypeData data ) {
    if ( data != _buildTypeData )
        return;

    Platform.runLater( ( ) -> {
        _displayedName.set( Strings.isNullOrEmpty( data.getAliasName( ) ) ? data.getName( ) : data.getAliasName( ) );
        _running.setValue( data.hasRunningBuild( ) );
        _queued.setValue( data.isQueued( ) );

        updateLastFinishedDate( );
        updateTimeLeft( );
        updatePercentageComplete( );
        updateBackground( );
        updateIcon( );
    } );
}
 
开发者ID:u2032,项目名称:wall-t,代码行数:18,代码来源:TileViewModel.java

示例8: layoutDone

import com.google.common.eventbus.Subscribe; //导入依赖的package包/类
/**
 * Retrieves metadata as soon as the layout is done.
 *
 * @param event a {@link LayoutDoneEvent}
 */
@Subscribe
public void layoutDone(final LayoutDoneEvent event) {
    if (currentRadius >= RADIUS_THRESHOLD) {
        retrievalExecutor.stop();
        return;
    }

    retrievalExecutor.run(() -> {
        retrieveMetadata(gfaFile, event.getSubgraph());
        if (Thread.interrupted()) {
            return;
        }
        pathCalculator.computePaths(event.getSubgraph());
        HygeneEventBus.getInstance().post(new NodeMetadataCacheUpdateEvent(event.getSubgraph()));
    });
}
 
开发者ID:ProgrammingLife2017,项目名称:hygene,代码行数:22,代码来源:NodeMetadataCache.java

示例9: onTextMessage

import com.google.common.eventbus.Subscribe; //导入依赖的package包/类
@Subscribe
public void onTextMessage(MessageReceivedEvent event) {
    CGuild cGuild = charrizard.getCGuildManager().getGuild(event.getGuild());
    if (cGuild == null) {
        charrizard.getCGuildManager().createGuild(event.getGuild());
        cGuild = charrizard.getCGuildManager().getGuild(event.getGuild());
    }
    if (!event.getMessage().getContent().startsWith(prefix)) {
        CTextChannel cTextChannel = cGuild.getTextChannel(event.getTextChannel());
        if (cTextChannel == null) {
            cGuild.createTextChannel(event.getTextChannel());
            cTextChannel = cGuild.getTextChannel(event.getTextChannel());
        }
        cTextChannel.addMessage();
        return;
    }
    String[] args = event.getMessage().getContent().split(" ");
    args[0] = args[0].substring(1);
    Command command = commands.stream().filter(c -> c.getLabel().equals(args[0])).findFirst().orElse(null);
    if (command == null) {
        return;
    }
    cGuild.runCommand(command, new CMessage(event.getMessage()), args);
}
 
开发者ID:kacperduras,项目名称:Charrizard,代码行数:25,代码来源:CommandCaller.java

示例10: testAnonymous

import com.google.common.eventbus.Subscribe; //导入依赖的package包/类
public void testAnonymous() {
  final AtomicReference<String> holder = new AtomicReference<String>();
  final AtomicInteger deliveries = new AtomicInteger();
  EventBus bus = new EventBus();
  bus.register(new Object() {
    @Subscribe
    public void accept(String str) {
      holder.set(str);
      deliveries.incrementAndGet();
    }
  });

  String EVENT = "Hello!";
  bus.post(EVENT);

  assertEquals("Only one event should be delivered.", 1, deliveries.get());
  assertEquals("Correct string should be delivered.", EVENT, holder.get());
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:19,代码来源:OutsideEventBusTest.java

示例11: onStreamLabsDonationEvent

import com.google.common.eventbus.Subscribe; //导入依赖的package包/类
@Subscribe
public void onStreamLabsDonationEvent(StreamLabsDonationEvent event) {
  User user = usersService.getUser(event.getUsername());
  if (user != null) {
    double reward = (event.getAmount() * DonationRegisterConstants.POINTS_MULTIPLIER);
    donationsService.registerDonation(user, event.getFormattedAmount(), event.getMessage());
    pointsService.give(user, reward);

    Template template = templateDao.getByKey(DonationRegisterConstants.INCOMING_DONATION_NOTICE);
    assert template != null; // Template cannot be null since it's set during install/update
    if (StringUtils.isNotEmpty(template.getTemplate())) {
      chat.say(Templater.template(template.getTemplate())
          .add("username", user::getDisplayName)
          .add("points", pointsService.asString(reward))
          .add("formattedamount", event::getFormattedAmount)
          .add("message", event::getMessage));
    }
  }
}
 
开发者ID:Juraji,项目名称:Biliomi,代码行数:20,代码来源:DonationsEventService.java

示例12: registerWatchResult

import com.google.common.eventbus.Subscribe; //导入依赖的package包/类
@SuppressWarnings("restriction")
@Subscribe
public void registerWatchResult(RegWatchResponseEvent e) {
	if (!e.isSuccess())
		throw new IllegalArgumentException("There isn't a register with the name "
				+ e.getRegisterName());
	
	String id = e.getRegisterID();
	String registerName = e.getRegisterName();
	LongProperty register = e.getRegObject();
	System.out.println("suc" + id + " -- " +  registerName + " -- " + register);
	register.addListener(new ChangeListener<Number>() {

		@Override
		public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
			//watchedRegisters.refresh();
			System.out.println("Success" + id + " -- " +  registerName + " -- " + register);
			session.setAttribute("idd", register.getValue());
			//System.out.println("id is:   " + session.getAttribute("idd"));
		}
		
	});

}
 
开发者ID:dhawal9035,项目名称:WebPLP,代码行数:25,代码来源:PLPWebController.java

示例13: onConsoleInputEvent

import com.google.common.eventbus.Subscribe; //导入依赖的package包/类
@Subscribe
public void onConsoleInputEvent(ConsoleInputEvent event) {
  char identifier = event.getIdentifier();

  switch (identifier) {
    case PREFIX_COMMAND:
      runCommand(event);
      break;
    case PREFIX_CMD_COMMAND:
      executeConsoleCommand(event);
      break;
    case PREFIX_WHISPER:
      doWhisper(event);
      break;
    case PREFIX_SAY:
      doSay(event);
      break;
    default:
      break;
  }
}
 
开发者ID:Juraji,项目名称:Biliomi,代码行数:22,代码来源:CliCommandRouter.java

示例14: toggleSettingsPane

import com.google.common.eventbus.Subscribe; //导入依赖的package包/类
@Subscribe
private void toggleSettingsPane(ToggleEvent e){
	Platform.runLater(()-> {
		if (e == ToggleEvent.SHOW_SETTINGS && !showSettings){
			settingsPane.toFront();
			showSettings = true;
		}else if (e == ToggleEvent.HIDE_SETTINGS && showSettings){
			settingsPane.toBack();
			showSettings = false;
		}else if (e == ToggleEvent.TOGGLE_SETTINGS){
			if (showSettings){
				settingsPane.toBack();
			}else{
				settingsPane.toFront();
			}
			showSettings = !showSettings;
		}
	});
}
 
开发者ID:Gurgy,项目名称:Cypher,代码行数:20,代码来源:RootPresenter.java

示例15: toggleRoomSettings

import com.google.common.eventbus.Subscribe; //导入依赖的package包/类
@Subscribe
private void toggleRoomSettings(ToggleEvent e) {
	if (e == ToggleEvent.SHOW_ROOM_SETTINGS && !showRoomSettings) {
		settingsPane.toFront();
		showRoomSettings = true;
	} else if (e == ToggleEvent.HIDE_ROOM_SETTINGS && showRoomSettings) {
		settingsPane.toBack();
		showRoomSettings = false;
	} else if (e == ToggleEvent.TOGGLE_ROOM_SETTINGS) {
		if (showRoomSettings) {
			settingsPane.toBack();
		} else {
			settingsPane.toFront();
		}
		showRoomSettings = !showRoomSettings;
	}
}
 
开发者ID:Gurgy,项目名称:Cypher,代码行数:18,代码来源:RoomPresenter.java


注:本文中的com.google.common.eventbus.Subscribe类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。