net.engio.mbassy.listener.Handler Java Examples

The following examples show how to use net.engio.mbassy.listener.Handler. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Synchronization.java    From PeerWasp with MIT License 6 votes vote down vote up
/**
 * This handler is automatically invoked when a {@link org.peerbox.app.manager.file.messages.FileExecutionFailedMessage
 * FileExecutionFailedMessage} is published using the {@link org.peerbox.
 * events.MessageBus MessageBus}. This method changes the corresponding
 * {@link javafx.scene.control. CheckBoxTreeItem CheckBoxTreeItem} in the
 * {@link javafx.scene.control.TreeView TreeView} accordingly.
 */
@Override
@Handler
public void onExecutionFails(FileExecutionFailedMessage message) {
	logger.trace("onExecutionFails: {}", message.getFile().getPath());

	SyncTreeItem item = getOrCreateItem(message.getFile(), false);
	item.setProgressState(ProgressState.FAILED);
	final SyncTreeItem item2 = item;
	javafx.application.Platform.runLater(new Runnable() {
        @Override
        public void run() {
        	item2.setSelected(true);
        }
	});
}
 
Example #2
Source File: Synchronization.java    From PeerWasp with MIT License 6 votes vote down vote up
/**
 * This handler is automatically invoked when a {@link org.peerbox.app.manager.file.messages.LocalFileSoftDeleteMessage LocalFileDesyncMessage} is published
 * using the {@link org.peerbox.events.MessageBus MessageBus}. This method
 * changes the corresponding {@link javafx.scene.control. CheckBoxTreeItem
 * CheckBoxTreeItem} in the {@link javafx.scene.control.TreeView TreeView}
 * accordingly.
 */
@Override
@Handler
public void onFileSoftDeleted(LocalFileSoftDeleteMessage message) {
	logger.trace("onFileSoftDeleted: {}", message.getFile().getPath());
	SyncTreeItem item = getTreeItem(message.getFile().getPath());

	item.setProgressState(ProgressState.DEFAULT);
	final SyncTreeItem item2 = item;
	javafx.application.Platform.runLater(new Runnable() {
        @Override
        public void run() {
        	item2.setSelected(false);
        }
   });
}
 
Example #3
Source File: FileEventManager.java    From PeerWasp with MIT License 6 votes vote down vote up
@Override
@Handler
public void onFileShare(IFileShareEvent fileEvent) {
	String permissionStr = "";
	for (UserPermission p : fileEvent.getUserPermissions()) {
		permissionStr = permissionStr.concat(p.getUserId() + " ");
		if(p.getPermission() == PermissionType.READ){
			permissionStr = permissionStr.concat("Read");
		} else {
			permissionStr = permissionStr.concat("Read / Write");
		}
	}
	logger.info("Share: Invited by: {}, Permission: [{}]", fileEvent.getInvitedBy(), permissionStr, fileEvent.getFile());
	fileEvent.getInvitedBy();
	Set<UserPermission> permissions = fileEvent.getUserPermissions();
	String invitedBy = fileEvent.getInvitedBy();
	FileInfo file = new FileInfo(fileEvent);

	StringBuilder sb = new StringBuilder();
	sb.append("User ").append(invitedBy).append(" shared the folder ").
	append(fileEvent.getFile().toPath()).append(" with you.");
	getMessageBus().post(new InformationNotification("Shared folder", sb.toString())).now();
	publishMessage(new RemoteShareFolderMessage(file, permissions, invitedBy));
}
 
Example #4
Source File: FileEventManager.java    From PeerWasp with MIT License 6 votes vote down vote up
/**
 * This handler is for remote move events and is called by the network when
 * a file has been moved remotely. This method forwards the event to the core and
 * publishes a {@link org.peerbox.app.manager.file.messages.RemoteFileMovedMessage
 * RemoteFileMovedMessage} to inform the GUI.
 */
@Override
@Handler
public void onFileMove(final IFileMoveEvent fileEvent) {
	if(cleanupRunning){
		pendingEvents.add(fileEvent.getSrcFile().toPath());
		pendingEvents.add(fileEvent.getDstFile().toPath());
		return;
	}
	final Path srcPath = fileEvent.getSrcFile().toPath();
	final Path dstPath = fileEvent.getDstFile().toPath();
	logger.debug("onFileMove: {} -> {}", srcPath, dstPath);

	final FileComponent source = fileTree.getOrCreateFileComponent(srcPath, this);
	source.getAction().handleRemoteMoveEvent(dstPath);

	FileInfo srcFile = new FileInfo(srcPath, fileEvent.isFolder());
	FileInfo dstFile = new FileInfo(dstPath, fileEvent.isFolder());
	messageBus.publish(new RemoteFileMovedMessage(srcFile, dstFile));
}
 
