use of org.eclipse.mylyn.context.core.IInteractionContext in project ecf by eclipse.
the class Activator method handleChannelEvent.
public synchronized void handleChannelEvent(IChannelEvent e) {
if (e instanceof IChannelMessageEvent) {
IChannelMessageEvent msgEvent = (IChannelMessageEvent) e;
byte[] data = msgEvent.getData();
File file = new File(getStateLocation().toFile(), "incoming.xml.zip");
try {
FileOutputStream fos = new FileOutputStream(file);
fos.write(data);
List tasks = TasksUiPlugin.getTaskListManager().getTaskListWriter().readTasks(file);
final ITask task = (ITask) tasks.get(0);
Set repositories = TasksUiPlugin.getTaskListManager().getTaskListWriter().readRepositories(file);
TasksUiPlugin.getRepositoryManager().insertRepositories(repositories, TasksUiPlugin.getDefault().getRepositoriesFilePath());
IInteractionContext context = ContextCore.getContextStore().importContext(task.getHandleIdentifier(), file);
CompoundContextActivationContributionItem.enqueue(task, context);
IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows();
Shell aShell = null;
for (int i = 0; i < windows.length; i++) {
aShell = windows[i].getShell();
if (aShell != null) {
break;
}
}
if (aShell == null) {
return;
}
final Shell shell = aShell;
UIJob job = new UIJob("Notify of incoming shared task") {
public IStatus runInUIThread(IProgressMonitor monitor) {
final IncomingSharedTaskNotificationPopup popup = new IncomingSharedTaskNotificationPopup(shell);
popup.setTask(task);
popup.open();
new // $NON-NLS-1$
UIJob(// $NON-NLS-1$
shell.getDisplay(), // $NON-NLS-1$
"Close Popup Job") {
public IStatus runInUIThread(IProgressMonitor monitor) {
Shell shell = popup.getShell();
if (shell != null && !shell.isDisposed()) {
popup.close();
}
monitor.done();
return Status.OK_STATUS;
}
}.schedule(5000);
return Status.OK_STATUS;
}
};
job.schedule();
} catch (Exception ex) {
ex.printStackTrace();
} finally {
file.delete();
}
}
}
Aggregations