public static boolean isFocused(@Nullable Component[] components) {
    if (components == null) return false;

    Component owner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();

    if (owner == null) return false;

    Window wnd;
    if (owner instanceof Window) {
      wnd = (Window) owner;
    } else {
      wnd = SwingUtilities.getWindowAncestor(owner);
    }

    for (Component each : components) {
      if (each != null && SwingUtilities.isDescendingFrom(owner, each)) {
        Window eachWindow =
            each instanceof Window ? (Window) each : SwingUtilities.getWindowAncestor(each);
        if (eachWindow == wnd) {
          return true;
        }
      }
    }

    return false;
  }
 private boolean noIntersections(Rectangle bounds) {
   Window owner = SwingUtilities.getWindowAncestor(myComponent);
   Window popup = SwingUtilities.getWindowAncestor(myTipComponent);
   Window focus = WindowManagerEx.getInstanceEx().getMostRecentFocusedWindow();
   if (focus == owner.getOwner()) {
     focus = null; // do not check intersection with parent
   }
   boolean focused = SystemInfo.isWindows || owner.isFocused();
   for (Window other : owner.getOwnedWindows()) {
     if (!focused && !SystemInfo.isWindows) {
       focused = other.isFocused();
     }
     if (popup != other
         && other.isVisible()
         && bounds.x + 10 >= other.getX()
         && bounds.intersects(other.getBounds())) {
       return false;
     }
     if (focus == other) {
       focus = null; // already checked
     }
   }
   return focused
       && (focus == owner || focus == null || !owner.getBounds().intersects(focus.getBounds()));
 }
 public boolean isFocused() {
   if (myComponent != null
       && isFocused(new Component[] {SwingUtilities.getWindowAncestor(myComponent)})) {
     return true;
   }
   return isFocused(myFocusOwners);
 }
  /**
   * Shows the given error message.
   *
   * @param text the text of the error
   */
  private void showErrorMessage(String text) {
    errorPane.setText(text);

    if (errorPane.getParent() == null) add(errorPane, BorderLayout.NORTH);

    SwingUtilities.getWindowAncestor(CreateSip2SipAccountForm.this).pack();
  }
 public void propertyChange(final PropertyChangeEvent e) {
   if (myAlarm.getActiveRequestCount() == 0) {
     myInitialFocusedWindow = (Window) e.getOldValue();
     final MenuElement[] selectedPath = MenuSelectionManager.defaultManager().getSelectedPath();
     if (selectedPath.length == 0) { // there is no visible popup
       return;
     }
     Component firstComponent = null;
     for (final MenuElement menuElement : selectedPath) {
       final Component component = menuElement.getComponent();
       if (component instanceof JMenuBar) {
         firstComponent = component;
         break;
       } else if (component instanceof JPopupMenu) {
         firstComponent = ((JPopupMenu) component).getInvoker();
         break;
       }
     }
     if (firstComponent == null) {
       return;
     }
     final Window window = SwingUtilities.getWindowAncestor(firstComponent);
     if (window != myInitialFocusedWindow) { // focused window doesn't have popup
       return;
     }
   }
   myLastFocusedWindow = (Window) e.getNewValue();
   myAlarm.cancelAllRequests();
   myAlarm.addRequest(myClearSelectedPathRunnable, 150);
 }
 public static Window moveTo(
     JComponent content, Point screenPoint, final Dimension headerCorrectionSize) {
   setDefaultCursor(content);
   final Window wnd = SwingUtilities.getWindowAncestor(content);
   if (headerCorrectionSize != null) {
     screenPoint.y -= headerCorrectionSize.height;
   }
   wnd.setLocation(screenPoint);
   return wnd;
 }
Esempio n. 7
0
 private boolean checkLeftMargin(int x) {
   // Make sure leftMargin has at least 2 pixels over
   if (x < 2) {
     leftMargin += (2 - x);
     // Repaint from top (above any cell renderers)
     SwingUtilities.getWindowAncestor(this).repaint();
     return true;
   }
   return false;
 }
