/** {@inheritDoc} */
  public Component getListCellRendererComponent(
      JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
    if (value instanceof IBooleanPM == false) {
      return null;
    }
    model = (IBooleanPM) value;
    Boolean bvalue = false;
    if (model.getBoolean() != null) {
      bvalue = model.getBoolean();
    }
    cb.setSelected(bvalue);

    if (isNimbus()) { // one more work around
      if (rendererComponent != null) {
        rendererComponent.setBackground(null);
      }
      rendererComponent =
          (JComponent)
              defaultRenderer.getListCellRendererComponent(
                  list, "", index, isSelected, cellHasFocus);
      if (isSelected == false && index % 2 != 0) {
        rendererComponent.setBackground(Color.white);
      }
    } else {
      rendererComponent =
          (JComponent)
              defaultRenderer.getListCellRendererComponent(
                  list, "", index, isSelected, cellHasFocus);
    }

    return this;
  }
 @Override
 public void setBackground(Color bg) {
   super.setBackground(bg);
   if (rendererComponent != null) {
     rendererComponent.setBackground(bg);
   }
 }
Ejemplo n.º 3
0
  public ResultProperties(int i, int i0, ArrayList<String[]> result, TransferContainer tc) {

    w = i;
    h = i0;
    setBackground(java.awt.Color.getHSBColor(tc.c1[0], tc.c1[1], tc.c1[2]));
    searchedProperties = new ResultUnit[result.size()];
    amount = result.size();
    for (int a = 0; a < searchedProperties.length; a++) {
      searchedProperties[a] = new ResultUnit(w, this);
      searchedProperties[a].propertyID = Integer.parseInt(result.get(a)[0]);
      searchedProperties[a].duchy = result.get(a)[2];

      switch (result.get(a)[4]) {
        case "Poor":
          searchedProperties[a].quality = 1;
          break;
        case "Fine":
          searchedProperties[a].quality = 2;
          break;
        default:
          searchedProperties[a].quality = 3;
          break;
      }
      searchedProperties[a].size = Integer.parseInt(result.get(a)[3]);
      searchedProperties[a].tiles = tc.rdb.convertFromArray(result.get(a)[5]);
      searchedProperties[a].buildings = tc.rdb.convertFromArray(result.get(a)[6]);
      searchedProperties[a].init(tc);
    }

    JComponent panel1 = makePanel("Panel #1", 1);
    GridLayout experimentLayout = new GridLayout(0, 1);
    panel1.setLayout(experimentLayout);
    panel1.setBackground(java.awt.Color.getHSBColor(tc.c1[0], tc.c1[1], tc.c1[2]));
    add(panel1);
  }
Ejemplo n.º 4
0
 public void setBackground(Color c) {
   shouldPaintBg = true;
   //		setOpaque( (c != null) && (c.getAlpha() == 0xFF) );
   super.setBackground(c);
   // bgColr = c;
   //		repaint();
 }
Ejemplo n.º 5
0
    public void paint(Graphics g, JComponent comp) {
        // paint to the buffered image
        comp.setBackground(UIHelper.LIGHT_GREEN_COLOR);
        comp.setForeground(UIHelper.BG_COLOR);

        super.paint(g, comp);
    }
Ejemplo n.º 6
0
  /**
   * Creates body of the dialog. You can redefine getDialogTitle(), getDescription(), getInputPane()
   * methods to customize this body.
   */
  protected final JPanel body() {
    final JPanel pane = new JPanel();
    pane.setLayout(new BoxLayout(pane, BoxLayout.Y_AXIS));
    final JEditorPane descPane =
        new JEditorPane(
            Tools.MIME_TYPE_TEXT_HTML,
            "<span style='font:bold italic;font-family:Dialog; font-size:"
                + Tools.getConfigData().scaled(14)
                + ";'>"
                + getDialogTitle()
                + "</span><br>"
                + "<span style='font-family:Dialog; font-size:"
                + Tools.getConfigData().scaled(12)
                + ";'>"
                + getDescription()
                + "</span>");
    descPane.setSize(300, Integer.MAX_VALUE);

    descPane.setBackground(Tools.getDefaultColor("ConfigDialog.Background"));
    descPane.setEditable(false);
    final JScrollPane descSP = new JScrollPane(descPane);
    descSP.setBorder(null);
    descSP.setAlignmentX(Component.LEFT_ALIGNMENT);
    descSP.setMinimumSize(new Dimension(0, 50));
    pane.add(descSP);
    final JComponent inputPane = getInputPane();
    if (inputPane != null) {
      inputPane.setMinimumSize(new Dimension(Short.MAX_VALUE, INPUT_PANE_HEIGHT));
      inputPane.setBackground(Tools.getDefaultColor("ConfigDialog.Background"));
      inputPane.setAlignmentX(Component.LEFT_ALIGNMENT);
      pane.add(inputPane);
    }
    pane.setBackground(Tools.getDefaultColor("ConfigDialog.Background.Light"));
    return pane;
  }
