private void maybeShowFor(Component c, MouseEvent me) {
    if (!(c instanceof JComponent)) return;

    JComponent comp = (JComponent) c;
    Window wnd = SwingUtilities.getWindowAncestor(comp);
    if (wnd == null) return;

    if (!wnd.isActive()) {
      if (JBPopupFactory.getInstance().isChildPopupFocused(wnd)) return;
    }

    String tooltipText = comp.getToolTipText(me);
    if (tooltipText == null || tooltipText.trim().isEmpty()) return;

    boolean centerDefault =
        Boolean.TRUE.equals(comp.getClientProperty(UIUtil.CENTER_TOOLTIP_DEFAULT));
    boolean centerStrict =
        Boolean.TRUE.equals(comp.getClientProperty(UIUtil.CENTER_TOOLTIP_STRICT));
    int shift = centerStrict ? 0 : centerDefault ? 4 : 0;

    // Balloon may appear exactly above useful content, such behavior is rather annoying.
    if (c instanceof JTree) {
      TreePath path = ((JTree) c).getClosestPathForLocation(me.getX(), me.getY());
      if (path != null) {
        Rectangle pathBounds = ((JTree) c).getPathBounds(path);
        if (pathBounds != null && pathBounds.y + 4 < me.getY()) {
          shift += me.getY() - pathBounds.y - 4;
        }
      }
    }

    queueShow(comp, me, centerStrict || centerDefault, shift, -shift, -shift);
  }
예제 #2
0
  public static int getRoundedInteriorCorner(JComponent c) {
    if (!(c.getBorder() instanceof PBorder) && !(c.getBorder() instanceof PRoundBorder)) {
      return 0;
    }

    int h = c.getHeight() - (getBorderSize(c) * 2);
    int roundCorner = h;

    String ctype = (String) c.getClientProperty("JComponent.type");
    if (ctype != null) {
      if (ctype.equals("roundRect")) {
        return roundCorner;
      } else if (ctype.equals("square")) {
        return 0;
      } else if (ctype.equals("normal")) {
        return DEFAULT_ROUND_CORNER;
      }
    }

    Integer maxRoundCorner = (Integer) c.getClientProperty("maxRoundCorner");
    if (maxRoundCorner != null && maxRoundCorner >= 0) {
      roundCorner = Math.min(roundCorner, maxRoundCorner);
    }
    return roundCorner;
  }
예제 #3
0
  /**
   * Fill Background with Color. (Ususlly called from update methods)
   *
   * @param g2D Graphics
   * @param c Component
   * @param round paint round corners
   */
  public static void fillRectange(Graphics2D g2D, JComponent c, boolean round) {
    //  Paint in AdempiereColor?
    CompiereColor cc = null;
    boolean stdCC = c.getClientProperty(CompiereLookAndFeel.BACKGROUND_FILL) != null;
    try {
      cc = (CompiereColor) c.getClientProperty(CompiereLookAndFeel.BACKGROUND);
    } catch (Exception e) {
      stdCC = true;
    }
    if (stdCC) cc = CompiereColor.getDefaultBackground();

    //  Paint AdempiereColor
    if (cc != null) {
      //  bounds is often not within Panel bouunds
      cc.paint(g2D, c);
    }
    //  Paint Flat Color
    else {
      Paint paint = c.getBackground();
      g2D.setPaint(paint);
      //
      RectangularShape rec = null;
      if (round) rec = new RoundRectangle2D.Float(0, 0, c.getWidth(), c.getHeight(), 15, 15);
      else rec = new Rectangle(0, 0, c.getWidth(), c.getHeight());
      g2D.fill(rec);
    }
  } //  fill Rectangle
