private InputMap getInputMap(int condition) {
   if (condition == JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) {
     return (InputMap) UIManager.get("Grid.ancestorInputMap");
   } else {
     return null;
   }
 }
  @SuppressWarnings("HardCodedStringLiteral")
  private boolean togglePopup(KeyEvent e) {
    final KeyStroke stroke = KeyStroke.getKeyStroke(e.getKeyCode(), e.getModifiers());
    final Object action = ((InputMap) UIManager.get("ComboBox.ancestorInputMap")).get(stroke);
    if ("selectNext".equals(action)) {
      if (!isPopupShowing()) {
        return true;
      } else {
        return false;
      }
    } else if ("togglePopup".equals(action)) {
      if (isPopupShowing()) {
        closePopup();
      } else {
        suggestCompletion(true, true);
      }
      return true;
    } else {
      final Keymap active = KeymapManager.getInstance().getActiveKeymap();
      final String[] ids = active.getActionIds(stroke);
      if (ids.length > 0 && IdeActions.ACTION_CODE_COMPLETION.equals(ids[0])) {
        suggestCompletion(true, true);
      }
    }

    return false;
  }
Ejemplo n.º 3
0
 /*
  * (non-Javadoc)
  *
  * @see javax.swing.JPanel#updateUI()
  */
 @Override
 public void updateUI() {
   if (UIManager.get(getUIClassID()) != null) {
     setUI((BandControlPanelUI) UIManager.getUI(this));
   } else {
     setUI(new BasicFlowBandControlPanelUI());
   }
 }
Ejemplo n.º 4
0
  @Nullable
  private static Icon getAquaMenuDisabledIcon() {
    final Icon arrowIcon = (Icon) UIManager.get("Menu.arrowIcon");
    if (arrowIcon != null) {
      return IconLoader.getDisabledIcon(arrowIcon);
    }

    return null;
  }
Ejemplo n.º 5
0
  /** Gets the GUI component for this pane. */
  public JComponent getGUI() {
    if (cwp == null) {
      Object object = mWhiteBoard.get("device_definition");
      Object ctx_obj = mWhiteBoard.get("context");

      if (null != object
          && object instanceof ConfigDefinition
          && null != ctx_obj
          && ctx_obj instanceof ConfigContext) {
        mConfigContext = (ConfigContext) ctx_obj;

        ConfigDefinition def = (ConfigDefinition) object;
        String token = def.getToken();

        // Create a temporary list of ConfigDefinitions to pass to factory.
        java.util.List def_list = new ArrayList();
        def_list.add(def);

        // Initialize a ConfigElementFactory with the needed
        // ConfigDefinition. And create a new ConfigElement.
        ConfigElementFactory temp_factory = new ConfigElementFactory(def_list);
        mConfigElement = temp_factory.create("New " + token, def);

        List list = CustomEditorRegistry.findEditors(token);

        Color start_color = new Color(160, 160, 180);

        Object color = UIManager.get("window");
        if (null != color && color instanceof Color) {
          start_color = (Color) color;
        } else {
          System.out.println("Could not get the desktop color from the  UIManager.");
        }

        // XXX:This will be used after making findEditors -> findEditor
        // if(null != editor)
        if (null == list || list.size() == 0) {
          System.out.println("No CustomEditors registered for token: " + token);

          JScrollPane scroll_pane = new JScrollPane();
          PropertySheet element_prop_sheet =
              PropertySheetFactory.instance()
                  .makeSheet(mConfigContext, mConfigElement, start_color);

          scroll_pane.getViewport().removeAll();
          scroll_pane.getViewport().add(element_prop_sheet, null);
          cwp = scroll_pane;
        } else if (null != list && list.size() > 0) {
          CustomEditor editor = (CustomEditor) list.get(0);
          cwp = (JComponent) editor.getPanel();
          editor.setConfig(mConfigContext, mConfigElement);
        }
      }
    }
    // cwp.init(mWhiteBoard);
    return cwp;
  }
 private ActionMap getActionMap() {
   ActionMap actionMap = (ActionMap) UIManager.get("Grid.actionMap");
   if (actionMap == null) {
     actionMap = createActionMap();
     if (actionMap != null) {
       UIManager.put("Grid.actionMap", actionMap);
     }
   }
   return actionMap;
 }