Ejemplo n.º 7
0
  /**
   * Load, starting with the memoryInputIcon element, then all the value-icon pairs
   *
   * @param element Top level Element to unpack.
   * @param o an Editor as an Object
   */
  public void load(Element element, Object o) {
    // create the objects
    Editor p = (Editor) o;

    int nCol = 2;
    try {
      nCol = element.getAttribute("colWidth").getIntValue();
    } catch (org.jdom2.DataConversionException e) {
      log.error("failed to convert colWidth attribute");
    }

    MemoryInputIcon l = new MemoryInputIcon(nCol, p);

    loadTextInfo(l, element);
    String name;
    Attribute attr = element.getAttribute("memory");
    if (attr == null) {
      log.error("incorrect information for a memory location; must use memory name");
      p.loadFailed();
      return;
    } else {
      name = attr.getValue();
    }

    Memory m = jmri.InstanceManager.memoryManagerInstance().getMemory(name);

    if (m != null) {
      l.setMemory(name);
    } else {
      log.error("Memory named '" + attr.getValue() + "' not found.");
      p.loadFailed();
      return;
    }

    p.putItem(l);
    // load individual item's option settings after editor has set its global settings
    loadCommonAttributes(l, Editor.MEMORIES, element);

    javax.swing.JComponent textField = l.getTextComponent();
    jmri.jmrit.display.PositionablePopupUtil util = l.getPopupUtility();
    if (util.hasBackground()) {
      textField.setBackground(util.getBackground());
    } else {
      textField.setBackground(null);
      textField.setOpaque(false);
    }
  }
Ejemplo n.º 8
0
 public Component getTableCellRendererComponent(
     JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
   final JComponent rendererComponent =
       (JComponent)
           myBaseRenderer.getTableCellRendererComponent(
               table, value, isSelected, hasFocus, row, column);
   if (isSelected) {
     rendererComponent.setBackground(table.getSelectionBackground());
     rendererComponent.setForeground(table.getSelectionForeground());
   } else {
     final Color bg = table.getBackground();
     rendererComponent.setBackground(bg);
     rendererComponent.setForeground(table.getForeground());
   }
   rendererComponent.setOpaque(isSelected);
   return rendererComponent;
 }
Ejemplo n.º 9
0
  public void installUI(JComponent c) {
    super.installUI(c);
    c.setFocusable(false);
    AlgebraTheme theme = AlgebraTheme.getInstance();

    c.setBackground(theme.getHighlightPaper());
    c.setForeground(theme.getHighlightInk());
  }
Ejemplo n.º 10
0
 void decorate(final boolean notified) {
   my(GuiThread.class).assertInGuiThread();
   if (notified) {
     _target.setOpaque(_isOpaque);
     _target.setBackground(_bgColor);
     return;
   }
   _target.setOpaque(true);
 }
Ejemplo n.º 11
0
 /**
  * {@inheritDoc}
  *
  * <p>Overridden to set the background of the delegate and icon label as well.
  */
 @Override
 public void setBackground(Color bg) {
   super.setBackground(bg);
   if (iconLabel != null) {
     iconLabel.setBackground(bg);
   }
   if (delegate != null) {
     delegate.setBackground(bg);
   }
 }
Ejemplo n.º 12
0
  public void paint(Graphics g, JComponent comp) {
    // paint to the buffered image
    comp.setForeground(UIHelper.DARK_GREEN_COLOR);
    comp.setBackground(UIHelper.BG_COLOR);
    comp.setFont(UIHelper.VER_12_BOLD);

    super.paint(g, comp);
    // do an alpha composite

  }