예제 #4
0
  @Override
  public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
    JComponent popup = (JComponent) c;
    g.translate(x, y);
    try {
      this.bottomLeft = (Image) popup.getClientProperty(RoundedPopupFactory.BOTTOM_LEFT_PIC);
      if (this.bottomLeft != null) {
        g.drawImage(this.bottomLeft, 0, h - 5, c);
      }

      this.bottomRight = (Image) popup.getClientProperty(RoundedPopupFactory.BOTTOM_RIGHT_PIC);
      if (this.bottomRight != null) {
        g.drawImage(this.bottomRight, w - 5, h - 5, c);
      }

      this.right = (Image) popup.getClientProperty(RoundedPopupFactory.RIGHT_PIC);
      if (this.right != null) {
        g.drawImage(this.right, w - 1, 0, c);
      }

      this.bottom = (Image) popup.getClientProperty(RoundedPopupFactory.BOTTOM_PIC);
      if (this.bottom != null) {
        g.drawImage(this.bottom, 5, h - 1, c);
      }
    } catch (Exception exp) {
      // do nothing
    }

    if (ShadowedPopupMenuBorder.POPUP_BOTTOM_LEFT != null)
      g.drawImage(ShadowedPopupMenuBorder.POPUP_BOTTOM_LEFT, 0, h - 5, popup);
    if (ShadowedPopupMenuBorder.POPUP_BOTTOM_RIGHT != null)
      g.drawImage(ShadowedPopupMenuBorder.POPUP_BOTTOM_RIGHT, w - 5, h - 5, popup);

    ColorUIResource c1 = new ColorUIResource(150, 150, 150);
    Color c4 = new Color(160, 160, 160, 100);
    ColorUIResource c2 = new ColorUIResource(135, 135, 135);

    g.setColor(UIManager.getColor("MenuItem.background"));
    g.drawLine(1, 0, w - 4, 0);
    g.drawLine(1, 1, w - 4, 1);
    g.drawLine(1, 0, 1, h - 7);
    g.drawLine(5, h - 3, w - 6, h - 3);
    g.setColor(UIManager.getColor("MenuItem.fadingColor"));
    g.drawLine(w - 3, 2, w - 3, h - 5);

    g.setColor(c1);
    g.drawLine(0, 0, 0, h - 6);
    g.setColor(c4);
    g.drawLine(5, h - 1, w - 6, h - 1);
    g.drawLine(w - 1, 2, w - 1, h - 6);

    g.setColor(c2);
    g.drawLine(w - 2, 0, w - 2, h - 6);
    g.drawLine(5, h - 2, w - 6, h - 2);

    g.translate(-x, -y);
  }
예제 #5
0
  /**
   * This looks at the client property VERTICAL_POSITION to return on the constants in this class
   * (POS_TOP, POS_MIDDLE, POS_BOTTOM or POS_ONLY).
   *
   * <p>This returns POS_ONLY if a shape is defined, because in this context a position doesn't make
   * sense.
   */
  protected static int getVerticalPosition(JComponent b) {
    if (b == null) return POS_ONLY;

    Shape shape = (Shape) b.getClientProperty(SHAPE);
    if (shape != null) {
      return POS_ONLY;
    }

    String s = (String) b.getClientProperty(VERTICAL_POSITION);
    if (s == null) s = "only";
    if (s.equalsIgnoreCase("top")) return POS_TOP;
    if (s.equalsIgnoreCase("middle")) return POS_MIDDLE;
    if (s.equalsIgnoreCase("bottom")) return POS_BOTTOM;
    return POS_ONLY;
  }
 private IBrowserComponent getActivePage() {
   JComponent activeComponent = (JComponent) myComponent.getSelectedComponent();
   if (activeComponent == null) {
     return null;
   }
   return (IBrowserComponent) activeComponent.getClientProperty(this);
 }
예제 #7
0
  /**
   * This looks at the client properties "JButton.segmentPosition" and HORIZONTAL_POSITION to return
   * on the constants in this class (LEFT_POS, POS_MIDDLE, RIGHT_POS or POS_ONLY).
   *
   * <p>This returns POS_ONLY if a shape is defined, because in this context a position doesn't make
   * sense.
   */
  protected static int getHorizontalPosition(JComponent b) {
    if (b == null) return POS_ONLY;

    Shape shape = (Shape) b.getClientProperty(SHAPE);
    if (shape != null) {
      return POS_ONLY;
    }

    String s = (String) b.getClientProperty("JButton.segmentPosition");
    if (s == null) s = (String) b.getClientProperty(HORIZONTAL_POSITION);
    if (s == null) s = "only";
    if (s.equalsIgnoreCase("first") || s.equalsIgnoreCase("left")) return POS_LEFT;
    if (s.equalsIgnoreCase("middle")) return POS_MIDDLE;
    if (s.equalsIgnoreCase("last") || s.equalsIgnoreCase("right")) return POS_RIGHT;
    return POS_ONLY;
  }