Example #5
Source File: FileEventManager.java    From PeerWasp with MIT License 6 votes vote down vote up
/**
 * This handler is for remote delete events and is called by the network when
 * a file has been definitely deleted. Besides forwarding the event to the core,
 * this method publishes a {@link org.peerbox.app.manager.file.messages.RemoteFileDeletedMessage
 * RemoteFileDeletedMessage} to notify the GUI.
 */
@Override
@Handler
public void onFileDelete(final IFileDeleteEvent fileEvent) {
	if(cleanupRunning){
		pendingEvents.add(fileEvent.getFile().toPath());
		return;
	}

	final Path path = fileEvent.getFile().toPath();
	logger.debug("onFileDelete: {}", path);

	final FileComponent file = fileTree.getOrCreateFileComponent(path, fileEvent.isFile(), this);
	file.getAction().handleRemoteDeleteEvent();

	FileInfo fileHelper = new FileInfo(file);
	messageBus.publish(new RemoteFileDeletedMessage(fileHelper));
}
 
Example #6
Source File: BufferServerStatsSubscriber.java    From attic-apex-core with Apache License 2.0 6 votes vote down vote up
@Handler
public void handleStreamDeactivation(StreamDeactivationEvent sde)
{
  ComponentContextPair<Stream, StreamContext> stream = sde.getStream();
  String portId = stream.context.getPortId();
  String sinkId = stream.context.getSinkId();
  if (stream.component instanceof ByteCounterStream) {
    if (sinkId.startsWith("tcp:")) {
      List<ByteCounterStream> portStreams = outputStreams.get(portId);
      if (portStreams != null) {
        portStreams.remove(stream);
        if (portStreams.size() == 0) {
          outputStreams.remove(portId);
        }
      }
    } else {
      inputStreams.remove(portId);
    }
  }
}
 
Example #7
Source File: BufferServerStatsSubscriber.java    From attic-apex-core with Apache License 2.0 6 votes vote down vote up
@Handler
public void handleStreamActivation(StreamActivationEvent sae)
{
  ComponentContextPair<Stream, StreamContext> stream = sae.getStream();
  String portId = stream.context.getPortId();
  String sinkId = stream.context.getSinkId();
  if (stream.component instanceof ByteCounterStream) {
    if (sinkId.startsWith("tcp:")) {
      List<ByteCounterStream> portStreams = outputStreams.get(portId);
      if (portStreams == null) {
        portStreams = new ArrayList<>();
        outputStreams.put(portId, portStreams);
      }
      portStreams.add((ByteCounterStream)stream.component);
    } else {
      inputStreams.put(portId, (ByteCounterStream)stream.component);
    }
  }
}
 
Example #8
Source File: BufferServerStatsSubscriber.java    From Bats with Apache License 2.0 6 votes vote down vote up
@Handler
public void handleStreamActivation(StreamActivationEvent sae)
{
  ComponentContextPair<Stream, StreamContext> stream = sae.getStream();
  String portId = stream.context.getPortId();
  String sinkId = stream.context.getSinkId();
  if (stream.component instanceof ByteCounterStream) {
    if (sinkId.startsWith("tcp:")) {
      List<ByteCounterStream> portStreams = outputStreams.get(portId);
      if (portStreams == null) {
        portStreams = new ArrayList<>();
        outputStreams.put(portId, portStreams);
      }
      portStreams.add((ByteCounterStream)stream.component);
    } else {
      inputStreams.put(portId, (ByteCounterStream)stream.component);
    }
  }
}
 
Example #9
Source File: FSEventRecorder.java    From Bats with Apache License 2.0 6 votes vote down vote up
private void setupWsClient() throws ExecutionException, IOException, InterruptedException, TimeoutException
{
  wsClient.addHandler(pubSubTopic, true, new SharedPubSubWebSocketClient.Handler()
  {
    @Override
    public void onMessage(String type, String topic, Object data)
    {
      numSubscribers = Integer.valueOf((String)data);
      LOG.info("Number of subscribers is now {}", numSubscribers);
    }

    @Override
    public void onClose()
    {
      numSubscribers = 0;
    }

  });

}
 