Ejemplo n.º 13
0
  @Override
  public Component prepareRenderer(TableCellRenderer renderer, int row, int column) {
    final Component result = super.prepareRenderer(renderer, row, column);
    final boolean selected =
        myExpandableItemsHandler.getExpandedItems().contains(new TableCell(row, column));

    // Fix GTK background
    if (UIUtil.isUnderGTKLookAndFeel()) {
      UIUtil.changeBackGround(this, UIUtil.getTreeTextBackground());
    }

    if (isTableDecorationSupported() && isStriped() && result instanceof JComponent) {
      final Color bg = row % 2 == 1 ? getBackground() : DECORATED_ROW_BG_COLOR;
      final JComponent c = (JComponent) result;
      final boolean cellSelected = isCellSelected(row, column);
      if (!cellSelected || (!hasFocus() && !getSelectionBackground().equals(c.getBackground()))) {
        c.setOpaque(true);
        c.setBackground(bg);
        for (Component child : c.getComponents()) {
          child.setBackground(bg);
        }
      }
    }

    if (!selected) return result;

    return new JComponent() {
      {
        add(result);
        setOpaque(false);
        setLayout(
            new AbstractLayoutManager() {
              @Override
              public Dimension preferredLayoutSize(Container parent) {
                return result.getPreferredSize();
              }

              @Override
              public void layoutContainer(Container parent) {
                Dimension size = parent.getSize();
                Insets i = parent.getInsets();
                Dimension pref = result.getPreferredSize();
                result.setBounds(
                    i.left,
                    i.top,
                    Math.max(pref.width, size.width - i.left - i.right),
                    size.height - i.top - i.bottom);
              }
            });
      }
    };
  }
  public boolean verify(JComponent component) {

    String text = ((JTextComponent) component).getText();

    // Permit empty values
    if (text == null || text.trim().length() == 0) {
      return true;
    }

    // Parse the text as a Bitcoin address
    try {
      new Address(networkParameters, text);
    } catch (AddressFormatException e) {
      component.setBackground(invalidColor);
      return false;
    }

    // Must be OK to be here
    component.setBackground(validColor);

    return true;
  }
  protected void installDefaults() {
    super.installDefaults();

    /* Enable the content pane to inherit background color
     * from its parent by setting its background color to null.
     * Fixes bug#4268949, which has been fixed in 1.4, too. */
    JComponent contentPane = (JComponent) frame.getContentPane();
    if (contentPane != null) {
      Color bg = contentPane.getBackground();
      if (bg instanceof UIResource) contentPane.setBackground(null);
    }
    frame.setBackground(UIManager.getLookAndFeelDefaults().getColor("control"));
  }
  /**
   * @see javax.swing.table.TableCellRenderer#getTableCellRendererComponent(javax.swing.JTable,
   *     java.lang.Object, boolean, boolean, int, int)
   */
  public Component getTableCellRendererComponent(
      JTable table, Object value, boolean selected, boolean hasFocus, int row, int column) {
    this.spinner.setComponentOrientation(table.getComponentOrientation());
    this.spinner.setFont(table.getFont());
    this.spinner.setEnabled(table.isEnabled());

    JComponent editor = this.editor();
    editor.setForeground(this.foregroundColor(table, value, selected, hasFocus, row, column));
    editor.setBackground(this.backgroundColor(table, value, selected, hasFocus, row, column));
    this.spinner.setBorder(this.border(table, value, selected, hasFocus, row, column));

    this.setValue(value);
    return this.spinner;
  }
Ejemplo n.º 17
0
    QuickDocInfoPane(
        @NotNull PsiElement documentationAnchor,
        @NotNull PsiElement elementUnderMouse,
        @NotNull JComponent baseDocControl) {
      myBaseDocControl = baseDocControl;

      PresentationFactory presentationFactory = new PresentationFactory();
      for (AbstractDocumentationTooltipAction action : ourTooltipActions) {
        Icon icon = action.getTemplatePresentation().getIcon();
        Dimension minSize = new Dimension(icon.getIconWidth(), icon.getIconHeight());
        myButtons.add(
            new ActionButton(
                action,
                presentationFactory.getPresentation(action),
                IdeTooltipManager.IDE_TOOLTIP_PLACE,
                minSize));
        action.setDocInfo(documentationAnchor, elementUnderMouse);
      }
      Collections.reverse(myButtons);

      setPreferredSize(baseDocControl.getPreferredSize());
      setMaximumSize(baseDocControl.getMaximumSize());
      setMinimumSize(baseDocControl.getMinimumSize());
      setBackground(baseDocControl.getBackground());

      add(baseDocControl, Integer.valueOf(0));
      int minWidth = 0;
      int minHeight = 0;
      int buttonWidth = 0;
      for (JComponent button : myButtons) {
        button.setBorder(null);
        button.setBackground(baseDocControl.getBackground());
        add(button, Integer.valueOf(1));
        button.setVisible(false);
        Dimension preferredSize = button.getPreferredSize();
        minWidth += preferredSize.width;
        minHeight = Math.max(minHeight, preferredSize.height);
        buttonWidth = Math.max(buttonWidth, preferredSize.width);
      }
      myButtonWidth = buttonWidth;

      int margin = 2;
      myMinWidth = minWidth + margin * 2 + (myButtons.size() - 1) * BUTTON_HGAP;
      myMinHeight = minHeight + margin * 2;
    }
Ejemplo n.º 18
0
 // private int MARGIN = 20;
 public CPopupMenu() {
   super();
   this.setLayout(new BorderLayout());
   this.setBackground(background);
   this.setOpaque(false);
   this.removeAll();
   this.setBorder(BorderFactory.createMatteBorder(2, 2, 2, 2, CGraphite.darkgreen));
   view = new JPanel(new GridLayout(0, 1));
   view.setBackground(background);
   scroll =
       new CTracklessScrollPane(
           view,
           ScrollPolicy.VERTICAL_BAR_AS_NEEDED,
           ScrollPolicy.HORIZONTAL_BAR_NEVER,
           9,
           CGraphite.darkgreen,
           background);
   this.add(scroll);
 }
