Esempio n. 1
0
  /**
   * Uninstalls the ShadowPopupFactory and restores the original popup factory as the new shared
   * popup factory.
   *
   * @see #install()
   */
  public static void uninstall() {
    PopupFactory factory = PopupFactory.getSharedInstance();
    if (!(factory instanceof ShadowPopupFactory)) return;

    PopupFactory stored = ((ShadowPopupFactory) factory).storedFactory;
    PopupFactory.setSharedInstance(stored);
  }
Esempio n. 2
0
    public void mouseMoved(MouseEvent e) {
      if (geoDisplayPopup != null) {
        geoDisplayPopup.hide();
      }

      String pointMessage = "";

      x = e.getX();
      y = e.getY();
      double minDist = -1;
      if (geoPoints == null || geoPoints.size() == 0) {
        return;
      }
      for (GeoPoint p : geoPoints) {
        double dist = p.distance(x, y);
        if (minDist > dist || minDist < 0) {
          pointMessage = p.getMessage();
          minDist = dist;
        }
      }
      if (minDist > 2.5) {
        return;
      }
      geoPanel = GeoPolygonPanel.this;
      message.setText(pointMessage);
      PopupFactory factory = PopupFactory.getSharedInstance();
      geoDisplayPopup =
          factory.getPopup(
              owner,
              message,
              (int) geoPanel.getLocationOnScreen().getX() + x,
              (int) geoPanel.getLocationOnScreen().getY() + y - 15);
      geoDisplayPopup.show();
    }
  /**
   * The following code is a trick! By default Swing uses lightweight and "medium" weight popups to
   * show JPopupMenu. The code below force the creation of real heavyweight menus - this increases
   * speed of popups and allows to get rid of some drawing artifacts.
   */
  private static void fixPopupWeight() {
    int popupWeight = OurPopupFactory.WEIGHT_MEDIUM;
    String property = System.getProperty("idea.popup.weight");
    if (property != null) property = property.toLowerCase(Locale.ENGLISH).trim();
    if (SystemInfo.isMacOSLeopard) {
      // force heavy weight popups under Leopard, otherwise they don't have shadow or any kind of
      // border.
      popupWeight = OurPopupFactory.WEIGHT_HEAVY;
    } else if (property == null) {
      // use defaults if popup weight isn't specified
      if (SystemInfo.isWindows) {
        popupWeight = OurPopupFactory.WEIGHT_HEAVY;
      }
    } else {
      if ("light".equals(property)) {
        popupWeight = OurPopupFactory.WEIGHT_LIGHT;
      } else if ("medium".equals(property)) {
        popupWeight = OurPopupFactory.WEIGHT_MEDIUM;
      } else if ("heavy".equals(property)) {
        popupWeight = OurPopupFactory.WEIGHT_HEAVY;
      } else {
        LOG.error("Illegal value of property \"idea.popup.weight\": " + property);
      }
    }

    PopupFactory factory = PopupFactory.getSharedInstance();
    if (!(factory instanceof OurPopupFactory)) {
      factory = new OurPopupFactory(factory);
      PopupFactory.setSharedInstance(factory);
    }
    PopupUtil.setPopupType(factory, popupWeight);
  }
Esempio n. 4
0
    public void mousePressed(MouseEvent e) {
      if (e.getButton() == e.BUTTON3) {
        NumberFormat nf = NumberFormat.getInstance();
        nf.setMaximumFractionDigits(2);
        int index = list.locationToIndex(e.getPoint());
        GetImageFile gif = new GetImageFile(files[index]);

        JTextArea area =
            new JTextArea(
                "File: "
                    + gif.getImageString()
                    + "\n"
                    + "Score: "
                    + nf.format(scores[index])
                    + "\n"
                    + "Pairs: "
                    + nrpairs[index]);
        area.setEditable(false);
        area.setBorder(BorderFactory.createLineBorder(Color.black));
        area.setFont(new Font("times", Font.PLAIN, 12));
        PopupFactory factory = PopupFactory.getSharedInstance();
        popup =
            factory.getPopup(
                null,
                area,
                (int) e.getComponent().getLocationOnScreen().getX() + e.getX() + 25,
                (int) e.getComponent().getLocationOnScreen().getY() + e.getY());
        popup.show();
      }
    }