예제 #8
0
  public void paint(Graphics g, JComponent c) {
    AbstractButton b = (AbstractButton) c;
    ButtonModel model = b.getModel();

    String text = layout(b, SwingUtilities2.getFontMetrics(b, g), b.getWidth(), b.getHeight());

    clearTextShiftOffset();

    // perform UI specific press action, e.g. Windows L&F shifts text
    if (model.isArmed() && model.isPressed()) {
      paintButtonPressed(g, b);
    }

    // Paint the Icon
    if (b.getIcon() != null) {
      paintIcon(g, c, iconRect);
    }

    if (text != null && !text.equals("")) {
      View v = (View) c.getClientProperty(BasicHTML.propertyKey);
      if (v != null) {
        v.paint(g, textRect);
      } else {
        paintText(g, b, textRect, text);
      }
    }

    if (b.isFocusPainted() && b.hasFocus()) {
      // paint UI specific focus
      paintFocus(g, b, viewRect, textRect, iconRect);
    }
  }
  private void assertTabCount(Content content) {
    //        PluginSettingsBean bean = (PluginSettingsBean)
    // SharedObjectPool.getUserData(SharedConstants.PLUGIN_SETTINGS);
    PluginSettingsBean bean = PluginKeys.PLUGIN_SETTINGS.getData();

    if (bean == null) {
      bean = new PluginSettingsBean();
    }

    int max = bean.getNumberOfTabs();

    if (max <= getTabComponent(content).getTabCount()) {
      // remove the oldest tab
      JTabbedPane tabbedPane = getTabComponent(content);
      long lastMin = Long.MAX_VALUE;
      int index = 0;
      for (int i = 0; i < tabbedPane.getTabCount(); i++) {
        JComponent tab = (JComponent) tabbedPane.getTabComponentAt(i);
        Long time = (Long) tab.getClientProperty(CREATE_TIME);
        if (time != null && lastMin < time) {
          lastMin = time;
          index = i;
        }
      }

      tabbedPane.remove(index);
    }
  }
  public void paint(Graphics g, JComponent c) {
    if (Boolean.FALSE.equals(c.getClientProperty("roundedCorners"))) paintSquare(g, c);
    else paintRounded(g, c);

    KCollapsiblePane pane =
        (KCollapsiblePane) c.getClientProperty(KCollapsiblePane.HEADER_UI_PROPERTY_OWNER_PANE);
    if (pane != null) {
      Rectangle bounds = c.getBounds();
      Icon arrowIcon = pane.isExpanded() ? arrowExpandedIcon : arrowCollapsedIcon;
      arrowIcon.paintIcon(
          c,
          g,
          bounds.width - arrowIcon.getIconWidth(),
          (bounds.height - arrowIcon.getIconWidth()) / 2);
    }
  }
예제 #11
0
 /**
  * Print Oarent of Component
  *
  * @param c component
  */
 static void printParents(JComponent c) {
   if (c.getName() == null) c.setName("C" + String.valueOf(s_no++));
   System.out.print(c.getName());
   System.out.print(" - " + c.getClass().getName());
   System.out.println(
       " ** "
           + c.isOpaque()
           + " bg="
           + (c.getClientProperty(CompiereLookAndFeel.BACKGROUND) != null));
   //
   Container container = c.getParent();
   while (container != null) {
     System.out.print(
         " - "
             + container.getName()
             + " "
             + container.getClass().getName()
             + " ** "
             + container.isOpaque());
     if (container instanceof JComponent)
       System.out.print(
           " bg="
               + (((JComponent) container).getClientProperty(CompiereLookAndFeel.BACKGROUND)
                   != null));
     System.out.println();
     container = container.getParent();
   }
 } //  printParents