Ejemplo n.º 19
0
  void test(JComponent c) {
    c.setEnabled(false);
    c.setOpaque(true);
    c.setBackground(TEST_COLOR);
    c.setBorder(null);
    Dimension size = c.getPreferredSize();
    c.setBounds(0, 0, size.width, size.height);

    BufferedImage image = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_ARGB);
    c.paint(image.getGraphics());

    int rgb = TEST_COLOR.getRGB();
    for (int i = 0; i < size.height; i++) {
      for (int j = 0; j < size.width; j++) {
        if (image.getRGB(j, i) != rgb) {
          throw new RuntimeException(String.format("Color mismatch at [%d, %d]", j, i));
        }
      }
    }
  }
Ejemplo n.º 20
0
  protected void layoutComponent(String name, JComponent c) {
    Color col = getConfigColor(name, "foreground");
    if (col != null) {
      c.setForeground(col);
    }
    col = getConfigColor(name, "background");
    if (col != null) {
      c.setBackground(col);
    }
    String opaque = getConfigProperty(name + ".opaque");
    if (opaque != null) {
      c.setOpaque("true".equalsIgnoreCase(opaque));
    }

    if (getLayout() == null) {
      Rectangle bounds = getConfigBounds(name);
      if (bounds == null) {
        // No bounds for this component => use layout manager
        log.warning(
            "no bounds for "
                + roleName
                + '.'
                + getName()
                + '.'
                + name
                + ": reverting to layout manager");
        BoxLayout layout = new BoxLayout(this, BoxLayout.Y_AXIS);
        setLayout(layout);
      } else {
        c.setBounds(bounds);
        if ((bounds.x + bounds.width) > minWidth) {
          minWidth = bounds.x + bounds.width;
        }
        if (bounds.y + bounds.height > minHeight) {
          minHeight = bounds.y + bounds.height;
        }
      }
    }
    add(c);
  }
 public static void setColors(JComponent pane) {
   pane.setForeground(Color.black);
   pane.setBackground(HintUtil.INFORMATION_COLOR);
   pane.setOpaque(true);
 }
Ejemplo n.º 22
0
 public void setBackground(JComponent field) {
   field.setBackground(App.whiteSmoke);
 }
 // some convenience methods
 private void applySelectionStyle(boolean selected, JComponent c) {
   if (selected) c.setBackground(table.getSelectionBackground());
   else c.setBackground(table.getBackground());
 }
Ejemplo n.º 24
0
 /** Apply the tooltip style (e.g. colors) to the given component. */
 public static void applyToolTipStyle(JComponent c) {
   c.setForeground((Color) UIManager.get("ToolTip.foreground"));
   c.setBackground((Color) UIManager.get("ToolTip.background"));
   c.setFont((Font) UIManager.get("ToolTip.font"));
 }