Ejemplo n.º 7
0
 static Icon getOceanDisabledButtonIcon(Image image) {
   Object[] range = (Object[]) UIManager.get("Button.disabledGrayRange");
   int min = 180;
   int max = 215;
   if (range != null) {
     min = ((Integer) range[0]).intValue();
     max = ((Integer) range[1]).intValue();
   }
   ImageProducer prod =
       new FilteredImageSource(image.getSource(), new OceanDisabledButtonImageFilter(min, max));
   return new ImageIconUIResource(Toolkit.getDefaultToolkit().createImage(prod));
 }
 protected void installDefaults() {
   Color defaultGridColor = UIManager.getColor("Table.gridColor");
   Color defaultForegroundColor = UIManager.getColor("Table.foreground");
   Color defaultBackgroundColor = UIManager.getColor("Table.background");
   Border defaultBorder = UIManager.getBorder("Table.scrollPaneBorder");
   Color defaultSelectionForeground = UIManager.getColor("Table.selectionForeground");
   Color defaultSelectionBackground = UIManager.getColor("Table.selectionBackground");
   Color defaultFocusCellForeground = UIManager.getColor("Table.focusCellForeground");
   Color defaultFocusCellBackground = new Color(153, 153, 204);
   Font defaultFont = UIManager.getFont("Table.font");
   Border defaultGridBorder = UIManager.getBorder("Table.border");
   InputMap inputMap = (InputMap) UIManager.get("Table.ancestorInputMap");
   if (!installed) {
     UIManager.getDefaults().put("Grid.gridColor", defaultGridColor);
     UIManager.getDefaults().put("Grid.foreground", defaultForegroundColor);
     UIManager.getDefaults().put("Grid.background", defaultBackgroundColor);
     UIManager.getDefaults().put("Grid.selectionForegroundColor", defaultSelectionForeground);
     UIManager.getDefaults().put("Grid.selectionBackgroundColor", defaultSelectionBackground);
     UIManager.getDefaults().put("Grid.focusForegroundColor", defaultFocusCellForeground);
     UIManager.getDefaults().put("Grid.focusBackgroundColor", defaultFocusCellBackground);
     UIManager.getDefaults().put("Grid.border", defaultGridBorder);
     UIManager.getDefaults().put("Grid.font", defaultFont);
     UIManager.getDefaults().put("Grid.scrollPaneBorder", defaultBorder);
     UIManager.getDefaults().put("Grid.ancestorInputMap", inputMap);
     installed = true;
   }
   Color foregroundColor = grid.getForeground();
   Color backgroundColor = grid.getBackground();
   Font font = grid.getFont();
   Border border = grid.getBorder();
   Color gridColor = grid.getGridColor();
   Color selectionForeground = grid.getSelectionForegroundColor();
   Color selectionBackground = grid.getSelectionBackgroundColor();
   Color focusForeground = grid.getFocusForegroundColor();
   Color focusBackground = grid.getFocusBackgroundColor();
   if (foregroundColor == null || foregroundColor instanceof UIResource)
     grid.setForeground(defaultForegroundColor);
   if (backgroundColor == null || backgroundColor instanceof UIResource)
     grid.setBackground(defaultBackgroundColor);
   if (font == null || font instanceof UIResource) grid.setFont(defaultFont);
   if (gridColor == null || gridColor instanceof UIResource) grid.setGridColor(defaultGridColor);
   if (border == null || border instanceof UIResource) grid.setBorder(defaultGridBorder);
   if (selectionForeground == null || selectionForeground instanceof UIResource)
     grid.setSelectionForegroundColor(defaultSelectionForeground);
   if (selectionBackground == null || selectionBackground instanceof UIResource)
     grid.setSelectionBackgroundColor(defaultSelectionBackground);
   if (focusForeground == null || focusForeground instanceof UIResource)
     grid.setFocusForegroundColor(defaultFocusCellForeground);
   if (focusBackground == null || focusBackground instanceof UIResource)
     grid.setFocusBackgroundColor(defaultFocusCellBackground);
 }