예제 #12
0
 public static boolean hasActiveSpeedSearch(JComponent component) {
   SpeedSearchBase speedSearch =
       (SpeedSearchBase) component.getClientProperty(SPEED_SEARCH_COMPONENT_MARKER);
   return speedSearch != null
       && speedSearch.mySearchPopup != null
       && speedSearch.mySearchPopup.isVisible();
 }
 @Override
 public Dimension getMinimumSize(JComponent c) {
   AbstractButton b = (AbstractButton) c;
   String style = (String) c.getClientProperty("Quaqua.Button.style");
   if (style == null) {
     style = "push";
   }
   if (style.equals("help")) {
     return getPreferredSize(c);
   }
   Dimension d = super.getMinimumSize(c);
   if (isFixedHeight(c)) {
     Dimension p = getPreferredSize(c);
     if (d != null && p != null) {
       d.height = Math.max(d.height, p.height);
     }
   }
   if (!QuaquaUtilities.isSmallSizeVariant(c)
       && style.equals("push") //
       && b.getIcon() == null
       && b.getText() != null) {
     if (d != null) {
       d.width = Math.max(d.width, UIManager.getInt("Button.minimumWidth"));
     }
   }
   return d;
 }
예제 #14
0
 public Dimension getMaximumSize(JComponent c) {
   Dimension d = getPreferredSize(c);
   View v = (View) c.getClientProperty(BasicHTML.propertyKey);
   if (v != null) {
     d.width += v.getMaximumSpan(View.X_AXIS) - v.getPreferredSpan(View.X_AXIS);
   }
   return d;
 }
 private synchronized State getState(JComponent component, Part part) {
   State rv = null;
   Object tmpObject = component.getClientProperty(PartUIClientPropertyKey.getKey(part));
   if (tmpObject instanceof State) {
     rv = (State) tmpObject;
   }
   return rv;
 }
예제 #16
0
 private Insets getVisualMargin(JComponent component) {
   String uid = component.getUIClassID();
   String style = null;
   if (uid == "ButtonUI" || uid == "ToggleButtonUI") {
     style = (String) component.getClientProperty("JButton.buttonType");
   } else if (uid == "ProgressBarUI") {
     style =
         (((JProgressBar) component).getOrientation() == JProgressBar.HORIZONTAL)
             ? "horizontal"
             : "vertical";
   } else if (uid == "SliderUI") {
     style =
         (((JSlider) component).getOrientation() == JProgressBar.HORIZONTAL)
             ? "horizontal"
             : "vertical";
   } else if (uid == "TabbedPaneUI") {
     switch (((JTabbedPane) component).getTabPlacement()) {
       case JTabbedPane.TOP:
         style = "top";
         break;
       case JTabbedPane.LEFT:
         style = "left";
         break;
       case JTabbedPane.BOTTOM:
         style = "bottom";
         break;
       case JTabbedPane.RIGHT:
         style = "right";
         break;
     }
   }
   Insets gap = getInsets(VISUAL_MARGINS, uid, style, 0);
   // Take into account different positions of the button icon
   if (uid == "RadioButtonUI" || uid == "CheckBoxUI") {
     switch (((AbstractButton) component).getHorizontalTextPosition()) {
       case SwingConstants.RIGHT:
         gap = new Insets(gap.top, gap.right, gap.bottom, gap.left);
         break;
       case SwingConstants.CENTER:
         gap = new Insets(gap.top, gap.right, gap.bottom, gap.right);
         break;
         /*
         case SwingConstants.LEFT :
             break;
              */
       default:
         gap = new Insets(gap.top, gap.left, gap.bottom, gap.right);
     }
     if (component.getBorder() instanceof EmptyBorder) {
       gap.left -= 2;
       gap.right -= 2;
       gap.top -= 2;
       gap.bottom -= 2;
     }
   }
   return gap;
 }