Ejemplo n.º 25
0
  /**
   * Add a new entry to this query that represents the given attribute. The name of the entry will
   * be set to the name of the attribute, and the attribute will be attached to the entry, so that
   * if the attribute is updated, then the entry is updated. If the attribute contains an instance
   * of ParameterEditorStyle, then defer to the style to create the entry, otherwise just create a
   * default entry. The style used in a default entry depends on the class of the attribute and on
   * its declared type, but defaults to a one-line entry if there is no obviously better style. Only
   * the first style that is found is used to create an entry.
   *
   * @param attribute The attribute to create an entry for.
   */
  public void addStyledEntry(Settable attribute) {
    // Note: it would be nice to give
    // multiple styles to specify to create more than one
    // entry for a particular parameter.  However, the style configurer
    // doesn't support it and we don't have a good way of representing
    // it in this class.
    // Look for a ParameterEditorStyle.
    boolean foundStyle = false;

    try {
      _addingStyledEntryFor = attribute;

      if (attribute instanceof NamedObj) {
        Iterator<?> styles =
            ((NamedObj) attribute).attributeList(ParameterEditorStyle.class).iterator();

        while (styles.hasNext() && !foundStyle) {
          ParameterEditorStyle style = (ParameterEditorStyle) styles.next();

          try {
            style.addEntry(this);
            foundStyle = true;
          } catch (IllegalActionException ex) {
            // Ignore failures here, and just present
            // the default dialog.
          }
        }
      }

      if (!foundStyle) {
        // NOTE: Infer the style.
        // This is a regrettable approach, but it keeps
        // dependence on UI issues out of actor definitions.
        // Also, the style code is duplicated here and in the
        // style attributes. However, it won't work to create
        // a style attribute here, because we don't necessarily
        // have write access to the workspace.
        String name = attribute.getName();
        String displayName = attribute.getDisplayName();

        try {
          JComponent component = null;
          if (attribute instanceof IntRangeParameter) {
            int current = ((IntRangeParameter) attribute).getCurrentValue();
            int min = ((IntRangeParameter) attribute).getMinValue();
            int max = ((IntRangeParameter) attribute).getMaxValue();

            component = addSlider(name, displayName, current, min, max);
            attachParameter(attribute, name);
            foundStyle = true;
          } else if (attribute instanceof DoubleRangeParameter) {
            double current =
                ((DoubleToken) ((DoubleRangeParameter) attribute).getToken()).doubleValue();
            double max =
                ((DoubleToken) ((DoubleRangeParameter) attribute).max.getToken()).doubleValue();
            double min =
                ((DoubleToken) ((DoubleRangeParameter) attribute).min.getToken()).doubleValue();
            int precision =
                ((IntToken) ((DoubleRangeParameter) attribute).precision.getToken()).intValue();

            // Get the quantized integer for the current value.
            int quantized = ((int) Math.round(((current - min) * precision) / (max - min)));
            component = addSlider(name, displayName, quantized, 0, precision);
            attachParameter(attribute, name);
            foundStyle = true;
          } else if (attribute instanceof ColorAttribute) {
            component = addColorChooser(name, displayName, attribute.getExpression());
            attachParameter(attribute, name);
            foundStyle = true;
          } else if (attribute instanceof CustomQueryBoxParameter) {
            JLabel label = new JLabel(displayName + ": ");
            label.setBackground(_background);
            component = ((CustomQueryBoxParameter) attribute).createQueryBox(this, attribute);
            _addPair(name, label, component, component);
            attachParameter(attribute, name);
            foundStyle = true;
          } else if (attribute instanceof FileParameter || attribute instanceof FilePortParameter) {
            // Specify the directory in which to start browsing
            // to be the location where the model is defined,
            // if that is known.
            URI modelURI = URIAttribute.getModelURI((NamedObj) attribute);
            File directory = null;

            if (modelURI != null) {
              if (modelURI.getScheme().equals("file")) {
                File modelFile = new File(modelURI);
                directory = modelFile.getParentFile();
              }
            }

            URI base = null;

            if (directory != null) {
              base = directory.toURI();
            }

            // Check to see whether the attribute being configured
            // specifies whether files or directories should be listed.
            // By default, only files are selectable.
            boolean allowFiles = true;
            boolean allowDirectories = false;

            // attribute is always a NamedObj
            Parameter marker =
                (Parameter) ((NamedObj) attribute).getAttribute("allowFiles", Parameter.class);

            if (marker != null) {
              Token value = marker.getToken();

              if (value instanceof BooleanToken) {
                allowFiles = ((BooleanToken) value).booleanValue();
              }
            }

            marker =
                (Parameter)
                    ((NamedObj) attribute).getAttribute("allowDirectories", Parameter.class);

            if (marker != null) {
              Token value = marker.getToken();

              if (value instanceof BooleanToken) {
                allowDirectories = ((BooleanToken) value).booleanValue();
              }
            }

            // FIXME: What to do when neither files nor directories are allowed?
            if (!allowFiles && !allowDirectories) {
              // The given attribute will not have a query in the dialog.
              return;
            }

            boolean isOutput = false;
            if (attribute instanceof FileParameter && ((FileParameter) attribute).isOutput()) {
              isOutput = true;
            }

            // FIXME: Should remember previous browse location?
            // Next to last argument is the starting directory.
            component =
                addFileChooser(
                    name,
                    displayName,
                    attribute.getExpression(),
                    base,
                    directory,
                    allowFiles,
                    allowDirectories,
                    isOutput,
                    preferredBackgroundColor(attribute),
                    preferredForegroundColor(attribute));
            attachParameter(attribute, name);
            foundStyle = true;
          } else if (attribute instanceof PasswordAttribute) {
            component = addPassword(name, displayName, "");
            attachParameter(attribute, name);
            foundStyle = true;
          } else if (attribute instanceof Parameter
              && (((Parameter) attribute).getChoices() != null)) {
            Parameter castAttribute = (Parameter) attribute;

            // NOTE: Make this always editable since Parameter
            // supports a form of expressions for value propagation.
            component =
                addChoice(
                    name,
                    displayName,
                    castAttribute.getChoices(),
                    castAttribute.getExpression(),
                    true,
                    preferredBackgroundColor(attribute),
                    preferredForegroundColor(attribute));
            attachParameter(attribute, name);
            foundStyle = true;
          } else if ((attribute instanceof NamedObj)
              && ((((NamedObj) attribute).getAttribute("_textWidthHint") != null)
                  || ((NamedObj) attribute).getAttribute("_textHeightHint") != null)) {
            // Support hints for text height and/or width so that actors
            // don't have to use a ParameterEditorStyle, which depends
            // on packages that depend on graphics.

            // Default values:
            int widthValue = 30;
            int heightValue = 10;

            Attribute widthAttribute = ((NamedObj) attribute).getAttribute("_textWidthHint");
            if (widthAttribute instanceof Variable) {
              Token token = ((Variable) widthAttribute).getToken();
              if (token instanceof IntToken) {
                widthValue = ((IntToken) token).intValue();
              }
            }
            Attribute heightAttribute = ((NamedObj) attribute).getAttribute("_textHeightHint");
            if (heightAttribute instanceof Variable) {
              Token token = ((Variable) heightAttribute).getToken();
              if (token instanceof IntToken) {
                heightValue = ((IntToken) token).intValue();
              }
            }

            component =
                addTextArea(
                    name,
                    displayName,
                    attribute.getExpression(),
                    preferredBackgroundColor(attribute),
                    preferredForegroundColor(attribute),
                    heightValue,
                    widthValue);
            attachParameter(attribute, name);
            foundStyle = true;
          } else if (attribute instanceof Variable) {
            Type declaredType = ((Variable) attribute).getDeclaredType();
            Token current = ((Variable) attribute).getToken();

            if (declaredType == BaseType.BOOLEAN) {
              // NOTE: If the expression is something other than
              // "true" or "false", then this parameter is set
              // to an expression that evaluates to to a boolean,
              // and the default Line style should be used.
              if (attribute.getExpression().equals("true")
                  || attribute.getExpression().equals("false")) {
                component = addCheckBox(name, displayName, ((BooleanToken) current).booleanValue());
                attachParameter(attribute, name);
                foundStyle = true;
              }
            }
          }

          // NOTE: Other attribute classes?

          if (attribute.getVisibility() == Settable.NOT_EDITABLE) {
            if (component == null) {
              String defaultValue = attribute.getExpression();
              component = addDisplay(name, displayName, defaultValue);
              attachParameter(attribute, name);
              foundStyle = true;
            } else if (component instanceof JTextComponent) {
              component.setBackground(_background);
              ((JTextComponent) component).setEditable(false);
            } else {
              component.setEnabled(false);
            }
          }
        } catch (IllegalActionException ex) {
          // Ignore and create a line entry.
        }
      }

      String defaultValue = attribute.getExpression();

      if (defaultValue == null) {
        defaultValue = "";
      }

      if (!(foundStyle)) {
        addLine(
            attribute.getName(),
            attribute.getDisplayName(),
            defaultValue,
            preferredBackgroundColor(attribute),
            preferredForegroundColor(attribute));

        // The style itself does this, so we don't need to do it again.
        attachParameter(attribute, attribute.getName());
      }
    } finally {
      _addingStyledEntryFor = null;
    }
  }