Esempio n. 8
0
 private boolean checkRightMargin(int w) {
   // Make sure rightMargin has at least 2 pixels over
   if (w + 2 > rightMargin) {
     rightMargin = (w + 2);
     // Repaint from top (above any cell renderers)
     SwingUtilities.getWindowAncestor(this).repaint();
     return true;
   }
   return false;
 }
Esempio n. 9
0
 private void registerAutoMove() {
   if (myOwner != null) {
     myOwnerWindow = SwingUtilities.getWindowAncestor(myOwner);
     if (myOwnerWindow != null) {
       myLastOwnerPoint = myOwnerWindow.getLocationOnScreen();
       myOwnerListener = new MyComponentAdapter();
       myOwnerWindow.addComponentListener(myOwnerListener);
     }
   }
 }
Esempio n. 10
0
 public static NoteFileDialogEx create(Component owner, BizRpcReducer rpcReducer) {
   Window win;
   if (owner instanceof Window) win = (Window) owner;
   else win = SwingUtilities.getWindowAncestor(owner);
   NoteFileDialogEx inst;
   if (win instanceof Frame) inst = new NoteFileDialogEx((Frame) win, rpcReducer);
   else if (win instanceof Dialog) inst = new NoteFileDialogEx((Dialog) win, rpcReducer);
   else inst = new NoteFileDialogEx(rpcReducer);
   return inst;
 }
Esempio n. 11
0
 /**
  * Installs the necessary Listeners on the parent <code>Window</code>, if there is one.
  *
  * <p>This takes the parent so that cleanup can be done from <code>removeNotify</code>, at which
  * point the parent hasn't been reset yet.
  *
  * @param parent The parent of the JRootPane
  */
 private void installWindowListeners(JRootPane root, Component parent) {
   if (parent instanceof Window) {
     window = (Window) parent;
   } else {
     window = SwingUtilities.getWindowAncestor(parent);
   }
   if (window != null) {
     if (mouseInputListener == null) {
       mouseInputListener = createWindowMouseInputListener(root);
     }
     window.addMouseListener(mouseInputListener);
     window.addMouseMotionListener(mouseInputListener);
   }
 }
Esempio n. 12
0
  public void tryToClose() {

    if (closeAppView()) {

      // success. continue with the shut down

      // apago el visor
      m_TP.getDeviceDisplay().clearVisor();
      // me desconecto de la base de datos.
      session.close();

      // Download Root form
      SwingUtilities.getWindowAncestor(this).dispose();
    }
  }
Esempio n. 13
0
  private void processParentWindowMoved() {
    if (isDisposed()) return;

    final Point newOwnerPoint = myOwnerWindow.getLocationOnScreen();

    int deltaX = myLastOwnerPoint.x - newOwnerPoint.x;
    int deltaY = myLastOwnerPoint.y - newOwnerPoint.y;

    myLastOwnerPoint = newOwnerPoint;

    final Window wnd = SwingUtilities.getWindowAncestor(getContent());
    final Point current = wnd.getLocationOnScreen();

    setLocation(new Point(current.x - deltaX, current.y - deltaY));
  }
  public void addNotify() {
    super.addNotify();

    uninstallListeners();

    myWindow = SwingUtilities.getWindowAncestor(this);
    if (myWindow != null) {
      if (myWindow instanceof Frame) {
        setState(((Frame) myWindow).getExtendedState());
      } else {
        setState(0);
      }
      setActive(myWindow.isActive());
      installListeners();
      updateSystemIcon();
    }
  }
  @Override
  public void adjustContainerWindow(Component c, Dimension oldSize, Dimension newSize) {
    if (c == null) return;

    Window wnd = SwingUtilities.getWindowAncestor(c);

    if (wnd instanceof JWindow) {
      JBPopup popup = (JBPopup) ((JWindow) wnd).getRootPane().getClientProperty(JBPopup.KEY);
      if (popup != null) {
        if (oldSize.height < newSize.height) {
          Dimension size = popup.getSize();
          size.height += (newSize.height - oldSize.height);
          popup.setSize(size);
          popup.moveToFitScreen();
        }
      }
    }
  }
  @Override
  public void pack(boolean width, boolean height) {
    if (!isVisible() || (!width && !height)) return;

    Dimension size = getSize();
    Dimension prefSize = myContent.computePreferredSize();

    if (width) {
      size.width = prefSize.width;
    }

    if (height) {
      size.height = prefSize.height;
    }

    size = computeWindowSize(size);

    final Window window = SwingUtilities.getWindowAncestor(myContent);
    window.setSize(size);
  }
  public void pack() {
    final Window window = SwingUtilities.getWindowAncestor(myContent);

    window.pack();
  }
