本文整理汇总了Java中com.intellij.util.messages.Topic类的典型用法代码示例。如果您正苦于以下问题:Java Topic类的具体用法?Java Topic怎么用?Java Topic使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Topic类属于com.intellij.util.messages包,在下文中一共展示了Topic类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: syncPublisher
import com.intellij.util.messages.Topic; //导入依赖的package包/类
@Override
@NotNull
@SuppressWarnings({"unchecked"})
public <L> L syncPublisher(@NotNull final Topic<L> topic) {
checkNotDisposed();
L publisher = (L)mySyncPublishers.get(topic);
if (publisher == null) {
final Class<L> listenerClass = topic.getListenerClass();
InvocationHandler handler = new InvocationHandler() {
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
sendMessage(new Message(topic, method, args));
return NA;
}
};
publisher = (L)Proxy.newProxyInstance(listenerClass.getClassLoader(), new Class[]{listenerClass}, handler);
publisher = (L)ConcurrencyUtil.cacheOrGet(mySyncPublishers, topic, publisher);
}
return publisher;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:MessageBusImpl.java
示例2: asyncPublisher
import com.intellij.util.messages.Topic; //导入依赖的package包/类
@Override
@NotNull
@SuppressWarnings({"unchecked"})
public <L> L asyncPublisher(@NotNull final Topic<L> topic) {
checkNotDisposed();
L publisher = (L)myAsyncPublishers.get(topic);
if (publisher == null) {
final Class<L> listenerClass = topic.getListenerClass();
InvocationHandler handler = new InvocationHandler() {
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
postMessage(new Message(topic, method, args));
return NA;
}
};
publisher = (L)Proxy.newProxyInstance(listenerClass.getClassLoader(), new Class[]{listenerClass}, handler);
publisher = (L)ConcurrencyUtil.cacheOrGet(myAsyncPublishers, topic, publisher);
}
return publisher;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:MessageBusImpl.java
示例3: calcSubscribers
import com.intellij.util.messages.Topic; //导入依赖的package包/类
private void calcSubscribers(Topic topic, List<MessageBusConnectionImpl> result) {
final List<MessageBusConnectionImpl> topicSubscribers = mySubscribers.get(topic);
if (topicSubscribers != null) {
result.addAll(topicSubscribers);
}
Topic.BroadcastDirection direction = topic.getBroadcastDirection();
if (direction == Topic.BroadcastDirection.TO_CHILDREN) {
for (MessageBusImpl childBus : myChildBuses) {
childBus.calcSubscribers(topic, result);
}
}
if (direction == Topic.BroadcastDirection.TO_PARENT && myParentBus != null) {
myParentBus.calcSubscribers(topic, result);
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:MessageBusImpl.java
示例4: postMessage
import com.intellij.util.messages.Topic; //导入依赖的package包/类
private void postMessage(Message message) {
checkNotDisposed();
final Topic topic = message.getTopic();
List<MessageBusConnectionImpl> topicSubscribers = mySubscriberCache.get(topic);
if (topicSubscribers == null) {
topicSubscribers = new SmartList<MessageBusConnectionImpl>();
calcSubscribers(topic, topicSubscribers);
mySubscriberCache.put(topic, topicSubscribers);
}
if (!topicSubscribers.isEmpty()) {
for (MessageBusConnectionImpl subscriber : topicSubscribers) {
subscriber.getBus().myMessageQueue.get().offer(new DeliveryJob(subscriber, message));
subscriber.getBus().notifyPendingJobChange(1);
subscriber.scheduleMessageDelivery(message);
}
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:MessageBusImpl.java
示例5: Tool
import com.intellij.util.messages.Topic; //导入依赖的package包/类
Tool(Project project, String command, ToolKey key, TextFieldWithBrowseButton pathField,
RawCommandLineEditor flagsField, JButton autoFindButton, JTextField versionField, String versionParam,
@Nullable Topic<SettingsChangeNotifier> topic) {
this.project = project;
this.command = command;
this.key = key;
this.pathField = pathField;
this.flagsField = flagsField;
this.versionField = versionField;
this.versionParam = versionParam;
this.autoFindButton = autoFindButton;
this.topic = topic;
this.publisher = topic == null ? null : project.getMessageBus().syncPublisher(topic);
this.propertyFields = Arrays.asList(
new PropertyField(key.pathKey, pathField),
new PropertyField(key.flagsKey, flagsField));
GuiUtil.addFolderListener(pathField, command);
GuiUtil.addApplyPathAction(autoFindButton, pathField, command);
updateVersion();
}
开发者ID:carymrobbins,项目名称:intellij-haskforce,代码行数:23,代码来源:HaskellToolsConfigurable.java
示例6: beforeEach
import com.intellij.util.messages.Topic; //导入依赖的package包/类
@Override
public void beforeEach(ExtensionContext context) {
IdeaMocksImpl ideaMocks = new IdeaMocksImpl();
Project project = mock(Project.class);
MessageBus messageBus = mock(MessageBus.class);
when(project.getMessageBus()).thenReturn(messageBus);
when(messageBus.syncPublisher(any(Topic.class))).thenAnswer(invocation -> {
Topic topic = invocation.getArgument(0);
Class<?> listenerClass = topic.getListenerClass();
if (ideaMocks.hasMockListener(listenerClass)) {
return ideaMocks.getMockListener(listenerClass);
} else {
return ideaMocks.mockListener(listenerClass);
}
});
Store store = context.getStore(NS);
store.put(Project.class, project);
store.put(MessageBus.class, messageBus);
store.put(IdeaMocks.class, ideaMocks);
}
开发者ID:zielu,项目名称:GitToolBox,代码行数:22,代码来源:IdeaMocksExtension.java
示例7: postMessage
import com.intellij.util.messages.Topic; //导入依赖的package包/类
private void postMessage(Message message) {
checkNotDisposed();
final Topic topic = message.getTopic();
final List<MessageBusConnectionImpl> topicSubscribers = mySubscribers.get(topic);
if (topicSubscribers != null) {
Queue<DeliveryJob> queue = myMessageQueue.get();
for (MessageBusConnectionImpl subscriber : topicSubscribers) {
queue.offer(new DeliveryJob(subscriber, message));
subscriber.scheduleMessageDelivery(message);
}
}
Topic.BroadcastDirection direction = topic.getBroadcastDirection();
if (direction == Topic.BroadcastDirection.TO_CHILDREN) {
for (MessageBusImpl childBus : myChildBuses) {
childBus.postMessage(message);
}
}
if (direction == Topic.BroadcastDirection.TO_PARENT && myParentBus != null) {
myParentBus.postMessage(message);
}
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:25,代码来源:MessageBusImpl.java
示例8: syncPublisher
import com.intellij.util.messages.Topic; //导入依赖的package包/类
@Override
@Nonnull
@SuppressWarnings("unchecked")
public <L> L syncPublisher(@Nonnull final Topic<L> topic) {
checkNotDisposed();
L publisher = (L)mySyncPublishers.get(topic);
if (publisher == null) {
final Class<L> listenerClass = topic.getListenerClass();
InvocationHandler handler = new InvocationHandler() {
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
sendMessage(new Message(topic, method, args));
return NA;
}
};
publisher = (L)Proxy.newProxyInstance(listenerClass.getClassLoader(), new Class[]{listenerClass}, handler);
publisher = (L)ConcurrencyUtil.cacheOrGet(mySyncPublishers, topic, publisher);
}
return publisher;
}
开发者ID:consulo,项目名称:consulo,代码行数:21,代码来源:MessageBusImpl.java
示例9: asyncPublisher
import com.intellij.util.messages.Topic; //导入依赖的package包/类
@Override
@Nonnull
@SuppressWarnings("unchecked")
public <L> L asyncPublisher(@Nonnull final Topic<L> topic) {
checkNotDisposed();
L publisher = (L)myAsyncPublishers.get(topic);
if (publisher == null) {
final Class<L> listenerClass = topic.getListenerClass();
InvocationHandler handler = new InvocationHandler() {
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
postMessage(new Message(topic, method, args));
return NA;
}
};
publisher = (L)Proxy.newProxyInstance(listenerClass.getClassLoader(), new Class[]{listenerClass}, handler);
publisher = (L)ConcurrencyUtil.cacheOrGet(myAsyncPublishers, topic, publisher);
}
return publisher;
}
开发者ID:consulo,项目名称:consulo,代码行数:21,代码来源:MessageBusImpl.java
示例10: runOnSyncPublisher
import com.intellij.util.messages.Topic; //导入依赖的package包/类
public static <T> void runOnSyncPublisher(final Project project, final Topic<T> topic, final Consumer<T> listener) {
final Application application = ApplicationManager.getApplication();
final Runnable runnable = createPublisherRunnable(project, topic, listener);
if (application.isDispatchThread()) {
runnable.run();
} else {
application.runReadAction(runnable);
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:MessageBusUtil.java
示例11: createPublisherRunnable
import com.intellij.util.messages.Topic; //导入依赖的package包/类
private static <T> Runnable createPublisherRunnable(final Project project, final Topic<T> topic, final Consumer<T> listener) {
return new Runnable() {
@Override
public void run() {
if (project.isDisposed()) throw new ProcessCanceledException();
listener.consume(project.getMessageBus().syncPublisher(topic));
}
};
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:MessageBusUtil.java
示例12: invokeLaterIfNeededOnSyncPublisher
import com.intellij.util.messages.Topic; //导入依赖的package包/类
public static <T> void invokeLaterIfNeededOnSyncPublisher(final Project project, final Topic<T> topic, final Consumer<T> listener) {
final Application application = ApplicationManager.getApplication();
final Runnable runnable = createPublisherRunnable(project, topic, listener);
if (application.isDispatchThread()) {
runnable.run();
} else {
application.invokeLater(runnable);
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:MessageBusUtil.java
示例13: subscribe
import com.intellij.util.messages.Topic; //导入依赖的package包/类
@Override
public <L> void subscribe(@NotNull Topic<L> topic, @NotNull L handler) throws IllegalStateException {
synchronized (myPendingMessages) {
if (mySubscriptions.get(topic) != null) {
throw new IllegalStateException("Subscription to " + topic + " already exists");
}
mySubscriptions = mySubscriptions.plus(topic, handler);
}
myBus.notifyOnSubscription(this, topic);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:MessageBusConnectionImpl.java
示例14: notifyOnSubscription
import com.intellij.util.messages.Topic; //导入依赖的package包/类
void notifyOnSubscription(final MessageBusConnectionImpl connection, final Topic topic) {
checkNotDisposed();
List<MessageBusConnectionImpl> topicSubscribers = mySubscribers.get(topic);
if (topicSubscribers == null) {
topicSubscribers = ContainerUtil.createLockFreeCopyOnWriteList();
topicSubscribers = ConcurrencyUtil.cacheOrGet(mySubscribers, topic, topicSubscribers);
}
topicSubscribers.add(connection);
getRootBus().clearSubscriberCache();
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:MessageBusImpl.java
示例15: notifyOnSubscription
import com.intellij.util.messages.Topic; //导入依赖的package包/类
void notifyOnSubscription(final MessageBusConnectionImpl connection, final Topic topic) {
checkNotDisposed();
List<MessageBusConnectionImpl> topicSubscribers = mySubscribers.get(topic);
if (topicSubscribers == null) {
topicSubscribers = ContainerUtil.createLockFreeCopyOnWriteList();
topicSubscribers = ConcurrencyUtil.cacheOrGet(mySubscribers, topic, topicSubscribers);
}
topicSubscribers.add(connection);
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:11,代码来源:MessageBusImpl.java
示例16: syncPublisher
import com.intellij.util.messages.Topic; //导入依赖的package包/类
/**
* Wraps {@link MessageBus#syncPublisher(Topic)} in a dispose check,
* and throws a {@link ProcessCanceledException} if the project is disposed,
* instead of throwing an assertion which would happen otherwise.
*
* @see #syncPublisher(Topic)
*/
@Nonnull
public static <L> L syncPublisher(@Nonnull Project project, @Nonnull Topic<L> topic) throws ProcessCanceledException {
return ReadAction.compute(() -> {
if (project.isDisposed()) throw new ProcessCanceledException();
return project.getMessageBus().syncPublisher(topic);
});
}
开发者ID:consulo,项目名称:consulo,代码行数:15,代码来源:BackgroundTaskUtil.java
示例17: subscribe
import com.intellij.util.messages.Topic; //导入依赖的package包/类
@Override
public <L> void subscribe(@Nonnull Topic<L> topic, @Nonnull L handler) throws IllegalStateException {
synchronized (myPendingMessages) {
if (mySubscriptions.get(topic) != null) {
throw new IllegalStateException("Subscription to " + topic + " already exists");
}
mySubscriptions = mySubscriptions.plus(topic, handler);
}
myBus.notifyOnSubscription(this, topic);
}
开发者ID:consulo,项目名称:consulo,代码行数:11,代码来源:MessageBusConnectionImpl.java
示例18: containsMessage
import com.intellij.util.messages.Topic; //导入依赖的package包/类
boolean containsMessage(@Nonnull Topic topic) {
for (Message message : myPendingMessages.get()) {
if (message.getTopic() == topic) {
return true;
}
}
return false;
}
开发者ID:consulo,项目名称:consulo,代码行数:9,代码来源:MessageBusConnectionImpl.java
示例19: hasUndeliveredEvents
import com.intellij.util.messages.Topic; //导入依赖的package包/类
@Override
public boolean hasUndeliveredEvents(@Nonnull Topic<?> topic) {
if (!isDispatchingAnything()) return false;
for (MessageBusConnectionImpl connection : getTopicSubscribers(topic)) {
if (connection.containsMessage(topic)) {
return true;
}
}
return false;
}
开发者ID:consulo,项目名称:consulo,代码行数:12,代码来源:MessageBusImpl.java
示例20: getTopicSubscribers
import com.intellij.util.messages.Topic; //导入依赖的package包/类
@Nonnull
private List<MessageBusConnectionImpl> getTopicSubscribers(Topic topic) {
List<MessageBusConnectionImpl> topicSubscribers = mySubscriberCache.get(topic);
if (topicSubscribers == null) {
topicSubscribers = new SmartList<MessageBusConnectionImpl>();
calcSubscribers(topic, topicSubscribers);
mySubscriberCache.put(topic, topicSubscribers);
}
return topicSubscribers;
}
开发者ID:consulo,项目名称:consulo,代码行数:11,代码来源:MessageBusImpl.java
注:本文中的com.intellij.util.messages.Topic类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论