Ejemplo n.º 26
0
 public static void configureFilterView(JComponent component) {
   component.setBackground(UNSELECTED_BACKGROUND_COLOR);
   component.setBorder(COMPOSITE_PANEL_BORDER);
 }
 public static void setScheme(JComponent parComponent, Scheme parScheme) {
   parComponent.setBackground(parScheme.COMPONENT_BACKGROUND_COLOR);
   parComponent.setForeground(parScheme.FOREGROUND_COLOR);
   parComponent.setFont(parScheme.FONT);
 }
  /**
   * Shows the hint in the layered pane. Coordinates <code>x</code> and <code>y</code> are in <code>
   * parentComponent</code> coordinate system. Note that the component appears on 250 layer.
   */
  @Override
  public void show(
      @NotNull final JComponent parentComponent,
      final int x,
      final int y,
      final JComponent focusBackComponent,
      @NotNull final HintHint hintHint) {
    myParentComponent = parentComponent;
    myHintHint = hintHint;

    myFocusBackComponent = focusBackComponent;

    LOG.assertTrue(myParentComponent.isShowing());
    myEscListener = new MyEscListener();
    myComponent.registerKeyboardAction(
        myEscListener,
        KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
        JComponent.WHEN_IN_FOCUSED_WINDOW);
    myComponent.registerKeyboardAction(
        myEscListener, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_FOCUSED);
    final JLayeredPane layeredPane = parentComponent.getRootPane().getLayeredPane();

    myComponent.validate();

    if (!myForceShowAsPopup
        && (myForceLightweightPopup
            || fitsLayeredPane(
                layeredPane,
                myComponent,
                new RelativePoint(parentComponent, new Point(x, y)),
                hintHint))) {
      beforeShow();
      final Dimension preferredSize = myComponent.getPreferredSize();

      if (hintHint.isAwtTooltip()) {
        IdeTooltip tooltip =
            new IdeTooltip(
                hintHint.getOriginalComponent(),
                hintHint.getOriginalPoint(),
                myComponent,
                hintHint,
                myComponent) {
              @Override
              protected boolean canAutohideOn(TooltipEvent event) {
                if (event.getInputEvent() instanceof MouseEvent) {
                  return !(hintHint.isContentActive() && event.isIsEventInsideBalloon());
                } else if (event.getAction() != null) {
                  return false;
                } else {
                  return true;
                }
              }

              @Override
              protected void onHidden() {
                fireHintHidden();
                TooltipController.getInstance().resetCurrent();
              }

              @Override
              public boolean canBeDismissedOnTimeout() {
                return false;
              }
            }.setToCenterIfSmall(hintHint.isMayCenterTooltip())
                .setPreferredPosition(hintHint.getPreferredPosition())
                .setHighlighterType(hintHint.isHighlighterType())
                .setTextForeground(hintHint.getTextForeground())
                .setTextBackground(hintHint.getTextBackground())
                .setBorderColor(hintHint.getBorderColor())
                .setBorderInsets(hintHint.getBorderInsets())
                .setFont(hintHint.getTextFont())
                .setCalloutShift(hintHint.getCalloutShift())
                .setPositionChangeShift(
                    hintHint.getPositionChangeX(), hintHint.getPositionChangeY())
                .setExplicitClose(hintHint.isExplicitClose())
                .setHint(true);
        myComponent.validate();
        myCurrentIdeTooltip =
            IdeTooltipManager.getInstance()
                .show(tooltip, hintHint.isShowImmediately(), hintHint.isAnimationEnabled());
      } else {
        final Point layeredPanePoint =
            SwingUtilities.convertPoint(parentComponent, x, y, layeredPane);
        myComponent.setBounds(
            layeredPanePoint.x, layeredPanePoint.y, preferredSize.width, preferredSize.height);
        layeredPane.add(myComponent, JLayeredPane.POPUP_LAYER);

        myComponent.validate();
        myComponent.repaint();
      }
    } else {
      myIsRealPopup = true;
      Point actualPoint = new Point(x, y);
      JComponent actualComponent = new OpaquePanel(new BorderLayout());
      actualComponent.add(myComponent, BorderLayout.CENTER);
      if (isAwtTooltip()) {
        fixActualPoint(actualPoint);

        int inset = BalloonImpl.getNormalInset();
        actualComponent.setBorder(new LineBorder(hintHint.getTextBackground(), inset));
        actualComponent.setBackground(hintHint.getTextBackground());
        actualComponent.validate();
      }

      myPopup =
          JBPopupFactory.getInstance()
              .createComponentPopupBuilder(actualComponent, myFocusRequestor)
              .setRequestFocus(myFocusRequestor != null)
              .setFocusable(myFocusRequestor != null)
              .setResizable(myResizable)
              .setMovable(myTitle != null)
              .setTitle(myTitle)
              .setModalContext(false)
              .setShowShadow(isRealPopup() && !isForceHideShadow())
              .setCancelKeyEnabled(false)
              .setCancelOnClickOutside(myCancelOnClickOutside)
              .setCancelCallback(
                  new Computable<Boolean>() {
                    @Override
                    public Boolean compute() {
                      onPopupCancel();
                      return true;
                    }
                  })
              .setCancelOnOtherWindowOpen(myCancelOnOtherWindowOpen)
              .createPopup();

      beforeShow();
      myPopup.show(new RelativePoint(myParentComponent, new Point(actualPoint.x, actualPoint.y)));
    }
  }
