public void readData(final Widget widget) {
    //    HttpServletRequest request = ContextProvider.getRequest();
    //    String parameter = request.getParameter( "JSON" );
    //    if( parameter != null ) {
    //      System.out.println( "#### BEGIN ####");
    //      System.out.println( parameter );
    //      System.out.println( "#### END ####");
    //    }

    Shell shell = (Shell) widget;
    // [if] Preserve the menu bounds before setting the new shell bounds.
    preserveMenuBounds(shell);
    // Important: Order matters, readMode() before readBounds()

    readBounds(shell);
    if (WidgetLCAUtil.wasEventSent(shell, JSConst.EVENT_SHELL_CLOSED)) {
      shell.close();
    }
    processActiveShell(shell);
    processActivate(shell);
    ControlLCAUtil.processMouseEvents(shell);
    ControlLCAUtil.processKeyEvents(shell);
    ControlLCAUtil.processMenuDetect(shell);
    WidgetLCAUtil.processHelp(shell);
  }
 private static String getMode(final Shell shell) {
   String result = null;
   if (shell.getMinimized()) {
     result = "minimized";
   } else if (shell.getMaximized() || shell.getFullScreen()) {
     result = "maximized";
   }
   return result;
 }
 private static void writeOpen(final Shell shell) throws IOException {
   // TODO [rst] workaround: qx window should be opened only once.
   Boolean defValue = Boolean.FALSE;
   Boolean actValue = Boolean.valueOf(shell.getVisible());
   if (WidgetLCAUtil.hasChanged(shell, Props.VISIBLE, actValue, defValue) && shell.getVisible()) {
     //      JSWriter writer = JSWriter.getWriterFor( shell );
     //      writer.call( "open", null );
     IWidgetSynchronizer synchronizer = WidgetSynchronizerFactory.getSynchronizerForWidget(shell);
     synchronizer.call("open");
   }
 }
 private static void readMode(final Shell shell, final String mode) {
   if (mode != null) {
     if ("maximized".equals(mode)) {
       shell.setMaximized(true);
     } else if ("minimized".equals(mode)) {
       shell.setMinimized(true);
     } else {
       shell.setMinimized(false);
       shell.setMaximized(false);
     }
   }
 }
 private static void setActiveControl(final Shell shell, final Widget widget) {
   if (EventUtil.isAccessible(widget)) {
     Object adapter = shell.getAdapter(IShellAdapter.class);
     IShellAdapter shellAdapter = (IShellAdapter) adapter;
     shellAdapter.setActiveControl((Control) widget);
   }
 }
 private static void preserveMenuBounds(final Shell shell) {
   Object adapter = shell.getAdapter(IShellAdapter.class);
   IShellAdapter shellAdapter = (IShellAdapter) adapter;
   Rectangle menuBounds = shellAdapter.getMenuBounds();
   IWidgetAdapter widgetAdapter = WidgetUtil.getAdapter(shell);
   widgetAdapter.preserve(PROP_SHELL_MENU_BOUNDS, menuBounds);
 }
 private static void writeDefaultButton(final Shell shell) throws IOException {
   Button defaultButton = shell.getDefaultButton();
   if (defaultButton != null && defaultButton.isDisposed()) {
     //      JSWriter writer = JSWriter.getWriterFor( shell );
     //      writer.call( "setDefaultButton", NULL_PARAMETER );
     IWidgetSynchronizer synchronizer = WidgetSynchronizerFactory.getSynchronizerForWidget(shell);
     synchronizer.call("setDefaultButton");
   }
 }
 private static void writeText(final Shell shell) throws IOException {
   String text = shell.getText();
   if (WidgetLCAUtil.hasChanged(shell, PROP_TEXT, text, "")) {
     //      JSWriter writer = JSWriter.getWriterFor( shell );
     text = WidgetLCAUtil.escapeText(text, false);
     //      writer.set( JSConst.QX_FIELD_CAPTION, text );
     IWidgetSynchronizer synchronizer = WidgetSynchronizerFactory.getSynchronizerForWidget(shell);
     synchronizer.setWidgetProperty(JSConst.QX_FIELD_CAPTION, text);
   }
 }
 private static void writeFullScreen(final Shell shell) throws IOException {
   Object defValue = Boolean.FALSE;
   Boolean newValue = Boolean.valueOf(shell.getFullScreen());
   if (WidgetLCAUtil.hasChanged(shell, PROP_FULLSCREEN, newValue, defValue)) {
     //      JSWriter writer = JSWriter.getWriterFor( shell );
     //      writer.set( "fullScreen", newValue );
     IWidgetSynchronizer synchronizer = WidgetSynchronizerFactory.getSynchronizerForWidget(shell);
     synchronizer.setWidgetProperty("fullScreen", newValue);
   }
 }
