use of mage.client.deckeditor.table.TableModel in project mage by magefree.
the class CardsList method initListViewComponents.
private void initListViewComponents() {
mainTable = new JTable();
mainModel = new TableModel();
mainModel.addListeners(mainTable);
mainTable.setModel(mainModel);
mainTable.setForeground(Color.white);
DefaultTableCellRenderer myRenderer = (DefaultTableCellRenderer) mainTable.getDefaultRenderer(String.class);
myRenderer.setBackground(new Color(0, 0, 0, 100));
mainTable.getColumnModel().getColumn(0).setMaxWidth(25);
mainTable.getColumnModel().getColumn(0).setPreferredWidth(25);
mainTable.getColumnModel().getColumn(1).setPreferredWidth(110);
mainTable.getColumnModel().getColumn(2).setPreferredWidth(90);
mainTable.getColumnModel().getColumn(3).setPreferredWidth(50);
mainTable.getColumnModel().getColumn(4).setPreferredWidth(170);
mainTable.getColumnModel().getColumn(5).setPreferredWidth(30);
mainTable.getColumnModel().getColumn(6).setPreferredWidth(15);
mainTable.getColumnModel().getColumn(7).setPreferredWidth(15);
// new mana render (svg support)
mainTable.getColumnModel().getColumn(mainModel.COLUMN_INDEX_COST).setCellRenderer(new ManaSymbolsCellRenderer());
mainTable.getColumnModel().getColumn(mainModel.COLUMN_INDEX_COLOR_IDENTITY).setCellRenderer(new ManaSymbolsCellRenderer());
if (PreferencesDialog.getCachedValue(PreferencesDialog.KEY_DRAFT_VIEW, "cardView").equals("listView")) {
jToggleListView.setSelected(true);
panelCardArea.setViewportView(mainTable);
currentView = mainModel;
cbSortBy.setEnabled(false);
chkPiles.setEnabled(false);
} else {
jToggleCardView.setSelected(true);
currentView = this;
panelCardArea.setViewportView(cardArea);
cbSortBy.setEnabled(true);
chkPiles.setEnabled(true);
}
mainTable.setOpaque(false);
// ENABLE double clicks in table mode
mainTable.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
// simulate mouse click on the card
if ((e.getClickCount() & 1) == 0 && (e.getClickCount() > 0) && !e.isConsumed()) {
// double clicks and repeated double clicks
e.consume();
// TODO: replace on card's event source instead mouse listener
handleTableDoubleClick(e);
}
}
});
mainModel.setUpdateCountsCallback(new UpdateCountsCallback(lblCount, lblCreatureCount, lblLandCount, null, null, null, null));
// ENABLE popup menu for non card area
cardArea.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (e.isPopupTrigger() || SwingUtilities.isRightMouseButton(e)) {
cardEventSource.fireEvent(null, e.getComponent(), e.getX(), e.getY(), ClientEventType.CARD_POPUP_MENU);
}
}
});
}
use of mage.client.deckeditor.table.TableModel in project mage by magefree.
the class CardSelector method initListViewComponents.
private void initListViewComponents() {
mainTable = new JTable();
mainModel = new TableModel();
mainModel.addListeners(mainTable);
mainTable.setModel(mainModel);
mainTable.setForeground(Color.white);
DefaultTableCellRenderer myRenderer = (DefaultTableCellRenderer) mainTable.getDefaultRenderer(String.class);
myRenderer.setBackground(new Color(0, 0, 0, 100));
mainTable.getColumnModel().getColumn(0).setMaxWidth(0);
mainTable.getColumnModel().getColumn(0).setPreferredWidth(10);
mainTable.getColumnModel().getColumn(1).setPreferredWidth(110);
mainTable.getColumnModel().getColumn(2).setPreferredWidth(90);
mainTable.getColumnModel().getColumn(3).setPreferredWidth(50);
mainTable.getColumnModel().getColumn(4).setPreferredWidth(170);
mainTable.getColumnModel().getColumn(5).setPreferredWidth(30);
mainTable.getColumnModel().getColumn(6).setPreferredWidth(15);
mainTable.getColumnModel().getColumn(7).setPreferredWidth(15);
// new mana render (svg support)
mainTable.getColumnModel().getColumn(mainModel.COLUMN_INDEX_COST).setCellRenderer(new ManaSymbolsCellRenderer());
mainTable.getColumnModel().getColumn(mainModel.COLUMN_INDEX_COLOR_IDENTITY).setCellRenderer(new ManaSymbolsCellRenderer());
// mainTable.setToolTipText(cardSelectorScrollPane.getToolTipText());
cardSelectorScrollPane.setViewportView(mainTable);
mainTable.setOpaque(false);
cbSortBy.setEnabled(false);
chkPiles.setEnabled(false);
chkNames.setSelected("true".equals(MageFrame.getPreferences().get(KEY_DECK_EDITOR_SEARCH_NAMES, "true")));
chkTypes.setSelected("true".equals(MageFrame.getPreferences().get(KEY_DECK_EDITOR_SEARCH_TYPES, "true")));
chkRules.setSelected("true".equals(MageFrame.getPreferences().get(KEY_DECK_EDITOR_SEARCH_RULES, "true")));
chkUnique.setSelected("true".equals(MageFrame.getPreferences().get(KEY_DECK_EDITOR_SEARCH_UNIQUE, "false")));
mainTable.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
if ((e.getClickCount() & 1) == 0 && (e.getClickCount() > 0) && !e.isConsumed()) {
// double clicks and repeated double clicks
e.consume();
if (e.isAltDown()) {
jButtonAddToSideboardActionPerformed(null);
} else {
jButtonAddToMainActionPerformed(null);
}
}
}
});
jToggleCardView.setToolTipText(jToggleCardView.getToolTipText() + " (works only up to " + CardGrid.MAX_IMAGES + " cards).");
}
Aggregations