Esempio n. 18
0
    public void actionPerformed(ActionEvent e) {
      Object source = e.getSource();
      JButton btn = (JButton) source;
      Window w = SwingUtilities.getWindowAncestor(btn);
      if (btn.getText().equals(usesword)) {
        boolean msword = false;
        for (String item : inventory) {
          String magicsword = "light saber"; // "magic sword";
          if (!used1) {
            if (item.equals(magicsword)) {
              txtTranscript.insert(
                  "An intense battle ensues! " // "\nCONGRATULATIONS! You have slain the dragon "
                      + "The only audible noise is the sound of light sabers waving in the air " // "and reclaimed the Treasure of the Noontide Sol! "
                      + "and crashing together. As the battle grows more intense, suddenly out " // "The light's morale has been restored to the land!\n"
                      + "of nowhere Emporer Palpatine intervenes, forcing you to the ground. "
                      + "You are paralyzed as powerful electrical pulses eminate from the "
                      + "Emporer's fingertips, entering into your entire being. "
                      + "Your father, Darth Vader will not let the Emporer kill you! "
                      + "He picks up the Emporer and throws him over the edge of a bottomless pit of certain doom! "
                      + "He has saved your life!!! "
                      + "With this one act of love your father has returned to the light, "
                      + "showing that the light side of the force is still in him. "
                      + "GAME OVER - YOU HAVE WON!!!",
                  txtTranscript.getText().length());
              msword = true;
              used1 = false;
              w.setVisible(false);
            }
          }
        }
        if (!used1 && !msword) {
          txtTranscript.insert(
              "\nDarth Vader lunges forward to strike you with his light saber!!! " // "The dragon
                  // blows flames
                  // in your
                  // direction!!!
                  // "
                  + "You got lucky! He narrowly missed!!!"
                  + "\nCONGRATULATIONS! You're an idiot! "
                  + "You don't have a light saber! "
                  + "Better retreat for now...",
              txtTranscript.getText().length());
          used1 = true;
        } else if (used1 && !msword) {
          txtTranscript.insert(
              "\nThe Mask doesn't seem to be working. " // ("\nThe dragon blows flames in your
                  // direction "
                  + "You are not so lucky this time. After stupidly trying the Hulk mask "
                  + "again, Vader lunges forward with his saber, decapitating you instantly. " // the dragon engulfs you in flames, almost instantly incinerating you "
                  + "...\nGAME OVER\n",
              txtTranscript.getText().length());
          msword = true;
          used1 = false;
          w.setVisible(false);
        }
      }
      if (btn.getText().equals(usedagger)) {
        boolean dagger = false;
        for (String item : inventory) {
          if (item.equals("glowing hulk mask")) { // dagger")) {
            if (!used) {
              txtTranscript.insert(
                  "\nThe Mask doesn't seem to be working. "
                      + "Darth Vader lunges forward to strike you with his light saber!!! " // "The
                      // dragon blows flames in your direction!!! "
                      + "You got lucky! He narrowly missed!!! "
                      + "Better try something else...",
                  txtTranscript.getText().length());
              dagger = true;
              used = true;
            } else {
              txtTranscript.insert(
                  "\nThe Mask doesn't seem to be working. " // ("\nThe dragon blows flames in your
                      // direction "
                      + "You are not so lucky this time. After stupidly trying the Hulk mask "
                      + "again, Vader lunges forward with his saber, decapitating you instantly. " // the dragon engulfs you in flames, almost instantly incinerating you "
                      + "...\nGAME OVER\n",
                  txtTranscript.getText().length());
              used = false; // reset static used boolean to false in case player comes back
              w.setVisible(false);
            }
          }
        }
        if (!used && !dagger) {
          txtTranscript.insert(
              "\nThe Mask doesn't seem to be working. "
                  + "Darth Vader lunges forward to strike you with his light saber!!! " // "The
                  // dragon
                  // blows
                  // flames in
                  // your
                  // direction!!! "
                  + "You got lucky! He narrowly missed!!! "
                  + "Better try something else...",
              txtTranscript.getText().length());
          /*("\nThe dragon blows flames in your direction!!! "
          + "You got lucky! The flames narrowly missed!!!"
          + "\nCONGRATULATIONS! You're an idiot! "
          + "You don't have a dagger! And if you did would it really help "
          + "against this dragon? Better try something else...", txtTranscript.getText().length());*/
          used = true;
        } else if (used && !dagger) {
          txtTranscript.insert(
              "\nThe Mask doesn't seem to be working. " // ("\nThe dragon blows flames in your
                  // direction "
                  + "You are not so lucky this time. After stupidly trying the Hulk mask "
                  + "again, Vader lunges forward with his saber, decapitating you instantly. " // the dragon engulfs you in flames, almost instantly incinerating you "
                  + "...\nGAME OVER\n",
              txtTranscript.getText().length());

          /*("\nThe dragon blows flames in your direction "
          + "You are not so lucky this time. After stupidly trying the dagger "
          + "again, THAT YOU DON'T HAVE! the dragon engulfs you in flames, almost instantly incinerating you "
          + "into a pile of ashes ...\nGAME OVER\n", txtTranscript.getText().length());*/
          used = false; // reset static used boolean to false in case player comes back
          w.setVisible(false);
        }
      }
      if (btn.getText().equals(runaway)) {
        txtTranscript.insert(
            "\nRUN FOR IT MARTY!!!\nYou barely escape.", txtTranscript.getText().length());
        used = false; // reset static used boolean to false in case player comes back
        w.setVisible(false);
      }
    }
 protected boolean isPopup() {
   Window window = SwingUtilities.getWindowAncestor(myComponent);
   return window != null
       && !(window instanceof Dialog || window instanceof Frame)
       && !isHintsAllowed(window);
 }