Beispiel #10
0
 private static void writeImage(final Shell shell) throws IOException {
   if ((shell.getStyle() & SWT.TITLE) != 0) {
     Image image = shell.getImage();
     if (image == null) {
       Image[] defaultImages = shell.getImages();
       if (defaultImages.length > 0) {
         image = defaultImages[0];
       }
     }
     if (WidgetLCAUtil.hasChanged(shell, PROP_IMAGE, image, null)) {
       //        JSWriter writer = JSWriter.getWriterFor( shell );
       //        writer.set( JSConst.QX_FIELD_ICON,
       //                    ResourceFactory.getImagePath( image ) );
       IWidgetSynchronizer synchronizer =
           WidgetSynchronizerFactory.getSynchronizerForWidget(shell);
       synchronizer.setWidgetProperty(JSConst.QX_FIELD_ICON, ResourceFactory.getImagePath(image));
     }
   }
 }
Beispiel #11
0
 private void writeAlpha(final Shell shell) throws IOException {
   int alpha = shell.getAlpha();
   if (WidgetLCAUtil.hasChanged(shell, PROP_ALPHA, new Integer(alpha), new Integer(0xFF))) {
     //      JSWriter writer = JSWriter.getWriterFor( shell );
     float opacity = (alpha & 0xFF) * 1000 / 0xFF / 1000.0f;
     //      writer.set( "opacity", opacity );
     IWidgetSynchronizer synchronizer = WidgetSynchronizerFactory.getSynchronizerForWidget(shell);
     synchronizer.setWidgetProperty("opacity", opacity);
   }
 }
Beispiel #12
0
 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);
   }
 }
Beispiel #13
0
 private static void writeMinimumSize(final Shell shell) throws IOException {
   Point newValue = shell.getMinimumSize();
   if (WidgetLCAUtil.hasChanged(shell, PROP_MINIMUM_SIZE, newValue)) {
     //      JSWriter writer = JSWriter.getWriterFor( shell );
     //      writer.set( "minWidth", new Integer( newValue.x ) );
     //      writer.set( "minHeight", new Integer( newValue.y ) );
     IWidgetSynchronizer synchronizer = WidgetSynchronizerFactory.getSynchronizerForWidget(shell);
     synchronizer.setWidgetProperty("minWidth", newValue.x);
     synchronizer.setWidgetProperty("minHeight", newValue.y);
   }
 }
Beispiel #14
0
 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();
   }
 }
Beispiel #15
0
 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);
 }
Beispiel #16
0
 private static void readBounds(final Shell shell) {
   Rectangle bounds = WidgetLCAUtil.readBounds(shell, shell.getBounds());
   Object adapter = shell.getAdapter(IShellAdapter.class);
   IShellAdapter shellAdapter = (IShellAdapter) adapter;
   shellAdapter.setBounds(bounds);
 }
Beispiel #17
0
 private static Control getActiveControl(final Shell shell) {
   Object adapter = shell.getAdapter(IShellAdapter.class);
   IShellAdapter shellAdapter = (IShellAdapter) adapter;
   Control activeControl = shellAdapter.getActiveControl();
   return activeControl;
 }
Beispiel #18
0
 private static void setActiveShell(final Shell shell) {
   Object adapter = shell.getDisplay().getAdapter(IDisplayAdapter.class);
   IDisplayAdapter displayAdapter = (IDisplayAdapter) adapter;
   displayAdapter.setActiveShell(shell);
 }