private JPanel getClickableTagsPanel() {
    JPanel pnl = new JPanel();

    pnl.setLayout(new GridLayout(0, 3));

    ArrayList<Commontags> listTags = new ArrayList<>(mapAllTags.values());
    Collections.sort(listTags);

    for (final Commontags ctag : listTags) {
      JCheckBox cb = new JCheckBox(ctag.getText());

      cb.setForeground(GUITools.getColor(ctag.getColor()));
      cb.setFont(ctag.getType() == 0 ? SYSConst.ARIAL12 : SYSConst.ARIAL12BOLD);

      cb.setSelected(listSelectedTags.contains(ctag));

      cb.addItemListener(
          e -> {
            if (e.getStateChange() == ItemEvent.SELECTED) {
              listSelectedTags.add(ctag);
              add(createButton(ctag));
            } else {
              listSelectedTags.remove(ctag);
              mapButtons.remove(ctag);
            }
            notifyListeners(ctag);
          });

      pnl.add(cb);
    }
    return pnl;
  }
    public BooleanField(BooleanOption option) {
      super(option);

      checkbox = new JCheckBox();
      checkbox.setSelected(option.isDefault());
      checkbox.addItemListener(
          new ItemListener() {
            @Override
            public void itemStateChanged(ItemEvent e) {
              fireChangeEvent();
            }
          });
    }
示例#3
0
  /** Add listeners to components. */
  private void addListeners() {
    dirBttn.addActionListener(this);
    backupBttn.addActionListener(this);
    runBttn.addActionListener(this);

    recursiveCheckBox.addItemListener(this);
    templateCh.addItemListener(this);

    dirTF.addActionListener(this);

    staticVersioningRadioButton.addItemListener(this);
    dynamicVersioningRadioButton.addItemListener(this);

    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            quit();
          }
        });
  }
  /**
   * Creates dialog.
   *
   * @param aFrame parent frame.
   * @param aTitle dialog title.
   * @param aPublishingAvailable <code>TRUE</code> if publishing is available.
   * @param aPublishingLimit the number of guides the user can have published.
   * @param aPublishingLimitReached <code>TRUE</code> if the limit is reached.
   */
  public BasicGuideDialog(
      Frame aFrame,
      String aTitle,
      boolean aPublishingAvailable,
      int aPublishingLimit,
      boolean aPublishingLimitReached) {
    super(aFrame, aTitle);

    publishingAvailable = aPublishingAvailable;
    publishingLimit = aPublishingLimit;
    publishingLimitReached = aPublishingLimitReached;

    presentTitles = Collections.EMPTY_SET;
    model = new GuideIcons.ComboBoxModel();
    renderer = new IconListCellRenderer();
    readingListsModel = new ReadingListsTableModel();

    tblReadingLists = new JTable(readingListsModel);
    tblReadingLists.setDefaultRenderer(
        String.class, new ReadingListsTableCellRenderer(readingListsModel));
    UifUtilities.setTableColWidth(tblReadingLists, 2, 90);

    btnAddReadingList = new JButton(null, ResourceUtils.getIcon("add.icon"));
    btnAddReadingList.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            onAddReadingList();
          }
        });
    btnRemoveList = new JButton(null, ResourceUtils.getIcon("delete.icon"));
    btnRemoveList.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            onRemoveReadingList();
          }
        });

    // Publishing components
    chPublishingEnabled =
        ComponentsFactory.createCheckBox(Strings.message("guide.dialog.enable.publishing"));
    lbPublishingPublic = new JLabel(Strings.message("guide.dialog.public.visibility"));
    chPublishingPublic = new JCheckBox();
    lbPublishingTitle =
        ComponentsFactory.createLabel(Strings.message("guide.dialog.reading.list.title"));
    lbPublishingTags = ComponentsFactory.createLabel(Strings.message("guide.dialog.tags"));
    lbPublishingURL = new JLabel(Strings.message("guide.dialog.publicationurl"));
    lnkPublishingURL = new LinkLabel(Strings.message("guide.dialog.not.published.yet"));
    lbLastPublishingDate = new JLabel(Strings.message("guide.dialog.last.update.date"));
    tfLastPublishingDate = new JLabel(Strings.message("guide.dialog.never.updated"));
    tfPublishingTitle = new JTextField();
    lbPublishingTitle.setLabelFor(tfPublishingTitle);
    tfPublishingTags = new JTextField();
    lbPublishingTags.setLabelFor(tfPublishingTags);

    vhPublishingRating = new ValueHolder(1);
    sscPublishingRating =
        new StarsSelectionComponent(new BoundedRangeAdapter(vhPublishingRating, 0, 1, 5));
    lbPublishingRating = new JLabel(Strings.message("guide.dialog.rating"));

    btnCopyToClipboard = new JButton(Strings.message("guide.dialog.copy"));
    btnCopyToClipboard.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            CommonUtils.copyTextToClipboard(lnkPublishingURL.getText());
          }
        });

    onPublishingEnabled();
    chPublishingEnabled.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            onPublishingEnabled();
          }
        });

    chAllowNotifications =
        ComponentsFactory.createCheckBox(Strings.message("guide.dialog.allow.notifications"));
  }
  public MavenArchetypesStep(MavenModuleBuilder builder, @Nullable StepAdapter step) {
    myBuilder = builder;
    myStep = step;
    Disposer.register(this, myLoadingIcon);

    myArchetypesTree = new Tree();
    myArchetypesTree.setModel(new DefaultTreeModel(new DefaultMutableTreeNode()));
    JScrollPane archetypesScrollPane = ScrollPaneFactory.createScrollPane(myArchetypesTree);

    myArchetypesPanel.add(archetypesScrollPane, "archetypes");

    JPanel loadingPanel = new JPanel(new GridBagLayout());
    JPanel bp = new JPanel(new BorderLayout(10, 10));
    bp.add(new JLabel("Loading archetype list..."), BorderLayout.NORTH);
    bp.add(myLoadingIcon, BorderLayout.CENTER);

    loadingPanel.add(bp, new GridBagConstraints());

    myArchetypesPanel.add(ScrollPaneFactory.createScrollPane(loadingPanel), "loading");
    ((CardLayout) myArchetypesPanel.getLayout()).show(myArchetypesPanel, "archetypes");

    myUseArchetypeCheckBox.addItemListener(
        new ItemListener() {
          @Override
          public void itemStateChanged(ItemEvent e) {
            updateComponents();
            archetypeMayBeChanged();
          }
        });

    myAddArchetypeButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            doAddArchetype();
          }
        });

    myArchetypesTree.setRootVisible(false);
    myArchetypesTree.setShowsRootHandles(true);
    myArchetypesTree.setCellRenderer(new MyRenderer());
    myArchetypesTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);

    myArchetypesTree
        .getSelectionModel()
        .addTreeSelectionListener(
            new TreeSelectionListener() {
              public void valueChanged(TreeSelectionEvent e) {
                updateArchetypeDescription();
                archetypeMayBeChanged();
              }
            });

    new TreeSpeedSearch(
            myArchetypesTree,
            new Convertor<TreePath, String>() {
              public String convert(TreePath path) {
                MavenArchetype info =
                    getArchetypeInfoFromPathComponent(path.getLastPathComponent());
                return info.groupId + ":" + info.artifactId + ":" + info.version;
              }
            })
        .setComparator(new SpeedSearchComparator(false));

    myArchetypeDescriptionField.setEditable(false);
    myArchetypeDescriptionField.setBackground(UIUtil.getPanelBackground());

    requestUpdate();
    updateComponents();
  }