Ejemplo n.º 1
0
  @IMEventHandler(IMEventType.SHOW_MEMBERS_WINDOW)
  protected void showMembersWindow(IMEvent event) {
    UINamedObject named = (UINamedObject) event.getTarget();
    Window win = event.getData("view");
    Rectangle rect = win.getBounds();
    setLocation(rect.x + rect.width - 30, rect.y + 25);

    setIconImage(named.getIcon());
    setTitle(named.getName());
    this.namedObject = named;

    progressOverlay.setShowLoad(true);
    setVisible(true);

    isLoadFace = true; // 设置允许下载头像

    checkReloadMembers(namedObject); // 显示成员

    win.addComponentListener(
        new ComponentAdapter() {
          @Override
          public void componentMoved(ComponentEvent e) {
            int x = e.getComponent().getX() + e.getComponent().getWidth() - 30;
            int y = e.getComponent().getY() + 25;
            if (isPtInRect(getBounds(), new Point(x, y))) {
              setLocation(x, y);
            }
          }
        });
  }
Ejemplo n.º 2
0
  @IMEventHandler(IMEventType.SHOW_MSG_HISTORY_WINDOW)
  protected void processIMShowWindow(IMEvent event) {
    namedObject = (UINamedObject) event.getTarget();
    setTitle(namedObject.getName() + " - Message History.");

    Window win = event.getData("view");
    Rectangle rect = win.getBounds();
    setLocation(rect.x + rect.width - 50, rect.y);
    setSize(getWidth(), rect.height);
    validate();
    setVisible(true);

    currentPage = 0;
    totalPage = 0;

    // 显示消息
    IMEvent imEvent = new IMEvent(IMEventType.MSG_HISTORY_FIND, namedObject.getEntity());
    imEvent.putData("limit", limit);
    IMEventService events = getContext().getSerivce(IMService.Type.EVENT);
    events.broadcast(imEvent);

    win.addComponentListener(
        new ComponentAdapter() {
          @Override
          public void componentMoved(ComponentEvent e) {
            int x = e.getComponent().getX() + e.getComponent().getWidth() - 50;
            int y = e.getComponent().getY();
            if (isPtInRect(getBounds(), new Point(x, y))) {
              setLocation(x, y);
              setSize(getWidth(), e.getComponent().getHeight());
            }
          }
        });
  }
Ejemplo n.º 3
0
 private void registerAutoMove() {
   if (myOwner != null) {
     myOwnerWindow = SwingUtilities.getWindowAncestor(myOwner);
     if (myOwnerWindow != null) {
       myLastOwnerPoint = myOwnerWindow.getLocationOnScreen();
       myOwnerListener = new MyComponentAdapter();
       myOwnerWindow.addComponentListener(myOwnerListener);
     }
   }
 }
Ejemplo n.º 4
0
 private void learnWindow(Container c) {
   if (c != null && c instanceof Window) {
     win = (Window) c;
     win.addWindowListener(winL);
     win.addComponentListener(cmpL);
     if (EventManager.DEBUG_EVENTS) {
       System.err.println(
           "DynamicAncestorAdapter added WindowListener : " + win.getClass().getName());
     }
     if (!listening && win.isShowing()) startListening();
   }
 }
Ejemplo n.º 5
0
  private void registerMoveResizeHandler() {
    myParent.addComponentListener(
        new ComponentAdapter() {
          @Override
          public void componentResized(ComponentEvent e) {
            super.componentResized(e);
            setPositionRelativeToParent();
          }

          @Override
          public void componentMoved(ComponentEvent e) {
            super.componentMoved(e);
            setPositionRelativeToParent();
          }
        });
  }
Ejemplo n.º 6
0
  public ProgressComponent(Window dialog) {
    setFloatable(false);
    setBorderPainted(false);

    bar.setStringPainted(true);
    bar.setMaximumSize(new Dimension(60, 60));

    addSeparator();
    add(bar);
    setVisible(false);

    this.trackerDialog = dialog;

    dialog.addComponentListener(
        new ComponentListener() {
          @Override
          public void componentResized(ComponentEvent e) {}

          @Override
          public void componentMoved(ComponentEvent e) {}

          @Override
          public void componentShown(ComponentEvent e) {
            setVisible(false);
          }

          @Override
          public void componentHidden(ComponentEvent e) {
            if (lastState == ProgressState.Start || lastState == ProgressState.Work) {
              setVisible(true);
            }
          }
        });
    bar.addMouseListener(
        new PopupMouseAdapter() {
          @Override
          protected void triggerDoubleClick(MouseEvent e) {
            trackerDialog.setVisible(true);
          }

          @Override
          protected void triggerPopup(MouseEvent e) {}
        });
  }