Ejemplo n.º 29
0
  /**
   * Builds the panel hosting the user's details.
   *
   * @return See above.
   */
  private JPanel buildContentPanel() {
    ExperimenterData user = (ExperimenterData) model.getRefObject();
    boolean editable = model.isUserOwner(user);
    if (!editable) editable = model.isGroupLeader() || MetadataViewerAgent.isAdministrator();
    details = EditorUtil.convertExperimenter(user);
    JPanel content = new JPanel();
    content.setBorder(BorderFactory.createTitledBorder("Profile"));
    content.setBackground(UIUtilities.BACKGROUND_COLOR);
    Entry entry;
    Iterator i = details.entrySet().iterator();
    JComponent label;
    JTextField area;
    String key, value;
    content.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.WEST;
    c.insets = new Insets(0, 2, 2, 0);
    // Add log in name but cannot edit.
    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = GridBagConstraints.REMAINDER; // end row
    c.fill = GridBagConstraints.HORIZONTAL;
    content.add(userPicture, c);
    c.gridy++;
    c.gridx = 0;
    label = EditorUtil.getLabel(EditorUtil.DISPLAY_NAME, true);
    label.setBackground(UIUtilities.BACKGROUND_COLOR);
    c.gridwidth = GridBagConstraints.RELATIVE; // next-to-last
    c.fill = GridBagConstraints.NONE; // reset to default
    c.weightx = 0.0;
    content.add(label, c);
    c.gridx++;
    content.add(Box.createHorizontalStrut(5), c);
    c.gridx++;
    c.gridwidth = GridBagConstraints.REMAINDER; // end row
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1.0;
    loginArea.setText(user.getUserName());
    loginArea.getDocument().addDocumentListener(this);
    content.add(loginArea, c);
    while (i.hasNext()) {
      ++c.gridy;
      c.gridx = 0;
      entry = (Entry) i.next();
      key = (String) entry.getKey();
      value = (String) entry.getValue();
      label = EditorUtil.getLabel(key, false);
      area = new JTextField(value);
      area.setBackground(UIUtilities.BACKGROUND_COLOR);
      area.setEditable(editable);
      area.setEnabled(editable);
      if (editable) area.getDocument().addDocumentListener(this);
      items.put(key, area);
      label.setBackground(UIUtilities.BACKGROUND_COLOR);
      c.gridwidth = GridBagConstraints.RELATIVE; // next-to-last
      c.fill = GridBagConstraints.NONE; // reset to default
      c.weightx = 0.0;
      content.add(label, c);
      c.gridx++;
      content.add(Box.createHorizontalStrut(5), c);
      c.gridx++;
      c.gridwidth = GridBagConstraints.REMAINDER; // end row
      c.fill = GridBagConstraints.HORIZONTAL;
      c.weightx = 1.0;
      content.add(area, c);
    }
    c.gridx = 0;
    c.gridy++;
    label = EditorUtil.getLabel(EditorUtil.DEFAULT_GROUP, false);
    c.gridwidth = GridBagConstraints.RELATIVE; // next-to-last
    c.fill = GridBagConstraints.NONE; // reset to default
    c.weightx = 0.0;
    content.add(label, c);
    c.gridx++;
    content.add(Box.createHorizontalStrut(5), c);
    c.gridx++;
    c.gridwidth = GridBagConstraints.REMAINDER; // end row
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1.0;
    content.add(groupLabel, c);
    c.gridy++;
    content.add(permissionsPane, c);

    // content.add(groups, c);

    c.gridx = 0;
    c.gridy++;
    label = EditorUtil.getLabel(EditorUtil.GROUP_OWNER, false);
    c.gridwidth = GridBagConstraints.RELATIVE; // next-to-last
    c.fill = GridBagConstraints.NONE; // reset to default
    c.weightx = 0.0;
    content.add(label, c);
    c.gridx++;
    content.add(Box.createHorizontalStrut(5), c);
    c.gridx++;
    c.gridwidth = GridBagConstraints.REMAINDER; // end row
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1.0;
    content.add(ownerBox, c);
    if (activeBox.isVisible()) {
      c.gridx = 0;
      c.gridy++;
      label = EditorUtil.getLabel(EditorUtil.ACTIVE, false);
      c.gridwidth = GridBagConstraints.RELATIVE; // next-to-last
      c.fill = GridBagConstraints.NONE; // reset to default
      c.weightx = 0.0;
      content.add(label, c);
      c.gridx++;
      content.add(Box.createHorizontalStrut(5), c);
      c.gridx++;
      c.gridwidth = GridBagConstraints.REMAINDER; // end row
      c.fill = GridBagConstraints.HORIZONTAL;
      c.weightx = 1.0;
      content.add(activeBox, c);
    }
    if (adminBox.isVisible()) {
      c.gridx = 0;
      c.gridy++;
      label = EditorUtil.getLabel(EditorUtil.ADMINISTRATOR, false);
      c.gridwidth = GridBagConstraints.RELATIVE; // next-to-last
      c.fill = GridBagConstraints.NONE; // reset to default
      c.weightx = 0.0;
      content.add(label, c);
      c.gridx++;
      content.add(Box.createHorizontalStrut(5), c);
      c.gridx++;
      c.gridwidth = GridBagConstraints.REMAINDER; // end row
      c.fill = GridBagConstraints.HORIZONTAL;
      c.weightx = 1.0;
      content.add(adminBox, c);
    }
    c.gridx = 0;
    c.gridy++;
    content.add(Box.createHorizontalStrut(10), c);
    c.gridy++;
    label = UIUtilities.setTextFont(EditorUtil.MANDATORY_DESCRIPTION, Font.ITALIC);
    label.setForeground(UIUtilities.REQUIRED_FIELDS_COLOR);
    c.weightx = 0.0;
    content.add(label, c);
    return content;
  }
Ejemplo n.º 30
0
 @Override
 public void setBackground(Color bg) {
   super.setBackground(bg);
   label.setBackground(bg);
   field.setBackground(bg);
 }