Esempio n. 5
0
  /**
   * Returns a <code>Popup</code> instance from the <code>PopupMenuUI</code> that has had <code>show
   * </code> invoked on it. If the current <code>popup</code> is non-null, this will invoke <code>
   * dispose</code> of it, and then <code>show</code> the new one.
   *
   * <p>This does NOT fire any events, it is up the caller to dispatch the necessary events.
   */
  private Popup getPopup() {
    Popup oldPopup = popup;

    if (oldPopup != null) {
      oldPopup.hide();
    }
    PopupFactory popupFactory = PopupFactory.getSharedInstance();

    if (isLightWeightPopupEnabled()) {
      popupFactory.setPopupType(PopupFactory.LIGHT_WEIGHT_POPUP);
    } else {
      popupFactory.setPopupType(PopupFactory.MEDIUM_WEIGHT_POPUP);
    }

    // adjust the location of the popup
    Point p = adjustPopupLocationToFitScreen(desiredLocationX, desiredLocationY);
    desiredLocationX = p.x;
    desiredLocationY = p.y;

    Popup newPopup = getUI().getPopup(this, desiredLocationX, desiredLocationY);

    popupFactory.setPopupType(PopupFactory.LIGHT_WEIGHT_POPUP);
    newPopup.show();
    return newPopup;
  }
Esempio n. 6
0
  public static void showPopup(Component parent, String title, String message, int x, int y) {
    JLabel descr = new JLabel(message);
    JLabel tit = new JLabel(title);

    JPanel pn = new JPanel(new BorderLayout());
    JPanel tpn = new JPanel(new GridBagLayout());
    tpn.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.GRAY));
    CloseButton cb = new CloseButton();
    tpn.add(
        cb,
        new GridBagConstraints(
            1,
            0,
            1,
            1,
            0,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE,
            new Insets(2, 0, 5, 0),
            0,
            0));
    tpn.add(
        tit,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            1.0,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 0, 2, 5),
            0,
            0));
    tpn.setOpaque(false);
    pn.add(tpn, BorderLayout.NORTH);
    pn.add(descr, BorderLayout.CENTER);
    //    pn.setFont(new Font("Dialog", Font.PLAIN, 11));
    pn.setBackground(SystemColor.info);
    pn.setForeground(SystemColor.infoText);
    pn.setOpaque(true);
    pn.setBorder(
        BorderFactory.createCompoundBorder(
            BorderFactory.createMatteBorder(1, 1, 1, 1, Color.BLACK),
            BorderFactory.createEmptyBorder(0, 5, 5, 5)));

    final Popup p = PopupFactory.getSharedInstance().getPopup(parent, pn, x, y);
    cb.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            p.hide();
          }
        });
    p.show();
  }
Esempio n. 7
0
 /** Perform a search when user stop to type in the search combo for 2 sec or pressed enter */
 private void search() {
   try {
     bNeedSearch = false;
     setEnabled(false); // no typing during search
     if (sTyped.length() >= MIN_CRITERIA_LENGTH) {
       // second test to get sure user didn't
       // typed before entering this method
       TreeSet<SearchResult> tsResu = TrackManager.getInstance().search(sTyped.toString());
       // Add web radio names
       tsResu.addAll(WebRadioManager.getInstance().search(sTyped.toString()));
       if (tsResu.size() > 0) {
         DefaultListModel model = new DefaultListModel();
         alResults = new ArrayList<SearchResult>();
         alResults.addAll(tsResu);
         for (SearchResult sr : tsResu) {
           model.addElement(sr);
         }
         jlist = new JList(model);
         jlist.setLayoutOrientation(JList.VERTICAL);
         jlist.setCellRenderer(new SearchListRenderer());
         PopupFactory factory = PopupFactory.getSharedInstance();
         JScrollPane jsp = new JScrollPane(jlist);
         int width = (int) ((float) Toolkit.getDefaultToolkit().getScreenSize().getWidth() * 0.7f);
         jsp.setMinimumSize(new Dimension(width, 250));
         jsp.setPreferredSize(new Dimension(width, 250));
         jsp.setMaximumSize(new Dimension(width, 250));
         jlist.setSelectionMode(0);
         jlist.addListSelectionListener(lsl);
         jsp.setBorder(BorderFactory.createLineBorder(Color.BLACK));
         if (popup != null) {
           popup.hide();
         }
         // take upper-left point relative to the
         // textfield
         Point point = new Point(0, 0);
         // take absolute coordonates in the screen (popups works
         // only on absolute coordonates in opposition to swing
         // widgets)
         SwingUtilities.convertPointToScreen(point, this);
         popup =
             factory.getPopup(
                 this, jsp, (int) point.getX() + 500 - (width), (int) point.getY() - 250);
         popup.show();
       } else {
         if (popup != null) {
           popup.hide();
         }
       }
     }
     requestFocusInWindow();
   } catch (Exception e) {
     Log.error(e);
   } finally { // make sure to enable search box in all cases
     setEnabled(true);
   }
 }
