Search in sources :

Example 1 with RepositoryEvent

use of mage.cards.repository.RepositoryEvent in project mage by magefree.

the class CollectionViewerPanel method initComponents.

public void initComponents() {
    buttonsPanel = new javax.swing.JPanel();
    buttonsPanel.setOpaque(false);
    bigCard = new BigCard();
    BoxLayout boxlayout = new BoxLayout(buttonsPanel, BoxLayout.PAGE_AXIS);
    buttonsPanel.setLayout(boxlayout);
    btnExit = new javax.swing.JButton();
    btnExit.setAlignmentX(Component.LEFT_ALIGNMENT);
    buttonsPanel.add(btnExit);
    JLabel label1 = new JLabel("Choose format:");
    label1.setAlignmentX(Component.LEFT_ALIGNMENT);
    label1.setForeground(Color.white);
    buttonsPanel.add(label1);
    // SELECT SET
    // panel
    setPanel = new JPanel();
    setPanel.setLayout(new javax.swing.BoxLayout(setPanel, javax.swing.BoxLayout.LINE_AXIS));
    setPanel.setOpaque(false);
    setPanel.setPreferredSize(new Dimension(200, 25));
    setPanel.setMaximumSize(new Dimension(200, 25));
    setPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    buttonsPanel.add(setPanel);
    // combo set
    formats = new JComboBox<>();
    reloadFormatCombobox();
    // auto-update sets list on changes
    setsDbListener = new Listener<RepositoryEvent>() {

        @Override
        public void event(RepositoryEvent event) {
            if (event.getEventType().equals(RepositoryEvent.RepositoryEventType.DB_UPDATED)) {
                reloadFormatCombobox();
            }
        }
    };
    ExpansionRepository.instance.subscribe(setsDbListener);
    // update cards on format combobox changes
    formats.addActionListener(e -> {
        if (mageBook != null) {
            String format = (String) formats.getSelectedItem();
            MageFrame.getPreferences().put(CollectionViewerPanel.FORMAT_CONFIG_KEY, format);
            mageBook.updateDispayedSets(format);
        }
    });
    formats.setAlignmentX(0.0F);
    formats.setMinimumSize(new Dimension(50, 25));
    formats.setPreferredSize(new Dimension(50, 25));
    formats.setMaximumSize(new Dimension(Integer.MAX_VALUE, 25));
    setPanel.add(formats);
    // search button
    btnSetFastSearch = new JButton();
    btnSetFastSearch.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/search_24.png")));
    btnSetFastSearch.setToolTipText(FastSearchUtil.DEFAULT_EXPANSION_TOOLTIP_MESSAGE);
    btnSetFastSearch.setAlignmentX(1.0F);
    btnSetFastSearch.setMinimumSize(new java.awt.Dimension(24, 24));
    btnSetFastSearch.setPreferredSize(new java.awt.Dimension(32, 32));
    btnSetFastSearch.setMaximumSize(new java.awt.Dimension(32, 32));
    btnSetFastSearch.addActionListener(new java.awt.event.ActionListener() {

        @Override
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            FastSearchUtil.showFastSearchForStringComboBox(formats, FastSearchUtil.DEFAULT_EXPANSION_SEARCH_MESSAGE);
        }
    });
    setPanel.add(btnSetFastSearch);
    JLabel label2 = new JLabel("Choose size:");
    label2.setAlignmentX(Component.LEFT_ALIGNMENT);
    label2.setForeground(Color.white);
    buttonsPanel.add(label2);
    small3x3 = new JRadioButton("3x3");
    small3x3.setForeground(Color.white);
    boolean selected3x3 = MageFrame.getPreferences().get(LAYOYT_CONFIG_KEY, MageBook.LAYOUT_3X3).equals(MageBook.LAYOUT_3X3);
    small3x3.setSelected(selected3x3);
    small3x3.addActionListener(e -> {
        big4x4.setSelected(false);
        mageBook.updateSize(MageBook.LAYOUT_3X3);
        MageFrame.getPreferences().put(LAYOYT_CONFIG_KEY, MageBook.LAYOUT_3X3);
    });
    buttonsPanel.add(small3x3);
    big4x4 = new JRadioButton("4x4");
    big4x4.setForeground(Color.white);
    big4x4.setSelected(!selected3x3);
    big4x4.addActionListener(e -> {
        small3x3.setSelected(false);
        mageBook.updateSize(MageBook.LAYOUT_4X4);
        MageFrame.getPreferences().put(LAYOYT_CONFIG_KEY, MageBook.LAYOUT_4X4);
    });
    buttonsPanel.add(big4x4);
    JLabel label3 = new JLabel("Switch tabs:");
    label3.setAlignmentX(Component.LEFT_ALIGNMENT);
    label3.setForeground(Color.white);
    buttonsPanel.add(label3);
    JPanel buttonPanel = new JPanel();
    buttonPanel.setPreferredSize(new Dimension(200, 100));
    buttonPanel.setMaximumSize(new Dimension(Integer.MAX_VALUE, 100));
    buttonPanel.setOpaque(false);
    buttonPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    buttonsPanel.add(buttonPanel);
    JButton prev = new JButton("Prev");
    prev.addActionListener(e -> mageBook.prev());
    buttonPanel.add(prev);
    JButton next = new JButton("Next");
    next.addActionListener(e -> mageBook.next());
    buttonPanel.add(next);
    JLabel labelCardTokenSwitch = new JLabel("Show cards or tokens:");
    labelCardTokenSwitch.setAlignmentX(Component.LEFT_ALIGNMENT);
    labelCardTokenSwitch.setForeground(Color.white);
    buttonsPanel.add(labelCardTokenSwitch);
    JCheckBox cardsOrTokens = new JCheckBox("Display Cards");
    cardsOrTokens.setSelected(true);
    cardsOrTokens.setForeground(Color.white);
    cardsOrTokens.setToolTipText("Select to show Cards for the chosen set.  When unselected, will show Tokens, Emblems and Planes for the set instead");
    cardsOrTokens.addActionListener(e -> mageBook.cardsOrTokens(cardsOrTokens.isSelected()));
    buttonsPanel.add(cardsOrTokens);
    buttonsPanel.add(Box.createVerticalGlue());
    bigCard.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
    bigCard.setAlignmentX(Component.LEFT_ALIGNMENT);
    bigCard.setAlignmentY(Component.BOTTOM_ALIGNMENT);
    buttonsPanel.add(bigCard);
    jPanel2 = new MageBookContainer();
    jPanel2.setOpaque(false);
    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
    this.setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addComponent(buttonsPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 261, javax.swing.GroupLayout.PREFERRED_SIZE).addGap(0, 0, 0).addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 604, Short.MAX_VALUE)));
    layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(buttonsPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, 615, Short.MAX_VALUE));
    btnExit.setText("Exit");
    btnExit.addActionListener(evt -> btnExitActionPerformed(evt));
}
Also used : BigCard(mage.client.cards.BigCard) javax.swing(javax.swing) RepositoryEvent(mage.cards.repository.RepositoryEvent) java.awt(java.awt)

Aggregations

java.awt (java.awt)1 javax.swing (javax.swing)1 RepositoryEvent (mage.cards.repository.RepositoryEvent)1 BigCard (mage.client.cards.BigCard)1