예제 #17
0
 /* (non-Javadoc)
  * @see org.jajuk.ui.actions.JajukAction#perform(java.awt.event.ActionEvent)
  */
 @Override
 @SuppressWarnings("unchecked")
 public void perform(ActionEvent e) {
   JComponent source = (JComponent) e.getSource();
   List<Item> alSelected = (List<Item>) source.getClientProperty(Const.DETAIL_SELECTION);
   ItemMoveManager.getInstance().removeAll();
   ItemMoveManager.getInstance().addItems(alSelected);
   ItemMoveManager.getInstance().setAction(ItemMoveManager.MoveActions.COPY);
 }
예제 #18
0
 public void update(Graphics g, JComponent c) {
   if (c.isOpaque()
       && c.getBackground() instanceof ColorUIResource
       && c.getClientProperty("backgroundTexture") == null) {
     AluminiumUtils.fillComponent(g, c);
   } else {
     super.update(g, c);
   }
 }
예제 #19
0
 /**
  * Checks whether the specified component or one of its ancestors has the specified client
  * property set to {@link Boolean#TRUE}.
  *
  * @param c Component.
  * @param clientPropName Client property name.
  * @return <code>true</code> if the specified component or one of its ancestors has the
  *     specified client property set to {@link Boolean#TRUE}, <code>false</code> otherwise.
  */
 private boolean hasClientPropertySetToTrue(Component c, String clientPropName) {
   while (c != null) {
     if (c instanceof JComponent) {
       JComponent jc = (JComponent) c;
       if (Boolean.TRUE.equals(jc.getClientProperty(clientPropName))) return true;
     }
     c = c.getParent();
   }
   return false;
 }
예제 #20
0
  public static int getRoundedExteriorCorner(JComponent c) {
    int roundCorner = c.getHeight() - 1;
    String ctype = (String) c.getClientProperty("JComponent.type");
    if (ctype != null) {
      if (ctype.equals("roundRect")) {
        return roundCorner;
      } else if (ctype.equals("square")) {
        return 0;
      } else if (ctype.equals("normal")) {
        return DEFAULT_ROUND_CORNER;
      }
    }

    Integer maxRoundCorner = (Integer) c.getClientProperty("maxRoundCorner");
    if (maxRoundCorner != null && maxRoundCorner >= 0) {
      roundCorner = Math.min(roundCorner, maxRoundCorner);
    }
    return roundCorner;
  }
예제 #21
0
 protected void installDefaults() {
   // Installs the text cursor on the component
   super.installDefaults();
   JComponent c = getComponent();
   Object clientProperty = c.getClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES);
   if (clientProperty == null || clientProperty == localFalse) {
     c.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, localTrue);
   }
   updateStyle((JTextComponent) getComponent());
 }
  @Nullable
  private Editor validateCurrentEditor() {
    Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
    if (focusOwner instanceof JComponent) {
      final JComponent jComponent = (JComponent) focusOwner;
      if (jComponent.getClientProperty("AuxEditorComponent") != null)
        return null; // Hack for EditorSearchComponent
    }

    return myEditor;
  }
예제 #23
0
파일: TMSchema.java 프로젝트: erdrix/GameC
 public String getControlName(Component component) {
   String str = "";
   if (component instanceof JComponent) {
     JComponent c = (JComponent) component;
     String subAppName = (String) c.getClientProperty("XPStyle.subAppName");
     if (subAppName != null) {
       str = subAppName + "::";
     }
   }
   return str + control.toString();
 }
  /**
   * Create PLAF
   *
   * @param c Component which need the UI
   * @return UI
   */
  public static ComponentUI createUI(JComponent c) {
    Object style = c.getClientProperty(ELFStyle.KEY);
    if (ELFStyle.TOGGLE_BUTTON_STONE == style) {
      return ButtonUiFactory.STONE_UI_SMALL;
    }
    if (ELFStyle.BUTTON_MENU == style) {
      return ButtonUiFactory.MENU_UI;
    }

    return FORWARD.create(c);
  }