Ejemplo n.º 7
0
 protected void initListeners(Window parent) {
   // add listeners
   addMouseListener(
       new MouseAdapter() {
         @Override
         public void mouseReleased(MouseEvent e) {
           exit();
         }
       });
   parent.addWindowListener(
       new WindowAdapter() {
         @Override
         public void windowClosed(WindowEvent e) {
           exit();
         }
       });
   parent.addComponentListener(
       new ComponentAdapter() {
         @Override
         public void componentMoved(ComponentEvent e) {
           FloatableDialog.this.refreshLocation();
         }
       });
 }
Ejemplo n.º 8
0
  /** Installs the sheet on the owner. This method is invoked just before the JSheet is shown. */
  protected void installSheet() {
    if (!isNativeSheetSupported() && !isInstalled && isExperimentalSheet()) {
      Window owner = getOwner();
      if (owner != null) {
        owner.addWindowListener(windowEventHandler);
      }
      isInstalled = true;
    } else {
      Window owner = getOwner();
      if (owner != null) {

        // Determine the location for the sheet and its owner while
        // the sheet will be visible.
        // In case we have to shift the owner to fully display the
        // dialog, we remember the shift back position.
        Point ownerLoc = owner.getLocation();
        Point sheetLoc;
        if (isShowAsSheet()) {
          if (owner instanceof JFrame) {
            sheetLoc =
                new Point(
                    ownerLoc.x + (owner.getWidth() - getWidth()) / 2,
                    ownerLoc.y
                        + owner.getInsets().top
                        + ((JFrame) owner).getRootPane().getContentPane().getY());
          } else if (owner instanceof JDialog) {
            sheetLoc =
                new Point(
                    ownerLoc.x + (owner.getWidth() - getWidth()) / 2,
                    ownerLoc.y
                        + owner.getInsets().top
                        + ((JDialog) owner).getRootPane().getContentPane().getY());
          } else {
            sheetLoc =
                new Point(
                    ownerLoc.x + (owner.getWidth() - getWidth()) / 2,
                    ownerLoc.y + owner.getInsets().top);
          }

          if (sheetLoc.x < 0) {
            owner.setLocation(ownerLoc.x - sheetLoc.x, ownerLoc.y);
            sheetLoc.x = 0;
            shiftBackLocation = ownerLoc;
            oldLocation = owner.getLocation();
          } else {
            shiftBackLocation = null;
            oldLocation = ownerLoc;
          }
        } else {
          sheetLoc =
              new Point(
                  ownerLoc.x + (owner.getWidth() - getWidth()) / 2,
                  ownerLoc.y + (owner.getHeight() - getHeight()) / 2);
        }
        setLocation(sheetLoc);

        oldFocusOwner = owner.getFocusOwner();

        // Note: We mustn't change the windows focusable state because
        // this also affects the focusable state of the JSheet.
        // owner.setFocusableWindowState(false);
        owner.setEnabled(false);
        // ((JFrame) owner).setResizable(false);
        if (isShowAsSheet()) {
          owner.addComponentListener(ownerMovementHandler);
        } else {
          if (owner instanceof Frame) {
            setTitle(((Frame) owner).getTitle());
          }
        }
      }
      isInstalled = true;
    }
  }