Example #10
Source File: BufferServerStatsSubscriber.java    From Bats with Apache License 2.0 6 votes vote down vote up
@Handler
public void handleStreamDeactivation(StreamDeactivationEvent sde)
{
  ComponentContextPair<Stream, StreamContext> stream = sde.getStream();
  String portId = stream.context.getPortId();
  String sinkId = stream.context.getSinkId();
  if (stream.component instanceof ByteCounterStream) {
    if (sinkId.startsWith("tcp:")) {
      List<ByteCounterStream> portStreams = outputStreams.get(portId);
      if (portStreams != null) {
        portStreams.remove(stream);
        if (portStreams.size() == 0) {
          outputStreams.remove(portId);
        }
      }
    } else {
      inputStreams.remove(portId);
    }
  }
}
 
Example #11
Source File: FileManagerCollector.java    From PeerWasp with MIT License 5 votes vote down vote up
@Handler
@Override
public void onRemoteFileAdded(RemoteFileAddedMessage upload) {
	ActivityItem item = ActivityItem.create()
			.setTitle("Remote add finished.")
			.setDescription(formatDescription(upload));
	getActivityLogger().addActivityItem(item);
}
 
Example #12
Source File: Synchronization.java    From PeerWasp with MIT License 5 votes vote down vote up
/**
 * This handler is automatically invoked when a {@link org.peerbox.app.manager.file.messages.FileExecutionStartedMessage
 * FileExecutionStartedMessage} is published using the {@link org.peerbox.
 * events.MessageBus MessageBus}. This method changes the corresponding
 * {@link javafx.scene.control.CheckBoxTreeItem CheckBoxTreeItem} in the
 * {@link javafx.scene.control.TreeView TreeView} accordingly.
 */
@Override
@Handler
public void onExecutionStarts(FileExecutionStartedMessage message) {
	logger.trace("onExecutionStarts: {}", message.getFile().getPath());
	SyncTreeItem item = getOrCreateItem(message.getFile(), false);
	item.setProgressState(ProgressState.IN_PROGRESS);
}
 
Example #13
Source File: JSystemTray.java    From PeerWasp with MIT License 5 votes vote down vote up
/***
 * User event handling
 ***/

@Handler
@Override
public void onUserRegister(RegisterMessage register) {
	// nothing to do
}
 
Example #14
Source File: FileManagerCollector.java    From PeerWasp with MIT License 5 votes vote down vote up
@Handler
@Override
public void onRemoteFileMoved(RemoteFileMovedMessage download) {
	ActivityItem item = ActivityItem.create()
			.setTitle("Remote move finished.")
			.setDescription(formatDescription(download));
	getActivityLogger().addActivityItem(item);
}
 
Example #15
Source File: FileManagerCollector.java    From PeerWasp with MIT License 5 votes vote down vote up
@Handler
@Override
public void onRemoteFileUpdated(RemoteFileUpdatedMessage message) {
	ActivityItem item = ActivityItem.create()
			.setTitle("Remote update finished.")
			.setDescription(formatDescription(message));
	getActivityLogger().addActivityItem(item);
}
 
Example #16
Source File: JSystemTray.java    From PeerWasp with MIT License 5 votes vote down vote up
@Override
@Handler
public void showFileEvents(AggregatedFileEventStatus event) {
	String msg = generateAggregatedFileEventStatusMessage(event);
	ActionListener listener = new ShowSettingsActionListener();
	setNewMessageActionListener(listener);
	showMessage("File Synchronization", msg, MessageType.INFO);
}
 
Example #17
Source File: JSystemTray.java    From PeerWasp with MIT License 5 votes vote down vote up
/**
 * NOTIFICATIONS - implementation of the ITrayNotifications interface
 */

@Override
@Handler
public void showInformation(InformationNotification in) {
	ActionListener listener = new ShowActivityActionListener();
	setNewMessageActionListener(listener);
	showMessage(in.getTitle(), in.getMessage(), MessageType.INFO);
}
 
Example #18
Source File: GeneralMessageCollector.java    From PeerWasp with MIT License 5 votes vote down vote up
@Handler
@Override
public void onInformationMessage(InformationMessage message) {
	ActivityItem item = ActivityItem.create()
			.setTitle(message.getTitle())
			.setDescription(message.getDescription());
	getActivityLogger().addActivityItem(item);
}
 
Example #19
Source File: GeneralMessageCollector.java    From PeerWasp with MIT License 5 votes vote down vote up
@Handler
@Override
public void onWarningMessage(WarningMessage message) {
	ActivityItem item = ActivityItem.create()
			.setTitle(message.getTitle())
			.setDescription(message.getDescription())
			.setType(ActivityType.WARNING);
	getActivityLogger().addActivityItem(item);
}
 
