Ejemplo n.º 1
0
  /**
   * <b>refreshWindow()</b></br> <i>Updates window boundaries, sets the current panel, and turns the
   * Window visible. A general method used to update things pertaining to the Window that the
   * WindowManager cares for.</i></br>
   *
   * @version Slap 0.1
   */
  public void refreshWindow() {

    LOG.setSubSection("Refresh");

    if (CURRENT_PANEL != null) {

      WINDOW.repaint();
      LOG.log("Current panel exists. Setting up information.");

      if (CURRENT_PANEL.getTrackProgress() == true) {

        LOG.log("Progress tracking turned on, setting next panel.");
        setTrackProgress(true);
        setNextPanel(CURRENT_PANEL.getNextPanelName());

      } else {
        LOG.log("Progress tracking turned off.");
        setTrackProgress(false);
      }

      LOG.log("Setting current panel.");
      WINDOW.setCurrentPanel(CURRENT_PANEL);

      if (BOUND_HEIGHT != WINDOW.getBoundLength() || BOUND_WIDTH != WINDOW.getBoundWidth()) {
        LOG.log("Forcing window visiblity to false to update boundaries.");
        WINDOW.setVisible(false);
        LOG.log("Updating boundaries.");
        WINDOW.setBoundaries(BOUND_HEIGHT, BOUND_WIDTH);

        try {
          SwingUtilities.invokeAndWait(
              new Runnable() {
                @Override
                public void run() {
                  WINDOW.updateBoundaries();
                }
              });
        } catch (Exception ex) {
          ex.printStackTrace();
        }
      }

      LOG.log("Applying window attributes.");
      WINDOW.setTitle(TITLE);
      LOG.log("Forcing window visibility to true.");
      WINDOW.setVisible(true);

      LOG.log("Forcing window to move to centered position.");
      WINDOW.setLocationRelativeTo(null);
      LOG.log("Repainting window.");
      WINDOW.repaint();

    } else {
      LOG.log("No current panel, window cannot be refreshed.");
    }

    LOG.useSubSection(false);
  }
Ejemplo n.º 2
0
 private static void repaintUI(Window window) {
   if (!window.isDisplayable()) {
     return;
   }
   window.repaint();
   Window[] children = window.getOwnedWindows();
   for (Window aChildren : children) {
     repaintUI(aChildren);
   }
 }
  private void setSizeAndDimensions(
      @NotNull JTable table,
      @NotNull JBPopup popup,
      @NotNull RelativePoint popupPosition,
      @NotNull List<UsageNode> data) {
    JComponent content = popup.getContent();
    Window window = SwingUtilities.windowForComponent(content);
    Dimension d = window.getSize();

    int width = calcMaxWidth(table);
    width = (int) Math.max(d.getWidth(), width);
    Dimension headerSize = ((AbstractPopup) popup).getHeaderPreferredSize();
    width = Math.max((int) headerSize.getWidth(), width);
    width = Math.max(myWidth, width);

    if (myWidth == -1) myWidth = width;
    int newWidth = Math.max(width, d.width + width - myWidth);

    myWidth = newWidth;

    int rowsToShow = Math.min(30, data.size());
    Dimension dimension = new Dimension(newWidth, table.getRowHeight() * rowsToShow);
    Rectangle rectangle = fitToScreen(dimension, popupPosition, table);
    dimension = rectangle.getSize();
    Point location = window.getLocation();
    if (!location.equals(rectangle.getLocation())) {
      window.setLocation(rectangle.getLocation());
    }

    if (!data.isEmpty()) {
      TableScrollingUtil.ensureSelectionExists(table);
    }
    table.setSize(dimension);
    // table.setPreferredSize(dimension);
    // table.setMaximumSize(dimension);
    // table.setPreferredScrollableViewportSize(dimension);

    Dimension footerSize = ((AbstractPopup) popup).getFooterPreferredSize();

    int newHeight =
        (int) (dimension.height + headerSize.getHeight() + footerSize.getHeight())
            + 4 /* invisible borders, margins etc*/;
    Dimension newDim = new Dimension(dimension.width, newHeight);
    window.setSize(newDim);
    window.setMinimumSize(newDim);
    window.setMaximumSize(newDim);

    window.validate();
    window.repaint();
    table.revalidate();
    table.repaint();
  }