本文整理汇总了Java中com.intellij.util.messages.Topic类的典型用法代码示例。如果您正苦于以下问题:Java Topic类的具体用法?Java Topic怎么用?Java Topic使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Topic类属于com.intellij.util.messages包,在下文中一共展示了Topic类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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);
}
}
示例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);
}
}
}
示例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();
}
示例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);
}
示例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);
}
}
示例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;
}
示例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;
}
示例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);
}
}
示例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));
}
};
}
示例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);
}
}
示例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);
}
示例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();
}
示例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);
}