Esempio n. 8
0
      public PopupComponent getPopup(Component owner, Component content, int x, int y) {
        final PopupFactory factory = PopupFactory.getSharedInstance();

        final int oldType = PopupUtil.getPopupType(factory);
        PopupUtil.setPopupType(factory, 2);
        final Popup popup = factory.getPopup(owner, content, x, y);
        if (oldType >= 0) PopupUtil.setPopupType(factory, oldType);

        return new AwtPopupWrapper(popup);
      }
Esempio n. 9
0
  /**
   * Installs the ShadowPopupFactory as the shared popup factory on non-Mac platforms. Also stores
   * the previously set factory, so that it can be restored in <code>#uninstall</code>.
   *
   * <p>In some Mac Java environments the popup factory throws a NullPointerException when we call
   * <code>#getPopup</code>.
   *
   * <p>TODO: The Mac case shows that we may have problems replacing non PopupFactory instances.
   * Therefore we should consider replacing only instances of PopupFactory.
   *
   * @see #uninstall()
   */
  public static void install() {
    if (LookUtils.IS_OS_MAC) {
      return;
    }

    PopupFactory factory = PopupFactory.getSharedInstance();
    if (factory instanceof ShadowPopupFactory) return;

    PopupFactory.setSharedInstance(new ShadowPopupFactory(factory));
  }
Esempio n. 10
0
 protected void showInfoPopup(String info, int x, int y) {
   JPanel content = new JPanel();
   content.add(new JLabel(info));
   content.setBorder(BorderFactory.createLineBorder(Color.BLACK));
   Point location = getLocationOnScreen();
   location.x += x + 5;
   location.y += y + 5;
   popup = PopupFactory.getSharedInstance().getPopup(this, content, location.x, location.y);
   popup.show();
 }
