當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。