Esempio n. 20
0
    public void actionPerformed(ActionEvent e) {
      int tempW = mapWidth;
      int tempH = mapHeight;
      int targetW;
      int targetH;
      try {
        targetW = Integer.parseInt(widthField.getText());
        targetH = Integer.parseInt(heightField.getText());

        if (targetH <= 0 || targetW <= 0) {
          JOptionPane.showMessageDialog(null, "Both x and y must be above 0.");
        } else {

          // shrink width if necessary
          while (targetW < mapWidth) {
            for (int i = mapHeight * mapWidth - 1; i >= 0; i -= mapWidth) {
              map.remove(i);
            }
            mapWidth--;
            mapScroll.revalidate();
            map.repaint();

            backEnd.removeColumn(backEnd.getWidth() - 1);
          }

          // shrink height if necessary
          while (targetH < mapHeight) {
            for (int i = 1; i <= mapWidth; i++) {
              map.remove(mapHeight * mapWidth - i);
            }
            mapHeight--;
            // map.setLayout(new GridLayout(mapHeight,mapWidth));
            map.repaint();
            backEnd.removeRow(backEnd.getHeight() - 1);
          }

          // Grow if necessary
          if (targetW > mapWidth || targetH > mapHeight) {
            // add new rows and columns, then rebuild and re-add display
            int[] mov = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
            while (targetW > mapWidth) {
              // add new column to backEnd
              List<Tile> tList = new ArrayList<Tile>();
              for (int i = 0; i < mapHeight; i++) {
                Tile t = new Tile(currTileImg, "Test", 0, 0, mov, "none", true, currTileLoc);
                t.setPreferredSize(
                    new Dimension(TILE_SIZE * DISPLAY_SCALE, TILE_SIZE * DISPLAY_SCALE));
                t.addMouseListener(new MapButtonListener());
                tList.add(t);
              }
              backEnd.addColumn(tList);
              mapWidth++;
            }
            while (targetH > mapHeight) {
              // add new row to backEnd
              List<Tile> tList = new ArrayList<Tile>();
              for (int i = 0; i < mapWidth; i++) {
                Tile t = new Tile(currTileImg, "Test", 0, 0, mov, "none", true, currTileLoc);
                t.setPreferredSize(
                    new Dimension(TILE_SIZE * DISPLAY_SCALE, TILE_SIZE * DISPLAY_SCALE));
                t.addMouseListener(new MapButtonListener());
                tList.add(t);
              }
              backEnd.addRow(tList);
              mapHeight++;
            }

            GridBagConstraints gbc = new GridBagConstraints();

            for (int i = 0; i < mapHeight; i++) {
              gbc.gridy = i;
              for (int j = 0; j < mapWidth; j++) {
                gbc.gridx = j;
                map.add(backEnd.getTile(j, i), gbc);
              }
            }
            map.revalidate();
            map.repaint();
            parentPanel.revalidate();
            parentPanel.repaint();
            ((MapBuilder) SwingUtilities.getWindowAncestor(parentPanel)).pack();
          }
        }
      } catch (NumberFormatException f) {
        JOptionPane.showMessageDialog(null, "Both x and y must be valid integers.");
      }
    }
  public void show(Component owner, int aScreenX, int aScreenY, final boolean considerForcedXY) {
    if (ApplicationManagerEx.getApplicationEx() != null
        && ApplicationManager.getApplication().isHeadlessEnvironment()) return;
    if (isDisposed()) {
      throw new IllegalStateException(
          "Popup was already disposed. Recreate a new instance to show again");
    }

    assert ApplicationManager.getApplication().isDispatchThread();

    addActivity();

    final boolean shouldShow = beforeShow();
    if (!shouldShow) {
      removeActivity();
      return;
    }

    prepareToShow();

    if (myInStack) {
      myFocusTrackback = new FocusTrackback(this, owner, true);
      myFocusTrackback.setMustBeShown(true);
    }

    Dimension sizeToSet = null;

    if (myDimensionServiceKey != null) {
      sizeToSet = DimensionService.getInstance().getSize(myDimensionServiceKey, myProject);
    }

    if (myForcedSize != null) {
      sizeToSet = myForcedSize;
    }

    if (myMinSize == null) {
      myMinSize = myContent.getMinimumSize();
    }

    if (sizeToSet == null) {
      sizeToSet = myContent.getPreferredSize();
    }

    if (sizeToSet != null) {
      sizeToSet.width = Math.max(sizeToSet.width, myMinSize.width);
      sizeToSet.height = Math.max(sizeToSet.height, myMinSize.height);

      myContent.setSize(sizeToSet);
      myContent.setPreferredSize(sizeToSet);
    }

    Point xy = new Point(aScreenX, aScreenY);
    boolean adjustXY = true;
    if (myDimensionServiceKey != null) {
      final Point storedLocation =
          DimensionService.getInstance().getLocation(myDimensionServiceKey, myProject);
      if (storedLocation != null) {
        xy = storedLocation;
        adjustXY = false;
      }
    }

    if (adjustXY) {
      final Insets insets = myContent.getInsets();
      if (insets != null) {
        xy.x -= insets.left;
        xy.y -= insets.top;
      }
    }

    if (considerForcedXY && myForcedLocation != null) {
      xy = myForcedLocation;
    }

    if (myLocateByContent) {
      final Dimension captionSize = myHeaderPanel.getPreferredSize();
      xy.y -= captionSize.height;
    }

    Rectangle targetBounds = new Rectangle(xy, myContent.getPreferredSize());
    Insets insets = myPopupBorder.getBorderInsets(myContent);
    if (insets != null) {
      targetBounds.x += insets.left;
      targetBounds.y += insets.top;
    }

    Rectangle original = new Rectangle(targetBounds);
    if (myLocateWithinScreen) {
      ScreenUtil.moveRectangleToFitTheScreen(targetBounds);
    }

    if (myMouseOutCanceller != null) {
      myMouseOutCanceller.myEverEntered = targetBounds.equals(original);
    }

    myOwner = IdeFrameImpl.findNearestModalComponent(owner);
    if (myOwner == null) {
      myOwner = owner;
    }

    myRequestorComponent = owner;

    boolean forcedDialog = (SystemInfo.isMac && !(myOwner instanceof IdeFrame)) || myMayBeParent;

    PopupComponent.Factory factory = getFactory(myForcedHeavyweight || myResizable, forcedDialog);
    myNativePopup = factory.isNativePopup();
    myPopup = factory.getPopup(myOwner, myContent, targetBounds.x, targetBounds.y);

    if (myResizable) {
      final JRootPane root = myContent.getRootPane();
      final IdeGlassPaneImpl glass = new IdeGlassPaneImpl(root);
      root.setGlassPane(glass);

      final ResizeComponentListener resizeListener = new ResizeComponentListener(this, glass);
      glass.addMousePreprocessor(resizeListener, this);
      glass.addMouseMotionPreprocessor(resizeListener, this);
    }

    if (myCaption != null && myMovable) {
      final MoveComponentListener moveListener =
          new MoveComponentListener(myCaption) {
            public void mousePressed(final MouseEvent e) {
              super.mousePressed(e);
              if (e.isConsumed()) return;

              if (UIUtil.isCloseClick(e)) {
                if (myCaption.isWithinPanel(e)) {
                  cancel();
                }
              }
            }
          };
      ListenerUtil.addMouseListener(myCaption, moveListener);
      ListenerUtil.addMouseMotionListener(myCaption, moveListener);
      final MyContentPanel saved = myContent;
      Disposer.register(
          this,
          new Disposable() {
            public void dispose() {
              ListenerUtil.removeMouseListener(saved, moveListener);
              ListenerUtil.removeMouseMotionListener(saved, moveListener);
            }
          });
    }

    for (JBPopupListener listener : myListeners) {
      listener.beforeShown(new LightweightWindowEvent(this));
    }

    myPopup.setRequestFocus(myRequestFocus);
    myPopup.show();

    final Window window = SwingUtilities.getWindowAncestor(myContent);

    myWindowListener = new MyWindowListener();
    window.addWindowListener(myWindowListener);

    if (myFocusable) {
      window.setFocusableWindowState(true);
      window.setFocusable(true);
    }

    myWindow = updateMaskAndAlpha(window);

    if (myWindow instanceof JWindow) {
      ((JWindow) myWindow).getRootPane().putClientProperty(KEY, this);
    }

    if (myWindow != null) {
      // dialogwrapper-based popups do this internally through peer,
      // for other popups like jdialog-based we should exclude them manually, but
      // we still have to be able to use IdeFrame as parent
      if (!myMayBeParent && !(myWindow instanceof Frame)) {
        WindowManager.getInstance().doNotSuggestAsParent(myWindow);
      }
    }

    final Runnable afterShow =
        new Runnable() {
          public void run() {
            if (myPreferredFocusedComponent != null && myInStack && myFocusable) {
              myFocusTrackback.registerFocusComponent(myPreferredFocusedComponent);
            }

            removeActivity();

            afterShow();
          }
        };

    if (myRequestFocus) {
      getFocusManager()
          .requestFocus(
              new FocusCommand() {
                @Override
                public ActionCallback run() {
                  if (isDisposed()) {
                    removeActivity();
                    return new ActionCallback.Done();
                  }

                  _requestFocus();

                  final ActionCallback result = new ActionCallback();

                  final Runnable afterShowRunnable =
                      new Runnable() {
                        @Override
                        public void run() {
                          afterShow.run();
                          result.setDone();
                        }
                      };
                  if (myNativePopup) {
                    final FocusRequestor furtherRequestor = getFocusManager().getFurtherRequestor();
                    SwingUtilities.invokeLater(
                        new Runnable() {
                          @Override
                          public void run() {
                            if (isDisposed()) {
                              result.setRejected();
                              return;
                            }

                            furtherRequestor
                                .requestFocus(
                                    new FocusCommand() {
                                      @Override
                                      public ActionCallback run() {
                                        if (isDisposed()) {
                                          return new ActionCallback.Rejected();
                                        }

                                        _requestFocus();

                                        afterShowRunnable.run();

                                        return new ActionCallback.Done();
                                      }
                                    },
                                    true)
                                .notify(result)
                                .doWhenProcessed(
                                    new Runnable() {
                                      @Override
                                      public void run() {
                                        removeActivity();
                                      }
                                    });
                          }
                        });
                  } else {
                    afterShowRunnable.run();
                  }

                  return result;
                }
              },
              true)
          .doWhenRejected(
              new Runnable() {
                @Override
                public void run() {
                  afterShow.run();
                }
              });
    } else {
      SwingUtilities.invokeLater(
          new Runnable() {
            @Override
            public void run() {
              if (isDisposed()) {
                removeActivity();
                return;
              }

              afterShow.run();
            }
          });
    }
  }
 public static void setDefaultCursor(JComponent content) {
   final Window wnd = SwingUtilities.getWindowAncestor(content);
   if (wnd != null) {
     wnd.setCursor(Cursor.getDefaultCursor());
   }
 }
