コード例 #1
0
ファイル: Window.java プロジェクト: Elisabitao/gxt-rtl
  /**
   * Returns the window's draggable instance.
   *
   * @return the draggable instance
   */
  public Draggable getDraggable() {
    if (dragger == null && draggable) {
      dragger = new Draggable(this, head);
      dragger.setConstrainClient(getConstrain());
      dragger.setSizeProxyToSource(false);
      dragger.addDragListener(
          new DragListener() {
            @Override
            public void dragEnd(DragEvent de) {
              endDrag(de, false);
            }

            @Override
            public void dragCancel(DragEvent de) {
              endDrag(de, true);
            }

            @Override
            public void dragMove(DragEvent de) {
              moveDrag(de);
            }

            @Override
            public void dragStart(DragEvent de) {
              startDrag(de);
            }
          });
    }
    return dragger;
  }
コード例 #2
0
ファイル: Window.java プロジェクト: Elisabitao/gxt-rtl
 protected void startDrag(DragEvent de) {
   dragging = true;
   WindowManager.get().bringToFront(this);
   hideShadow();
   ghost = ghost();
   if (eventPreview != null && ghost != null) {
     eventPreview.getIgnoreList().add(ghost.dom);
   }
   showWindow(false);
   Draggable d = de.getDraggable();
   d.setProxy(ghost);
 }
コード例 #3
0
ファイル: Window.java プロジェクト: Elisabitao/gxt-rtl
  /**
   * Restores a maximized window back to its original size and position prior to being maximized and
   * also replaces the 'restore' tool button with the 'maximize' tool button.
   */
  public void restore() {
    if (maximized) {
      el().removeStyleName("x-window-maximized");
      if (maximizable) {
        restoreBtn.setVisible(false);
        maxBtn.setVisible(true);
      }
      if (restoreShadow != null && restoreShadow.booleanValue() && layer != null) {
        layer.enableShadow();
        restoreShadow = null;
      }
      if (draggable) {
        dragger.setEnabled(true);
      }
      if (resizable) {
        resizer.setEnabled(true);
      }
      head.addStyleName("x-window-draggable");
      if (restorePos != null) {
        setPosition(restorePos.x, restorePos.y);

        boolean cacheSizesRestore = cacheSizes;
        cacheSizes = false;
        setSize(restoreSize.width, restoreSize.height);
        cacheSizes = cacheSizesRestore;
      }
      if (container == null && restoreWindowScrolling != null) {
        com.google.gwt.dom.client.Document.get()
            .enableScrolling(restoreWindowScrolling.booleanValue());
        restoreWindowScrolling = null;
      }
      maximized = false;
      fireEvent(Events.Restore, new WindowEvent(this));
    }
  }
コード例 #4
0
ファイル: Window.java プロジェクト: Elisabitao/gxt-rtl
 /**
  * True to enable dragging of this Panel (defaults to false).
  *
  * @param draggable the draggable to state
  */
 public void setDraggable(boolean draggable) {
   this.draggable = draggable;
   if (draggable) {
     head.addStyleName("x-window-draggable");
     getDraggable();
   } else if (dragger != null) {
     dragger.release();
     dragger = null;
     head.removeStyleName("x-window-draggable");
   }
 }
コード例 #5
0
ファイル: Window.java プロジェクト: Elisabitao/gxt-rtl
  /**
   * Fits the window within its current container and automatically replaces the 'maximize' tool
   * button with the 'restore' tool button.
   */
  public void maximize() {
    if (!maximized) {
      restoreSize = getSize();
      restorePos = getPosition(true);
      restoreShadow = getShadow();
      if (container == null) {
        String bodyOverflow =
            com.google.gwt.dom.client.Document.get().isCSS1Compat()
                ? com.google.gwt.dom.client.Document.get()
                    .getDocumentElement()
                    .getStyle()
                    .getProperty("overflow")
                : com.google.gwt.dom.client.Document.get()
                    .getBody()
                    .getStyle()
                    .getProperty("overflow");
        if (!"hidden".equals(bodyOverflow)) {
          restoreWindowScrolling = true;
        }
        com.google.gwt.dom.client.Document.get().enableScrolling(false);
      }
      maximized = true;
      addStyleName("x-window-maximized");
      head.removeStyleName("x-window-draggable");
      if (layer != null) {
        layer.disableShadow();
      }

      boolean cacheSizesRestore = cacheSizes;
      cacheSizes = false;
      fitContainer();
      cacheSizes = cacheSizesRestore;

      if (maximizable) {
        maxBtn.setVisible(false);
        restoreBtn.setVisible(true);
      }
      if (draggable) {
        dragger.setEnabled(false);
      }
      if (resizable) {
        resizer.setEnabled(false);
      }

      fireEvent(Events.Maximize, new WindowEvent(this));
    } else {
      fitContainer();
    }
  }
コード例 #6
0
ファイル: Window.java プロジェクト: Elisabitao/gxt-rtl
  /**
   * Hides the window.
   *
   * @param buttonPressed the button that was pressed or null
   */
  public void hide(Button buttonPressed) {
    if (hidden || !fireEvent(Events.BeforeHide, new WindowEvent(this, buttonPressed))) {
      return;
    }

    if (dragger != null) {
      dragger.cancelDrag();
    }

    hidden = true;

    if (!maximized) {
      restoreSize = getSize();
      restorePos = getPosition(true);
    }

    if (modalPreview != null) {
      modalPreview.removeHandler();
      modalPreview = null;
    }

    onHide();
    manager.unregister(this);
    if (removeFromParentOnHide) {
      removeFromParent();
    }

    if (modalPanel != null) {
      ModalPanel.push(modalPanel);
      modalPanel = null;
    }

    eventPreview.remove();
    notifyHide();

    if (restoreWindowScrolling != null) {
      com.google.gwt.dom.client.Document.get()
          .enableScrolling(restoreWindowScrolling.booleanValue());
    }

    fireEvent(Events.Hide, new WindowEvent(this, buttonPressed));
  }
コード例 #7
0
ファイル: Window.java プロジェクト: Elisabitao/gxt-rtl
 /**
  * True to constrain the window to the {@link Viewport}, false to allow it to fall outside of the
  * Viewport (defaults to true).
  *
  * @param constrain true to constrain, otherwise false
  */
 public void setConstrain(boolean constrain) {
   this.constrain = constrain;
   if (dragger != null) {
     dragger.setConstrainClient(constrain);
   }
 }