One way is to use a ShellListener
on the Shell
for the workbench window:
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
Shell shell = window.getShell();
shell.addShellListener(listener);
The shell listener is notified when the shell is activated, deactivated, closed, minimized (iconified) and restored (deiconified).