Ejemplo n.º 9
0
  /**
   * Create a frame for this DockPanel. The frame will either be a JFrame or a JDialog depending on
   * the isDialog flag.
   */
  public void createFrame() {

    if (isDialog) {
      frame =
          new JDialog(app.getFrame(), false) {
            private static final long serialVersionUID = 1L;

            // Send window closing event when dialog is set invisible.
            // This allows a dock panel view to close properly.
            @Override
            public void setVisible(boolean isVisible) {
              if (!isVisible && frame != null) {
                windowClosing(new WindowEvent(frame, WindowEvent.WINDOW_CLOSING));
              }
              super.setVisible(isVisible);
            }
          };
    } else {
      frame = new JFrame(getPlainTitle());
      // needs the higher res as used by Windows 7 for the Toolbar
      ((JFrame) frame).setIconImage(app.getInternalImage("geogebra64.png"));
    }

    frame.addWindowListener(this);

    frame.addComponentListener(
        new ComponentAdapter() {
          @Override
          public void componentResized(ComponentEvent event) {
            setFrameBounds(event.getComponent().getBounds());
          }

          @Override
          public void componentMoved(ComponentEvent event) {
            setFrameBounds(event.getComponent().getBounds());
          }
        });

    if (isDialog) {
      (((JDialog) frame).getContentPane()).add(this);
    } else {
      (((JFrame) frame).getContentPane()).add(this);
      menubar = loadMenuBar();
      if (menubar != null) {
        ((JFrame) frame).setJMenuBar(menubar);
      }
    }

    // TODO multimonitor supported?
    Rectangle screenSize =
        GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();

    // Use the previous dimension of this view
    Rectangle windowBounds = getFrameBounds();

    // resize window if necessary
    if (windowBounds.width > screenSize.width) windowBounds.width = screenSize.width - 50;
    if (windowBounds.height > screenSize.height) windowBounds.height = windowBounds.height - 50;

    // center window if necessary
    if (isNewDialog) {
      // frame.pack();
      frame.setSize(windowBounds.getSize());
      frame.setLocationRelativeTo(app.getMainComponent());
      isNewDialog = false;
    } else if (windowBounds.x + windowBounds.width > screenSize.width
        || windowBounds.y + windowBounds.height > screenSize.height) {
      frame.setLocationRelativeTo(null);

    } else {
      frame.setLocation(windowBounds.getLocation());
    }
    setOpenInFrame(true);

    frame.setSize(windowBounds.getSize());
    frame.setVisible(true);

    // make titlebar visible if necessary
    updatePanel();

    frame.repaint();
  }
Ejemplo n.º 10
0
  /** Color chooser popup */
  private void showColorChooserPopup() {
    // Checking that component is eligable for focus request
    if (!requestFocusInWindow() && !isFocusOwner()) {
      // Cancel operation if component is not eligable for focus yet
      // This might occur if some other component input verifier holds the focus or in some other
      // rare cases
      return;
    }

    // Update date from field if it was changed
    updateColorFromField();

    // Create popup if it doesn't exist
    if (popup == null || colorChooserPanel == null) {
      final Window ancestor = SwingUtils.getWindowAncestor(this);

      // Color chooser
      colorChooserPanel = new WebColorChooserPanel(true);
      colorChooserPanel.setColor(color);
      colorChooserPanel.setUndecorated(false);
      colorChooserPanel.setPaintFocus(false);
      colorChooserPanel.setRound(StyleConstants.smallRound);
      colorChooserPanel.setShadeWidth(0);

      // Popup window
      popup = new WebWindow(ancestor);
      popup.setLayout(new BorderLayout());
      popup.setCloseOnFocusLoss(true);
      popup.setWindowOpaque(false);
      popup.add(colorChooserPanel);
      popup.pack();

      // Correct popup positioning
      updatePopupLocation();
      ancestor.addComponentListener(
          new ComponentAdapter() {
            @Override
            public void componentMoved(final ComponentEvent e) {
              if (popup.isShowing()) {
                updatePopupLocation();
              }
            }

            @Override
            public void componentResized(final ComponentEvent e) {
              if (popup.isShowing()) {
                updatePopupLocation();
              }
            }
          });
      ancestor.addPropertyChangeListener(
          WebLookAndFeel.ORIENTATION_PROPERTY,
          new PropertyChangeListener() {
            @Override
            public void propertyChange(final PropertyChangeEvent evt) {
              if (popup.isShowing()) {
                updatePopupLocation();
              }
            }
          });

      colorChooserPanel.addColorChooserListener(
          new ColorChooserListener() {
            @Override
            public void okPressed(final ActionEvent e) {
              setColor(colorChooserPanel.getColor());
              popup.setVisible(false);
            }

            @Override
            public void resetPressed(final ActionEvent e) {}

            @Override
            public void cancelPressed(final ActionEvent e) {
              popup.setVisible(false);
            }
          });
    } else {
      // Updating window location
      updatePopupLocation();

      // Updating color
      colorChooserPanel.setColor(color);
    }

    // Applying orientation to popup
    SwingUtils.copyOrientation(WebColorChooserField.this, popup);

    // Showing popup and changing focus
    popup.setVisible(true);
    colorChooserPanel.requestFocusInWindow();
  }