Ejemplo n.º 9
0
  /**
   * Draws a radial type gradient. The gradient will be drawn vertically if <code>vertical</code> is
   * true, otherwise horizontally. The UIManager key consists of five values: r1 r2 c1 c2 c3. The
   * gradient is broken down into four chunks drawn in order from the origin.
   *
   * <ol>
   *   <li>Gradient r1 % of the size from c1 to c2
   *   <li>Rectangle r2 % of the size in c2.
   *   <li>Gradient r1 % of the size from c2 to c1
   *   <li>The remaining size will be filled with a gradient from c1 to c3.
   * </ol>
   *
   * @param c Component rendering to
   * @param g Graphics to draw to.
   * @param key UIManager key used to look up gradient values.
   * @param x X coordinate to draw from
   * @param y Y coordinate to draw from
   * @param w Width to draw to
   * @param h Height to draw to
   * @param vertical Direction of the gradient
   * @return true if <code>key</code> exists, otherwise false.
   */
  static boolean drawGradient(
      Component c, Graphics g, String key, int x, int y, int w, int h, boolean vertical) {
    java.util.List gradient = (java.util.List) UIManager.get(key);
    if (gradient == null || !(g instanceof Graphics2D)) {
      return false;
    }

    if (w <= 0 || h <= 0) {
      return true;
    }

    GradientPainter.INSTANCE.paint(c, (Graphics2D) g, gradient, x, y, w, h, vertical);
    return true;
  }
Ejemplo n.º 10
0
  static int getInt(Object key, int defaultValue) {
    Object value = UIManager.get(key);

    if (value instanceof Integer) {
      return ((Integer) value).intValue();
    }
    if (value instanceof String) {
      try {
        return Integer.parseInt((String) value);
      } catch (NumberFormatException nfe) {
      }
    }
    return defaultValue;
  }
Ejemplo n.º 11
0
  @Nullable
  private static Icon getAquaMenuInvertedIcon() {
    if (!UIUtil.isUnderAquaLookAndFeel()) return null;
    final Icon arrow = (Icon) UIManager.get("Menu.arrowIcon");
    if (arrow == null) return null;

    try {
      final Method method = ReflectionUtil.getMethod(arrow.getClass(), "getInvertedIcon");
      if (method != null) {
        return (Icon) method.invoke(arrow);
      }
      return null;
    } catch (InvocationTargetException e1) {
      return null;
    } catch (IllegalAccessException e1) {
      return null;
    }
  }
