public UserDefinedLibraryPanel() {
   pathListModel = new DefaultListModel();
   pathList = preparePathList(pathListModel);
   toolbarDecorator = prepareToolbarDecorator(pathList);
   pathsPanel.add(toolbarDecorator.createPanel());
   userDefinedLibraryEnabled.addActionListener(getUserDefinedLibraryEnabledListener());
 }
  public void setUpChangeListeners(
      final DataSourceConfigurationAggregatingPanel aggregatingPanel,
      final ConfigurationChangeListener listener) {
    userDefinedLibraryEnabled.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            listener.changeApplied(aggregatingPanel.getCurrentConfigurationState());
          }
        });
    pathListModel.addListDataListener(
        new ListDataListener() {
          @Override
          public void intervalAdded(ListDataEvent e) {
            listener.changeApplied(aggregatingPanel.getCurrentConfigurationState());
          }

          @Override
          public void intervalRemoved(ListDataEvent e) {
            listener.changeApplied(aggregatingPanel.getCurrentConfigurationState());
          }

          @Override
          public void contentsChanged(ListDataEvent e) {
            // do nothing (can't happen - we only support adding and removing)
          }
        });
  }
  protected FontOptions(@NotNull ColorAndFontOptions options, final String title) {
    setLayout(new MigLayout("ins 0, gap 5, flowx"));
    Insets borderInsets =
        new Insets(
            IdeBorderFactory.TITLED_BORDER_TOP_INSET,
            IdeBorderFactory.TITLED_BORDER_LEFT_INSET,
            0,
            IdeBorderFactory.TITLED_BORDER_RIGHT_INSET);
    setBorder(IdeBorderFactory.createTitledBorder(title, false, borderInsets));
    myOptions = options;
    add(myOnlyMonospacedCheckBox, "sgx b, sx 2");

    add(new JLabel(ApplicationBundle.message("primary.font")), "newline, ax right");
    add(myPrimaryCombo, "sgx b");
    add(new JLabel(ApplicationBundle.message("editbox.font.size")), "gapleft 20");
    add(myEditorFontSizeField);
    add(new JLabel(ApplicationBundle.message("editbox.line.spacing")), "gapleft 20");
    add(myLineSpacingField);

    add(
        new JLabel(
            ApplicationBundle.message("label.fallback.fonts.list.description"),
            MessageType.INFO.getDefaultIcon(),
            SwingConstants.LEFT),
        "newline, sx 5");
    add(myUseSecondaryFontCheckbox, "newline, ax right");
    add(mySecondaryCombo, "sgx b");
    JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 0));
    myEnableLigaturesCheckbox.setBorder(null);
    panel.add(myEnableLigaturesCheckbox);
    myLigaturesInfoLinkLabel =
        new LinkLabel<Void>(
            ApplicationBundle.message("ligatures.more.info"),
            null,
            new LinkListener<Void>() {
              @Override
              public void linkSelected(LinkLabel aSource, Void aLinkData) {
                BrowserUtil.browse(
                    "https://confluence.jetbrains.com/display/IDEADEV/Support+for+Ligatures+in+Editor");
              }
            });
    myLigaturesInfoLinkLabel.setBorder(new EmptyBorder(0, 5, 0, 0));
    panel.add(myLigaturesInfoLinkLabel);
    add(panel, "newline, sx 2");

    myOnlyMonospacedCheckBox.setBorder(null);
    myUseSecondaryFontCheckbox.setBorder(null);
    mySecondaryCombo.setEnabled(false);

    myOnlyMonospacedCheckBox.setSelected(
        EditorColorsManager.getInstance().isUseOnlyMonospacedFonts());
    myOnlyMonospacedCheckBox.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            EditorColorsManager.getInstance()
                .setUseOnlyMonospacedFonts(myOnlyMonospacedCheckBox.isSelected());
            myPrimaryCombo.setMonospacedOnly(myOnlyMonospacedCheckBox.isSelected());
            mySecondaryCombo.setMonospacedOnly(myOnlyMonospacedCheckBox.isSelected());
          }
        });
    myPrimaryCombo.setMonospacedOnly(myOnlyMonospacedCheckBox.isSelected());
    myPrimaryCombo.setRenderer(RENDERER);

    mySecondaryCombo.setMonospacedOnly(myOnlyMonospacedCheckBox.isSelected());
    mySecondaryCombo.setRenderer(RENDERER);

    myUseSecondaryFontCheckbox.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            mySecondaryCombo.setEnabled(myUseSecondaryFontCheckbox.isSelected());
            syncFontFamilies();
          }
        });
    ItemListener itemListener =
        new ItemListener() {
          @Override
          public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
              syncFontFamilies();
            }
          }
        };
    myPrimaryCombo.addItemListener(itemListener);
    mySecondaryCombo.addItemListener(itemListener);

    ActionListener actionListener =
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            syncFontFamilies();
          }
        };
    myPrimaryCombo.addActionListener(actionListener);
    mySecondaryCombo.addActionListener(actionListener);

    myEditorFontSizeField
        .getDocument()
        .addDocumentListener(
            new DocumentAdapter() {
              @Override
              public void textChanged(DocumentEvent event) {
                if (myIsInSchemeChange || !SwingUtilities.isEventDispatchThread()) return;
                String selectedFont = myPrimaryCombo.getFontName();
                if (selectedFont != null) {
                  FontPreferences fontPreferences = getFontPreferences();
                  fontPreferences.register(selectedFont, getFontSizeFromField());
                }
                updateDescription(true);
              }
            });
    myEditorFontSizeField.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() != KeyEvent.VK_UP && e.getKeyCode() != KeyEvent.VK_DOWN) return;
            boolean up = e.getKeyCode() == KeyEvent.VK_UP;
            try {
              int value = Integer.parseInt(myEditorFontSizeField.getText());
              value += (up ? 1 : -1);
              value =
                  Math.min(
                      OptionsConstants.MAX_EDITOR_FONT_SIZE,
                      Math.max(OptionsConstants.MIN_EDITOR_FONT_SIZE, value));
              myEditorFontSizeField.setText(String.valueOf(value));
            } catch (NumberFormatException ignored) {
            }
          }
        });

    myLineSpacingField
        .getDocument()
        .addDocumentListener(
            new DocumentAdapter() {
              @Override
              public void textChanged(DocumentEvent event) {
                if (myIsInSchemeChange) return;
                float lineSpacing = getLineSpacingFromField();
                if (getLineSpacing() != lineSpacing) {
                  setCurrentLineSpacing(lineSpacing);
                }
                updateDescription(true);
              }
            });
    myLineSpacingField.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() != KeyEvent.VK_UP && e.getKeyCode() != KeyEvent.VK_DOWN) return;
            boolean up = e.getKeyCode() == KeyEvent.VK_UP;
            try {
              float value = Float.parseFloat(myLineSpacingField.getText());
              value += (up ? 1 : -1) * .1F;
              value =
                  Math.min(
                      OptionsConstants.MAX_EDITOR_LINE_SPACING,
                      Math.max(OptionsConstants.MIN_EDITOR_LINE_SPACING, value));
              myLineSpacingField.setText(String.format(Locale.ENGLISH, "%.1f", value));
            } catch (NumberFormatException ignored) {
            }
          }
        });
    myEnableLigaturesCheckbox.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            getFontPreferences().setUseLigatures(myEnableLigaturesCheckbox.isSelected());
          }
        });
  }
  public CloudAttachDialog(@NotNull Project project) {
    super(project, true);

    myProject = project;
    init();
    initValidation();
    setTitle(GctBundle.getString("clouddebug.attachtitle"));
    setOKButtonText(GctBundle.getString("clouddebug.attach"));
    mySyncStashCheckbox.setVisible(false);
    mySyncStashCheckbox.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            if (mySyncStashCheckbox.isVisible()) {
              myWarningLabel.setVisible(!mySyncStashCheckbox.isSelected());
              myWarningLabel2.setVisible(!mySyncStashCheckbox.isSelected());
              myInfoPanel.setVisible(mySyncStashCheckbox.isSelected());
              if (mySyncStashCheckbox.isSelected()) {
                setOKButtonText(
                    isContinued()
                        ? GctBundle.getString("clouddebug.continuesession")
                        : GctBundle.getString("clouddebug.attach"));
              } else {
                setOKButtonText(
                    isContinued()
                        ? GctBundle.getString("clouddebug.continueanyway")
                        : GctBundle.getString("clouddebug.attach.anyway"));
              }
            }
          }
        });

    myWarningLabel.setVisible(false);
    myWarningLabel.setFont(
        new Font(
            myWarningLabel.getFont().getName(), Font.BOLD, myWarningLabel.getFont().getSize() - 1));
    myWarningLabel.setForeground(JBColor.RED);
    myWarningLabel2.setVisible(false);
    myWarningLabel2.setFont(
        new Font(
            myWarningLabel2.getFont().getName(),
            Font.PLAIN,
            myWarningLabel.getFont().getSize() - 1));
    myWarningLabel2.setText(GctBundle.getString("clouddebug.sourcedoesnotmatch"));

    myInfoPanel.setFont(
        new Font(
            myWarningLabel2.getFont().getName(),
            Font.PLAIN,
            myWarningLabel.getFont().getSize() - 1));
    Border paddingBorder = BorderFactory.createEmptyBorder(2, 0, 2, 0);
    myInfoPanel.setBorder(paddingBorder);

    Window myWindow = getWindow();
    if (myWindow != null) {
      myWindow.setPreferredSize(new Dimension(355, 175));
    }
    BasicAction.saveAll();

    myWireup = new ProjectDebuggeeBinding(myElysiumProjectId, myDebuggeeTarget);
    myDebuggeeTarget.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            buildResult();
            checkSyncStashState();
            setOKActionEnabled(doValidate() == null);
          }
        });

    setOKActionEnabled(isContinued() || doValidate() == null);
  }