예제 #25
0
  public static RoundRectangle2D getExternalPaintableShape(JComponent c) {
    int x = 0, y = 0;
    int w = c.getWidth() - 1, h = c.getHeight() - 1;
    int roundCorner = h;
    Integer maxRoundCorner = (Integer) c.getClientProperty("maxRoundCorner");
    if (maxRoundCorner != null && maxRoundCorner >= 0) {
      roundCorner = Math.min(roundCorner, maxRoundCorner);
    }

    return new RoundRectangle2D.Double(x, y, w, h, roundCorner, roundCorner);
  }
예제 #26
0
  /** Installs the UI delegate for the specified component */
  public void installUI(JComponent c) {
    super.installUI(c);

    Object paletteProp = c.getClientProperty(IS_PALETTE);
    if (paletteProp != null) {
      setPalette(((Boolean) paletteProp).booleanValue());
    }

    Container content = frame.getContentPane();
    stripContentBorder(content);
    // c.setOpaque(false);
  }
예제 #27
0
  private Insets getPreferredGap(JComponent component, int type, int sizeStyle) {
    Map gapMap;

    switch (type) {
      case INDENT:
        gapMap = INDENT_GAPS;
        break;
      case RELATED:
        gapMap = RELATED_GAPS;
        break;
      case UNRELATED:
      default:
        gapMap = UNRELATED_GAPS;
        break;
    }

    String uid = component.getUIClassID();
    String style = null;
    // == is ok here as Strings from Swing get interned, if for some reason
    // need .equals then must deal with null.
    if (uid == "ButtonUI" || uid == "ToggleButtonUI") {
      style = (String) component.getClientProperty("JButton.buttonType");
    } else if (uid == "ProgressBarUI") {
      style =
          (((JProgressBar) component).getOrientation() == JProgressBar.HORIZONTAL)
              ? "horizontal"
              : "vertical";
    } else if (uid == "SliderUI") {
      style =
          (((JSlider) component).getOrientation() == JProgressBar.HORIZONTAL)
              ? "horizontal"
              : "vertical";
    } else if (uid == "TabbedPaneUI") {
      switch (((JTabbedPane) component).getTabPlacement()) {
        case JTabbedPane.TOP:
          style = "top";
          break;
        case JTabbedPane.LEFT:
          style = "left";
          break;
        case JTabbedPane.BOTTOM:
          style = "bottom";
          break;
        case JTabbedPane.RIGHT:
          style = "right";
          break;
      }
    } else if (uid == "ComboBoxUI") {
      style = ((JComboBox) component).isEditable() ? "editable" : "uneditable";
    }
    return getInsets(gapMap, uid, style, sizeStyle);
  }
예제 #28
0
  // installs a private instance of GestureHandler, if necessary
  static void addGestureListenerTo(final JComponent component, final GestureListener listener) {
    final Object value = component.getClientProperty(CLIENT_PROPERTY);
    if (value instanceof GestureHandler) {
      ((GestureHandler) value).addListener(listener);
      return;
    }

    if (value != null) return; // some other garbage is in our client property

    final GestureHandler newHandler = new GestureHandler();
    newHandler.addListener(listener);
    component.putClientProperty(CLIENT_PROPERTY, newHandler);
  }
예제 #29
0
  protected void deleteCurrentPanel() {
    JComponent tabPane = (JComponent) tabbedPane.getSelectedComponent();
    if (tabPane == null) return;

    WMSPanel wmsPanel = (WMSPanel) tabPane.getClientProperty(Constants.FEATURE_OWNER_PROPERTY);

    if (tabbedPane.getTabCount()
        > 2) // actually remove the tab only if there is more than one (plus the "+" tab)
    tabbedPane.remove(tabPane);
    else tabbedPane.setTitleAt(1, "New Server");

    if (wmsPanel != null) wmsPanel.clearPanel();
  }
예제 #30
0
  private void checkSolution() {

    ArrayList<Point> current = new ArrayList<>();

    for (JComponent btn : buttons) {
      current.add((Point) btn.getClientProperty("position"));
    }

    if (compareList(solution, current)) {
      JOptionPane.showMessageDialog(
          panel, "Finished", "Congratulation", JOptionPane.INFORMATION_MESSAGE);
    }
  }