private static JLabel createArrow(final ActionLink link) {
   JLabel arrow = new JLabel(AllIcons.General.Combo3);
   arrow.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
   arrow.setVerticalAlignment(SwingConstants.BOTTOM);
   new ClickListener() {
     @Override
     public boolean onClick(@NotNull MouseEvent e, int clickCount) {
       final MouseEvent newEvent = MouseEventAdapter.convert(e, link, e.getX(), e.getY());
       link.doClick(newEvent);
       return true;
     }
   }.installOn(arrow);
   return arrow;
 }
  private JLabel makeLabelIcon() {
    ImageIcon i = new ImageIcon(getClass().getResource("duke.gif"));
    Dimension d = new Dimension(i.getIconWidth(), i.getIconHeight());
    final BufferedImage image = new BufferedImage(d.width, d.height, BufferedImage.TYPE_INT_ARGB);
    Graphics g = image.createGraphics();
    i.paintIcon(null, g, 0, 0);
    g.dispose();
    final JLabel icon =
        new JLabel(i) {
          @Override
          public boolean contains(int x, int y) {
            return super.contains(x, y) && ((image.getRGB(x, y) >> 24) & 0xff) != 0;
          }
        };
    icon.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
    MouseAdapter l =
        new MouseAdapter() {
          private final transient Point start = new Point();
          private Point loc;

          @Override
          public void mousePressed(MouseEvent me) {
            start.setLocation(me.getPoint());
          }

          @Override
          public void mouseDragged(MouseEvent me) {
            loc = icon.getLocation(loc);
            int x = loc.x - start.x + me.getX();
            int y = loc.y - start.y + me.getY();
            icon.setLocation(x, y);
          }
        };
    icon.addMouseListener(l);
    icon.addMouseMotionListener(l);
    icon.setBounds(new Rectangle(22, 22, d.width, d.height));
    return icon;
  }
  /**
   * Creates the subscribe label.
   *
   * @param linkName the link name
   * @return the newly created subscribe label
   */
  private Component createWebSignupLabel(String linkName, final String linkURL) {
    JLabel subscribeLabel =
        new JLabel("<html><a href=''>" + linkName + "</a></html>", JLabel.RIGHT);

    subscribeLabel.setCursor(new Cursor(Cursor.HAND_CURSOR));
    subscribeLabel.setToolTipText(
        DesktopUtilActivator.getResources()
            .getI18NString("plugin.simpleaccregwizz.SPECIAL_SIGNUP"));
    subscribeLabel.addMouseListener(
        new MouseAdapter() {
          public void mousePressed(MouseEvent e) {
            try {
              DesktopUtilActivator.getBrowserLauncher().openURL(linkURL);
            } catch (UnsupportedOperationException ex) {
              // This should not happen, because we check if the
              // operation is supported, before adding the sign
              // up.
              logger.error("The web sign up is not supported.", ex);
            }
          }
        });
    return subscribeLabel;
  }
  public void addKey(final String key, boolean showExpand) {

    Color rowColor = Color.WHITE;
    if (keyKeyComponentMap.size() % 2 == 0) {
      rowColor = ViewUtil.getAlternateRowColor();
    }

    if (newRowsGoIntoMoreSection) {
      keysInMoreSection.add(key);
    }

    rowColor = Color.white;

    String layoutConstraints = "insets 3 3 3 3, filly";

    JPanel valuePanel = ViewUtil.getClearPanel();
    valuePanel.setLayout(new MigLayout(layoutConstraints));
    valuePanel.setBackground(rowColor);

    int i = 0;

    JPanel keyPanel = ViewUtil.getClearPanel();
    keyPanel.setLayout(new MigLayout(layoutConstraints + ", alignx right, hmin 30"));

    keyPanel.setBackground(rowColor);

    final JLabel keyLabel = getKeyLabel(key);

    // keyLabel.setBorder(ViewUtil.getMediumBorder());
    keyKeyComponentMap.put(key, keyLabel);

    if (showExpand) {

      keyLabel.setText("? " + key.toUpperCase());

      keyLabel.setCursor(new Cursor(Cursor.HAND_CURSOR));
      keyLabel.addMouseListener(
          new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent me) {
              toggleMoreVisibility();

              if (keyLabel.getText().startsWith("?")) {
                keyLabel.setText("? " + key.toUpperCase());
              } else {
                keyLabel.setText("? " + key.toUpperCase());
              }
            }
          });
    }

    keyPanel.add(keyLabel);

    keyLabel.setVisible(keysVisible);

    kvpPanel.add(keyPanel, incrementConstraintRow(i++));
    kvpPanel.add(valuePanel, incrementConstraintRow(i++));

    JPanel[] extraComponents = new JPanel[additionalColumns];
    for (int j = 0; j < additionalColumns; j++) {
      JPanel panel = ViewUtil.getClearPanel();
      panel.setBackground(rowColor);
      ViewUtil.applyHorizontalBoxLayout(panel);
      // panel.setBorder(border);
      // panel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
      extraComponents[j] = panel; // ViewUtil.getClearPanel();
      kvpPanel.add(extraComponents[j], incrementConstraintRow(i++));
    }

    // add hidden panel
    keyDetailConstraints.gridy++;
    keyDetailConstraints.gridy++;

    JPanel detailPanel = ViewUtil.getClearPanel();
    detailPanel.setBackground(rowColor);
    // detailPanel.setBorder(ViewUtil.getTinyLineBorder());
    detailPanel.setVisible(false);
    keyDetailComponentMap.put(key, detailPanel);

    kvpPanel.add(detailPanel, keyDetailConstraints);

    // update all constraints to skip a line
    for (int k = 0; k < 2 + additionalColumns; k++) {
      incrementConstraintRow(k);
    }

    keyValueComponentMap.put(key, valuePanel);
    keyExtraComponentsMap.put(key, extraComponents);

    setMoreVisibility(showingMore);
  }
  /** Initializes this panel. */
  private void init() {
    JPanel mainPanel = new TransparentPanel(new BorderLayout());

    mainPanel.setBorder(
        BorderFactory.createTitledBorder(
            Sip2SipAccRegWizzActivator.getResources()
                .getI18NString("plugin.sipaccregwizz.CREATE_ACCOUNT_TITLE")));

    JPanel labelsPanel = new TransparentPanel(new GridLayout(0, 1));

    JPanel valuesPanel = new TransparentPanel(new GridLayout(0, 1));

    JLabel usernameLabel =
        new JLabel(
            Sip2SipAccRegWizzActivator.getResources()
                .getI18NString("plugin.sip2sipaccregwizz.USERNAME"));

    JLabel displayNameLabel =
        new JLabel(
            Sip2SipAccRegWizzActivator.getResources()
                .getI18NString("plugin.sipaccregwizz.DISPLAY_NAME"));

    JLabel passLabel =
        new JLabel(Sip2SipAccRegWizzActivator.getResources().getI18NString("service.gui.PASSWORD"));

    JLabel retypePasswordLabel =
        new JLabel(
            Sip2SipAccRegWizzActivator.getResources()
                .getI18NString("plugin.sip2sipaccregwizz.RETYPE_PASSWORD"));

    JLabel emailLabel =
        new JLabel(
            Sip2SipAccRegWizzActivator.getResources()
                .getI18NString("plugin.sip2sipaccregwizz.EMAIL"));

    labelsPanel.add(displayNameLabel);
    labelsPanel.add(usernameLabel);
    labelsPanel.add(passLabel);
    labelsPanel.add(retypePasswordLabel);
    labelsPanel.add(emailLabel);

    valuesPanel.add(displayNameField);
    valuesPanel.add(usernameField);
    valuesPanel.add(passField);
    valuesPanel.add(retypePassField);
    valuesPanel.add(emailField);

    JLabel emailDescriptionLabel =
        new JLabel(
            Sip2SipAccRegWizzActivator.getResources()
                .getI18NString("plugin.sip2sipaccregwizz.EMAIL_NOTE"),
            SwingConstants.CENTER);
    emailDescriptionLabel.setForeground(Color.GRAY);
    emailDescriptionLabel.setFont(emailDescriptionLabel.getFont().deriveFont(8));
    emailDescriptionLabel.setBorder(BorderFactory.createEmptyBorder(0, 10, 8, 10));

    initErrorArea();

    mainPanel.add(labelsPanel, BorderLayout.WEST);
    mainPanel.add(valuesPanel, BorderLayout.CENTER);
    mainPanel.add(emailDescriptionLabel, BorderLayout.SOUTH);

    this.add(mainPanel, BorderLayout.CENTER);

    JLabel infoLabel =
        new JLabel(
            Sip2SipAccRegWizzActivator.getResources()
                .getI18NString("plugin.sip2sipaccregwizz.INFO_NOTE"),
            SwingConstants.RIGHT);
    infoLabel.setCursor(new Cursor(Cursor.HAND_CURSOR));
    infoLabel.setForeground(Color.GRAY);
    infoLabel.setFont(emailDescriptionLabel.getFont().deriveFont(8));
    infoLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 8, 0));
    infoLabel.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mousePressed(MouseEvent e) {
            Sip2SipAccRegWizzActivator.getBrowserLauncher().openURL("http://wiki.sip2sip.info");
          }
        });

    this.add(infoLabel, BorderLayout.SOUTH);
  }
  @SuppressWarnings("serial")
  public JTableRenderer(final Object cell, final GraphComponent graphContainer) {
    this.cell = cell;
    this.graphContainer = graphContainer;
    this.graph = graphContainer.getGraph();
    setLayout(new BorderLayout());
    setBorder(
        BorderFactory.createCompoundBorder(
            ShadowBorder.getSharedInstance(), BorderFactory.createBevelBorder(BevelBorder.RAISED)));

    JPanel title = new JPanel();
    title.setBackground(new Color(149, 173, 239));
    title.setOpaque(true);
    title.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 1));
    title.setLayout(new BorderLayout());

    JLabel icon =
        new JLabel(new ImageIcon(JTableRenderer.class.getResource(IMAGE_PATH + "preferences.gif")));
    icon.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 1));
    title.add(icon, BorderLayout.WEST);

    JLabel label = new JLabel(String.valueOf(graph.getLabel(cell)));
    label.setForeground(Color.WHITE);
    label.setFont(title.getFont().deriveFont(Font.BOLD, 11));
    label.setBorder(BorderFactory.createEmptyBorder(0, 1, 0, 2));
    title.add(label, BorderLayout.CENTER);

    JPanel toolBar2 = new JPanel();
    toolBar2.setLayout(new FlowLayout(FlowLayout.LEFT, 1, 2));
    toolBar2.setOpaque(false);
    JButton button =
        new JButton(
            new AbstractAction(
                "", new ImageIcon(JTableRenderer.class.getResource(IMAGE_PATH + "minimize.gif"))) {

              public void actionPerformed(ActionEvent e) {
                graph.foldCells(graph.isCellCollapsed(cell), false, new Object[] {cell});
                ((JButton) e.getSource())
                    .setIcon(
                        new ImageIcon(
                            JTableRenderer.class.getResource(
                                IMAGE_PATH
                                    + ((graph.isCellCollapsed(cell))
                                        ? "maximize.gif"
                                        : "minimize.gif"))));
              }
            });
    button.setPreferredSize(new Dimension(16, 16));
    button.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    button.setToolTipText("Collapse/Expand");
    button.setOpaque(false);
    toolBar2.add(button);

    title.add(toolBar2, BorderLayout.EAST);
    add(title, BorderLayout.NORTH);

    // CellStyle style =
    // graph.getStylesheet().getCellStyle(graph.getModel(),
    // cell);
    // if (style.getStyleClass() == null) {
    table = new MyTable();
    JScrollPane scrollPane = new JScrollPane(table);
    scrollPane.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));

    if (graph.getModel().getChildCount(cell) == 0) {
      scrollPane.getViewport().setBackground(Color.WHITE);
      setOpaque(true);
      add(scrollPane, BorderLayout.CENTER);
    }

    scrollPane
        .getVerticalScrollBar()
        .addAdjustmentListener(
            new AdjustmentListener() {

              public void adjustmentValueChanged(AdjustmentEvent e) {
                graphContainer.refresh();
              }
            });

    label = new JLabel(new ImageIcon(JTableRenderer.class.getResource(IMAGE_PATH + "resize.gif")));
    label.setCursor(new Cursor(Cursor.NW_RESIZE_CURSOR));

    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());
    panel.add(label, BorderLayout.EAST);

    add(panel, BorderLayout.SOUTH);

    ResizeHandler resizeHandler = new ResizeHandler();
    label.addMouseListener(resizeHandler);
    label.addMouseMotionListener(resizeHandler);

    setMinimumSize(new Dimension(20, 30));
  }