Esempio n. 11
0
 /** Perform a search when user stop to type in the search combo for 2 sec or pressed enter */
 private void search() {
   try {
     bNeedSearch = false;
     setEnabled(false); // no typing during search
     if (sTyped.length()
         >= MIN_CRITERIA_LENGTH) { // second test to get sure user didn't typed before entering
                                   // this method
       TreeSet tsResu = FileManager.getInstance().search(sTyped.toString());
       if (tsResu.size() > 0) {
         DefaultListModel model = new DefaultListModel();
         alResults = new ArrayList();
         alResults.addAll(tsResu);
         Iterator it = tsResu.iterator();
         while (it.hasNext()) {
           model.addElement(((SearchResult) it.next()).getResu());
         }
         jlist = new JList(model);
         PopupFactory factory = PopupFactory.getSharedInstance();
         JScrollPane jsp = new JScrollPane(jlist);
         jlist.setSelectionMode(0);
         jlist.addListSelectionListener(lsl);
         jsp.setBorder(BorderFactory.createLineBorder(Color.BLACK));
         if (popup != null) {
           popup.hide();
         }
         Point point = new Point(0, 0); // take upper-left point relative to the textfield
         SwingUtilities.convertPointToScreen(
             point,
             this); // take absolute coordonates in the screen ( popups works only on absolute
                    // coordonates in oposition to swing widgets)
         popup = factory.getPopup(this, jsp, (int) point.getX(), (int) point.getY() + 25);
         popup.show();
       } else {
         if (popup != null) {
           popup.hide();
         }
       }
     }
     requestFocusInWindow();
   } catch (Exception e) {
     Log.error(e);
   } finally { // make sure to enable search box in all cases
     setEnabled(true);
   }
 }
 public void actionPerformed(ActionEvent e) {
   PopupFactory popupFactory = PopupFactory.getSharedInstance();
   JToolTip tip = new JToolTip();
   tip.setTipText(TextUtils.getText("docear.monitoring.reload.name"));
   final Point locationOnScreen = comp.getLocationOnScreen();
   final int height = comp.getHeight();
   Rectangle sBounds = comp.getGraphicsConfiguration().getBounds();
   final int minX = sBounds.x;
   final int maxX = sBounds.x + sBounds.width;
   final int minY = sBounds.y;
   final int maxY = sBounds.y + sBounds.height;
   int x = locationOnScreen.x;
   int y = locationOnScreen.y + height;
   final Dimension tipSize = tip.getPreferredSize();
   final int tipWidth = tipSize.width;
   if (x + tipWidth > maxX) {
     x = maxX - tipWidth;
   }
   if (x < minX) {
     x = minX;
   }
   final int tipHeight = tipSize.height;
   if (y + tipHeight > maxY) {
     if (locationOnScreen.y - tipHeight > minY) {
       y = locationOnScreen.y - tipHeight;
     } else {
       y = maxY - tipHeight;
     }
   }
   if (y < minY) {
     y = minY;
   }
   final Popup tipPopup = popupFactory.getPopup(comp, tip, x, y);
   tipPopup.show();
   showTimer.removeActionListener(this);
   hideTimer.addActionListener(new HideToolTipAction(tipPopup, tip, comp));
   hideTimer.start();
 }
 /**
  * show date chooser panel
  *
  * @param owner: {@link Component}
  */
 private void showPanel(Component owner) {
   if (pop != null) {
     pop.hide();
   }
   Point show = new Point(0, showDate.getHeight());
   SwingUtilities.convertPointToScreen(show, showDate);
   Dimension size = Toolkit.getDefaultToolkit().getScreenSize();
   int x = show.x;
   int y = show.y;
   if (x < 0) {
     x = 0;
   }
   if (x > size.width - 380) {
     x = size.width - 380;
   }
   if (y < size.height - 170) {
   } else {
     y -= 188;
   }
   pop = PopupFactory.getSharedInstance().getPopup(owner, monthPanel, x, y);
   pop.show();
   isShow = true;
 }
Esempio n. 14
0
  private void showPopup(Set<AppearancePort> portObjects) {
    dragStart = null;
    CircuitState circuitState = canvas.getCircuitState();
    if (circuitState == null) return;
    ArrayList<Instance> ports = new ArrayList<Instance>(portObjects.size());
    for (AppearancePort portObject : portObjects) {
      ports.add(portObject.getPin());
    }

    hideCurrentPopup();
    LayoutThumbnail layout = new LayoutThumbnail();
    layout.setCircuit(circuitState, ports);
    JViewport owner = canvasPane.getViewport();
    Point ownerLoc = owner.getLocationOnScreen();
    Dimension ownerDim = owner.getSize();
    Dimension layoutDim = layout.getPreferredSize();
    int x = ownerLoc.x + Math.max(0, ownerDim.width - layoutDim.width - 5);
    int y = ownerLoc.y + Math.max(0, ownerDim.height - layoutDim.height - 5);
    PopupFactory factory = PopupFactory.getSharedInstance();
    Popup popup = factory.getPopup(canvasPane.getViewport(), layout, x, y);
    popup.show();
    curPopup = popup;
    curPopupTime = System.currentTimeMillis();
  }
Esempio n. 15
0
 public PopupComponent getPopup(Component owner, Component content, int x, int y) {
   return new AwtPopupWrapper(PopupFactory.getSharedInstance().getPopup(owner, content, x, y));
 }