[deckeditor] done with list view for main and sideboard. (not tested in tournaments)

This commit is contained in:
magenoxx 2011-06-17 13:55:34 +04:00
parent a934d2733c
commit 7dc036ccee
3 changed files with 126 additions and 19 deletions

View file

@ -27,15 +27,15 @@
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jPanel1" alignment="0" max="32767" attributes="0"/>
<Component id="jScrollPane1" alignment="0" pref="325" max="32767" attributes="0"/>
<Component id="jScrollPane1" alignment="0" pref="808" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Component id="jPanel1" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
<Component id="jScrollPane1" pref="23" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jScrollPane1" pref="305" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@ -62,10 +62,14 @@
<Component id="lblCreatureCount" min="-2" pref="100" max="-2" attributes="0"/>
<EmptySpace type="unrelated" min="-2" max="-2" attributes="0"/>
<Component id="lblLandCount" min="-2" pref="75" max="-2" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="chkPiles" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="cbSortBy" pref="0" max="32767" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="jToggleListView" min="-2" pref="76" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jToggleCardView" min="-2" pref="85" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@ -76,7 +80,9 @@
<Component id="lblCount" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblCreatureCount" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblLandCount" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jToggleCardView" alignment="3" min="-2" pref="21" max="-2" attributes="0"/>
<Component id="chkPiles" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jToggleListView" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@ -112,6 +118,43 @@
<Property name="text" type="java.lang.String" value="Land Count"/>
</Properties>
</Component>
<Component class="javax.swing.JToggleButton" name="jToggleListView">
<Properties>
<Property name="selected" type="boolean" value="true"/>
<Property name="text" type="java.lang.String" value="ListView"/>
<Property name="focusable" type="boolean" value="false"/>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[45, 21]"/>
</Property>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[54, 21]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[45, 21]"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jToggleListViewActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JToggleButton" name="jToggleCardView">
<Properties>
<Property name="text" type="java.lang.String" value="CardView"/>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[77, 21]"/>
</Property>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[77, 21]"/>
</Property>
<Property name="opaque" type="boolean" value="true"/>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[77, 21]"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jToggleCardViewActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JCheckBox" name="chkPiles">
<Properties>
<Property name="text" type="java.lang.String" value="Piles"/>

View file