Example #20
Source File: JSystemTray.java    From PeerWasp with MIT License 5 votes vote down vote up
@Handler
@Override
public void onUserLogout(LogoutMessage logout) {
	// refresh menu
	trayIcon.setPopupMenu(null);
	trayIcon.setPopupMenu(createMenu(false));
}
 
Example #21
Source File: FileManagerCollector.java    From PeerWasp with MIT License 5 votes vote down vote up
@Handler
@Override
public void onLocalFileConfilct(LocalFileConflictMessage conflict) {
	ActivityItem item = ActivityItem.create()
			.setType(ActivityType.WARNING)
			.setTitle("Conflict detected, local version renamed.")
			.setDescription(formatDescription(conflict));
	getActivityLogger().addActivityItem(item);
}
 
Example #22
Source File: FileManagerCollector.java    From PeerWasp with MIT License 5 votes vote down vote up
@Handler
@Override
public void onLocalFileDesynchronized(LocalFileSoftDeleteMessage desync){
	ActivityItem item = ActivityItem.create()
			.setTitle("Soft-delete finished. File has been locally deleted.")
			.setDescription(formatDescription(desync));
	getActivityLogger().addActivityItem(item);
}
 
Example #23
Source File: FileManagerCollector.java    From PeerWasp with MIT License 5 votes vote down vote up
@Handler
@Override
public void onLocalFileDeleted(LocalFileDeletedMessage delete) {
	ActivityItem item = ActivityItem.create()
			.setTitle("Local delete finished.")
			.setDescription(formatDescription(delete));
	getActivityLogger().addActivityItem(item);
}
 
Example #24
Source File: FileManagerCollector.java    From PeerWasp with MIT License 5 votes vote down vote up
@Handler
@Override
public void onLocalFileMoved(LocalFileMovedMessage download) {
	ActivityItem item = ActivityItem.create()
			.setTitle("Local move finished.")
			.setDescription(formatDescription(download));
	getActivityLogger().addActivityItem(item);
}
 
Example #25
Source File: FileManagerCollector.java    From PeerWasp with MIT License 5 votes vote down vote up
@Handler
@Override
public void onLocalFileAdded(LocalFileAddedMessage upload) {
	ActivityItem item = ActivityItem.create()
			.setTitle("Local add finished.")
			.setDescription(formatDescription(upload));
	getActivityLogger().addActivityItem(item);
}
 
Example #26
Source File: UserManagerCollector.java    From PeerWasp with MIT License 5 votes vote down vote up
@Handler
@Override
public void onUserLogout(LogoutMessage logout) {
	ActivityItem item = ActivityItem.create()
			.setTitle("User logged out.")
			.setDescription(String.format("Username: %s", logout.getUsername()));
		getActivityLogger().addActivityItem(item);
}
 
Example #27
Source File: UserManagerCollector.java    From PeerWasp with MIT License 5 votes vote down vote up
@Handler
@Override
public void onUserLogin(LoginMessage login) {
	ActivityItem item = ActivityItem.create()
		.setTitle("User logged in.")
		.setDescription(String.format("Username: %s", login.getUsername()));
	getActivityLogger().addActivityItem(item);
}
 
Example #28
Source File: UserManagerCollector.java    From PeerWasp with MIT License 5 votes vote down vote up
@Handler
@Override
public void onUserRegister(RegisterMessage register) {
	ActivityItem item = ActivityItem.create()
			.setTitle("User registered.")
			.setDescription(String.format("Username: %s", register.getUsername()));
	getActivityLogger().addActivityItem(item);
}
 
Example #29
Source File: IndexService.java    From disthene with MIT License 5 votes vote down vote up
@Handler(rejectSubtypes = false)
public void handle(MetricStoreEvent metricStoreEvent) {
    if (indexConfiguration.isCache()) {
        handleWithCache(metricStoreEvent.getMetric());
    } else {
        metrics.offer(metricStoreEvent.getMetric());
    }
}
 
Example #30
Source File: Synchronization.java    From PeerWasp with MIT License 5 votes vote down vote up
@Override
@Handler
public void onRemoteFolderShared(RemoteShareFolderMessage message) {
	logger.trace("onRemoteFolderShared: {}", message.getFile().getPath());

	SyncTreeItem item = getOrCreateItem(message.getFile(), false);
	item.getValue().getPermissions().clear();
	item.getValue().getPermissions().addAll(message.getUserPermissions());
	item.setIsShared(true);
}