Esempio n. 23
0
    @Override
    protected void paintComponent(Graphics g) {
      JRibbonFrame ribbonFrame = (JRibbonFrame) SwingUtilities.getWindowAncestor(this);
      if (!ribbonFrame.isShowingKeyTips()) return;

      // don't show keytips on inactive windows
      if (!ribbonFrame.isActive()) return;

      Collection<KeyTipManager.KeyTipLink> keyTips =
          KeyTipManager.defaultManager().getCurrentlyShownKeyTips();
      if (keyTips != null) {
        Graphics2D g2d = (Graphics2D) g.create();
        RenderingUtils.installDesktopHints(g2d);

        for (KeyTipManager.KeyTipLink keyTip : keyTips) {
          // don't display keytips on components in popup panels
          if (SwingUtilities.getAncestorOfClass(JPopupPanel.class, keyTip.comp) != null) continue;

          // don't display key tips on hidden components
          Rectangle compBounds = keyTip.comp.getBounds();
          if (!keyTip.comp.isShowing()
              || (compBounds.getWidth() == 0)
              || (compBounds.getHeight() == 0)) continue;

          Dimension pref =
              KeyTipRenderingUtilities.getPrefSize(g2d.getFontMetrics(), keyTip.keyTipString);

          Point prefCenter = keyTip.prefAnchorPoint;
          Point loc = SwingUtilities.convertPoint(keyTip.comp, prefCenter, this);
          Container bandControlPanel =
              SwingUtilities.getAncestorOfClass(AbstractBandControlPanel.class, keyTip.comp);
          if (bandControlPanel != null) {
            // special case for controls in threesome
            // ribbon band rows
            if (hasClientPropertySetToTrue(keyTip.comp, BasicBandControlPanelUI.TOP_ROW)) {
              loc = SwingUtilities.convertPoint(keyTip.comp, prefCenter, bandControlPanel);
              loc.y = 0;
              loc = SwingUtilities.convertPoint(bandControlPanel, loc, this);
              // prefCenter.y = 0;
            }
            if (hasClientPropertySetToTrue(keyTip.comp, BasicBandControlPanelUI.MID_ROW)) {
              loc = SwingUtilities.convertPoint(keyTip.comp, prefCenter, bandControlPanel);
              loc.y = bandControlPanel.getHeight() / 2;
              loc = SwingUtilities.convertPoint(bandControlPanel, loc, this);
              // prefCenter.y = keyTip.comp.getHeight() / 2;
            }
            if (hasClientPropertySetToTrue(keyTip.comp, BasicBandControlPanelUI.BOTTOM_ROW)) {
              loc = SwingUtilities.convertPoint(keyTip.comp, prefCenter, bandControlPanel);
              loc.y = bandControlPanel.getHeight();
              loc = SwingUtilities.convertPoint(bandControlPanel, loc, this);
              // prefCenter.y = keyTip.comp.getHeight();
            }
          }

          KeyTipRenderingUtilities.renderKeyTip(
              g2d,
              this,
              new Rectangle(
                  loc.x - pref.width / 2, loc.y - pref.height / 2, pref.width, pref.height),
              keyTip.keyTipString,
              keyTip.enabled);
        }

        g2d.dispose();
      }
    }
