private static void writeActiveShell(final Shell shell) throws IOException {
   Shell activeShell = shell.getDisplay().getActiveShell();
   boolean hasChanged = WidgetLCAUtil.hasChanged(shell, PROP_ACTIVE_SHELL, activeShell, null);
   if (shell == activeShell && hasChanged) {
     //      JSWriter writer = JSWriter.getWriterFor( shell );
     //      writer.set( "active", true );
     IWidgetSynchronizer synchronizer = WidgetSynchronizerFactory.getSynchronizerForWidget(shell);
     synchronizer.setWidgetProperty("active", true);
   }
 }
 private static void processActiveShell(final Shell shell) {
   if (WidgetLCAUtil.wasEventSent(shell, JSConst.EVENT_SHELL_ACTIVATED)) {
     Shell lastActiveShell = shell.getDisplay().getActiveShell();
     setActiveShell(shell);
     ActivateEvent event;
     if (lastActiveShell != null) {
       event = new ActivateEvent(lastActiveShell, ActivateEvent.DEACTIVATED);
       event.processEvent();
     }
     event = new ActivateEvent(shell, ActivateEvent.ACTIVATED);
     event.processEvent();
   }
 }
 public void preserveValues(final Widget widget) {
   ControlLCAUtil.preserveValues((Control) widget);
   Shell shell = (Shell) widget;
   IWidgetAdapter adapter = WidgetUtil.getAdapter(shell);
   adapter.preserve(PROP_ACTIVE_CONTROL, getActiveControl(shell));
   adapter.preserve(PROP_ACTIVE_SHELL, shell.getDisplay().getActiveShell());
   adapter.preserve(PROP_TEXT, shell.getText());
   adapter.preserve(PROP_IMAGE, shell.getImage());
   adapter.preserve(PROP_ALPHA, new Integer(shell.getAlpha()));
   adapter.preserve(PROP_MODE, getMode(shell));
   adapter.preserve(PROP_FULLSCREEN, Boolean.valueOf(shell.getFullScreen()));
   adapter.preserve(PROP_SHELL_LISTENER, Boolean.valueOf(ShellEvent.hasListener(shell)));
   adapter.preserve(PROP_SHELL_MENU, shell.getMenuBar());
   adapter.preserve(PROP_MINIMUM_SIZE, shell.getMinimumSize());
   WidgetLCAUtil.preserveCustomVariant(shell);
 }
 private static void setActiveShell(final Shell shell) {
   Object adapter = shell.getDisplay().getAdapter(IDisplayAdapter.class);
   IDisplayAdapter displayAdapter = (IDisplayAdapter) adapter;
   displayAdapter.setActiveShell(shell);
 }