Ejemplo n.º 12
0
  @Override
  public Object get(SynthContext context, Object key) {
    // See if this is a class specific value.
    String classKey = CLASS_SPECIFIC_MAP.get(key);
    if (classKey != null) {
      Object value = getClassSpecificValue(classKey);
      if (value != null) {
        return value;
      }
    }

    // Is it a specific value ?
    if (key == "ScrollPane.viewportBorderInsets") {
      return getThicknessInsets(context, new Insets(0, 0, 0, 0));
    } else if (key == "Slider.tickColor") {
      return getColorForState(context, ColorType.FOREGROUND);
    } else if (key == "ScrollBar.minimumThumbSize") {
      int len = getClassSpecificIntValue(context, "min-slider-length", 21);
      JScrollBar sb = (JScrollBar) context.getComponent();
      if (sb.getOrientation() == JScrollBar.HORIZONTAL) {
        return new DimensionUIResource(len, 0);
      } else {
        return new DimensionUIResource(0, len);
      }
    } else if (key == "Separator.thickness") {
      JSeparator sep = (JSeparator) context.getComponent();
      if (sep.getOrientation() == JSeparator.HORIZONTAL) {
        return getYThickness();
      } else {
        return getXThickness();
      }
    } else if (key == "ToolBar.separatorSize") {
      int size = getClassSpecificIntValue(WidgetType.TOOL_BAR, "space-size", 12);
      return new DimensionUIResource(size, size);
    } else if (key == "ScrollBar.buttonSize") {
      JScrollBar sb = (JScrollBar) context.getComponent().getParent();
      boolean horiz = (sb.getOrientation() == JScrollBar.HORIZONTAL);
      WidgetType wt = horiz ? WidgetType.HSCROLL_BAR : WidgetType.VSCROLL_BAR;
      int sliderWidth = getClassSpecificIntValue(wt, "slider-width", 14);
      int stepperSize = getClassSpecificIntValue(wt, "stepper-size", 14);
      return horiz
          ? new DimensionUIResource(stepperSize, sliderWidth)
          : new DimensionUIResource(sliderWidth, stepperSize);
    } else if (key == "ArrowButton.size") {
      String name = context.getComponent().getName();
      if (name != null && name.startsWith("Spinner")) {
        // Believe it or not, the size of a spinner arrow button is
        // dependent upon the size of the spinner's font.  These
        // calculations come from gtkspinbutton.c (version 2.8.20),
        // spin_button_get_arrow_size() method.
        String pangoFontName;
        synchronized (sun.awt.UNIXToolkit.GTK_LOCK) {
          pangoFontName = nativeGetPangoFontName(WidgetType.SPINNER.ordinal());
        }
        int arrowSize = (pangoFontName != null) ? PangoFonts.getFontSize(pangoFontName) : 10;
        return (arrowSize + (getXThickness() * 2));
      }
      // For all other kinds of arrow buttons (e.g. combobox arrow
      // buttons), we will simply fall back on the value of
      // ArrowButton.size as defined in the UIDefaults for
      // GTKLookAndFeel when we call UIManager.get() below...
    } else if ("CheckBox.iconTextGap".equals(key) || "RadioButton.iconTextGap".equals(key)) {
      // The iconTextGap value needs to include "indicator-spacing"
      // and it also needs to leave enough space for the focus line,
      // which falls between the indicator icon and the text.
      // See getRadioInsets() and 6489585 for more details.
      int indicatorSpacing = getClassSpecificIntValue(context, "indicator-spacing", 2);
      int focusSize = getClassSpecificIntValue(context, "focus-line-width", 1);
      int focusPad = getClassSpecificIntValue(context, "focus-padding", 1);
      return indicatorSpacing + focusSize + focusPad;
    }

    // Is it a stock icon ?
    GTKStockIcon stockIcon = null;
    synchronized (ICONS_MAP) {
      stockIcon = ICONS_MAP.get(key);
    }

    if (stockIcon != null) {
      return stockIcon;
    }

    // Is it another kind of value ?
    if (key != "engine") {
      // For backward compatibility we'll fallback to the UIManager.
      // We don't go to the UIManager for engine as the engine is GTK
      // specific.
      Object value = UIManager.get(key);
      if (key == "Table.rowHeight") {
        int focusLineWidth = getClassSpecificIntValue(context, "focus-line-width", 0);
        if (value == null && focusLineWidth > 0) {
          value = Integer.valueOf(16 + 2 * focusLineWidth);
        }
      }
      return value;
    }

    // Don't call super, we don't want to pick up defaults from
    // SynthStyle.
    return null;
  }
Ejemplo n.º 13
0
 public void updateUI() {
   if (UIManager.get(getUIClassID()) != null) setUI((ZPopupGalleryUI) UIManager.getUI(this));
   else setUI(new FSXPPopupGalleryUI());
 }