Esempio n. 24
0
  // s.oh^ 2014/08/19 施設患者一括表示機能
  public void visitAll() {
    List<PatientModel> list = getTableModel().getDataProvider();
    if (list == null) return;
    for (PatientModel model : list) {
      // 来院情報を生成する
      PatientVisitModel pvt = new PatientVisitModel();
      pvt.setId(0L);
      pvt.setNumber(number++);
      pvt.setPatientModel(model);

      // --------------------------------------------------------
      // 受け付けを通していないのでログイン情報及び設定ファイルを使用する
      // 診療科名、診療科コード、医師名、医師コード、JMARI
      // 2.0
      // ---------------------------------------------------------
      pvt.setDeptName(Project.getUserModel().getDepartmentModel().getDepartmentDesc());
      pvt.setDeptCode(Project.getUserModel().getDepartmentModel().getDepartment());
      pvt.setDoctorName(Project.getUserModel().getCommonName());
      if (Project.getUserModel().getOrcaId() != null) {
        pvt.setDoctorId(Project.getUserModel().getOrcaId());
      } else {
        pvt.setDoctorId(Project.getUserModel().getUserId());
      }
      String jamri;
      if (Project.claimSenderIsServer()) {
        ServerInfoDelegater sid = new ServerInfoDelegater();
        try {
          jamri = sid.getJamri();
        } catch (Exception ex) {
          jamri = Project.getString(Project.JMARI_CODE);
          Log.outputFuncLog(Log.LOG_LEVEL_0, Log.FUNCTIONLOG_KIND_ERROR, ex.toString());
        }
      } else {
        jamri = Project.getString(Project.JMARI_CODE);
      }
      pvt.setJmariNumber(jamri);

      // 来院日
      pvt.setPvtDate(ModelUtils.getDateTimeAsString(new Date()));

      final PatientVisitModel fPvt = pvt;

      SimpleWorker worker =
          new SimpleWorker<Void, Void>() {

            @Override
            protected Void doInBackground() throws Exception {
              PVTDelegater1 pdl = new PVTDelegater1();
              pdl.addPvt(fPvt);
              return null;
            }

            @Override
            protected void succeeded(Void result) {}

            @Override
            protected void failed(Throwable cause) {}

            @Override
            protected void startProgress() {
              doStartProgress();
            }

            @Override
            protected void stopProgress() {
              doStopProgress();
            }
          };

      worker.execute();
    }
    Window parent = SwingUtilities.getWindowAncestor(getUI());
    JOptionPane.showMessageDialog(parent, "一括受付しました。", "一括受付", JOptionPane.WARNING_MESSAGE);
    Log.outputFuncLog(Log.LOG_LEVEL_0, Log.FUNCTIONLOG_KIND_INFORMATION, "一括受付しました。");
  }