@ -77,9 +77,8 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
public CardsList() {
initComponents();
makeTransparent();
//initListViewComponents();
//currentView = mainModel; // by default we have List (table) view
currentView = this;
initListViewComponents();
currentView = mainModel; // by default we use List View
}
public void makeTransparent() {
@ -109,12 +108,12 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
mainTable.getColumnModel().getColumn(6).setPreferredWidth(15);
mainTable.getColumnModel().getColumn(7).setPreferredWidth(15);
//jScrollPane1.setViewportView(mainTable);
jScrollPane1.setViewportView(mainTable);
mainTable.setOpaque(false);
//cbSortBy.setEnabled(false);
//chkPiles.setEnabled(false);
cbSortBy.setEnabled(false);
chkPiles.setEnabled(false);
mainTable.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
@ -133,6 +132,10 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
});
}
public ICardGrid getMainModel() {
return mainModel;
}
public List<Integer> asList(final int[] is) {
List<Integer> list = new ArrayList<Integer>();
for (int i : is) list.add(i);
@ -140,10 +143,17 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
}
public void loadCards(CardsView showCards, BigCard bigCard, UUID gameId) {
this.cards = showCards;
this.bigCard = bigCard;
this.gameId = gameId;
currentView.loadCards(showCards, null, false, bigCard, gameId);
//loadCards(showCards, null, false, bigCard, gameId);
}
private void redrawCards() {
currentView.loadCards(cards, null, false, bigCard, gameId);
}
public void drawCards(SortBy sortBy, boolean piles) {
int maxWidth = this.getParent().getWidth();
int numColumns = maxWidth / Config.dimensions.frameWidth;
@ -250,7 +260,7 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
public void addCardEventListener(Listener<Event> listener) {
cardEventSource.addListener(listener);
//mainModel.addCardEventListener(listener);
mainModel.addCardEventListener(listener);
}
public void drawCards(SortBy sortBy) {
@ -268,6 +278,7 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
public void clearCardEventListeners() {
cardEventSource.clearListeners();
mainModel.clearCardEventListeners();
}
/** This method is called from within the constructor to
@ -286,6 +297,8 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
lblCount = new javax.swing.JLabel();
lblCreatureCount = new javax.swing.JLabel();
lblLandCount = new javax.swing.JLabel();
jToggleListView = new javax.swing.JToggleButton();
jToggleCardView = new javax.swing.JToggleButton();
chkPiles = new javax.swing.JCheckBox();
setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
@ -306,6 +319,29 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
lblLandCount.setText("Land Count");
jToggleListView.setSelected(true);
jToggleListView.setText("ListView");
jToggleListView.setFocusable(false);
jToggleListView.setMaximumSize(new java.awt.Dimension(45, 21));
jToggleListView.setMinimumSize(new java.awt.Dimension(54, 21));
jToggleListView.setPreferredSize(new java.awt.Dimension(45, 21));
jToggleListView.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jToggleListViewActionPerformed(evt);
}
});
jToggleCardView.setText("CardView");
jToggleCardView.setMaximumSize(new java.awt.Dimension(77, 21));
jToggleCardView.setMinimumSize(new java.awt.Dimension(77, 21));
jToggleCardView.setOpaque(true);
jToggleCardView.setPreferredSize(new java.awt.Dimension(77, 21));
jToggleCardView.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jToggleCardViewActionPerformed(evt);
}
});
chkPiles.setText("Piles");
chkPiles.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
@ -325,8 +361,12 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
.addComponent(lblLandCount, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(chkPiles)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(cbSortBy, 0, 0, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jToggleListView, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cbSortBy, 0, 0, Short.MAX_VALUE))
.addComponent(jToggleCardView, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@ -335,7 +375,9 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
.addComponent(lblCount)
.addComponent(lblCreatureCount)
.addComponent(lblLandCount)
.addComponent(chkPiles))
.addComponent(jToggleCardView, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(chkPiles)
.addComponent(jToggleListView, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
@ -343,14 +385,14 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 636, Short.MAX_VALUE)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 808, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, 0)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 366, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 305, Short.MAX_VALUE))
);
}// </editor-fold>//GEN-END:initComponents
@ -362,12 +404,34 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
drawCards((SortBy) cbSortBy.getSelectedItem());
}//GEN-LAST:event_chkPilesActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private void jToggleListViewActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleListViewActionPerformed
jToggleCardView.setSelected(false);
currentView = mainModel;
jScrollPane1.setViewportView(mainTable);
cbSortBy.setEnabled(false);
chkPiles.setEnabled(false);
//drawCards((SortBy) cbSortBy.getSelectedItem());
redrawCards();
}//GEN-LAST:event_jToggleListViewActionPerformed
private void jToggleCardViewActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleCardViewActionPerformed
jToggleListView.setSelected(false);
currentView = this;
jScrollPane1.setViewportView(cardArea);
cbSortBy.setEnabled(false);
chkPiles.setEnabled(false);
//drawCards((SortBy) cbSortBy.getSelectedItem());
redrawCards();
}//GEN-LAST:event_jToggleCardViewActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JLayeredPane cardArea;
private javax.swing.JComboBox cbSortBy;
private javax.swing.JCheckBox chkPiles;
private javax.swing.JPanel jPanel1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JToggleButton jToggleCardView;
private javax.swing.JToggleButton jToggleListView;
private javax.swing.JLabel lblCount;
private javax.swing.JLabel lblCreatureCount;
private javax.swing.JLabel lblLandCount;

View file

@ -72,7 +72,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
initComponents();
makeTransparent();
initListViewComponents();
currentView = mainModel; // by default we have List (table) view
currentView = mainModel; // by default we use List View
}
public void makeTransparent() {