use of org.magic.gui.models.CardStockTableModel in project MtgDesktopCompanion by nicho92.
the class StockPanelGUI method initGUI.
private void initGUI() {
JLabel lblSelect;
JPanel bottomPanel;
JLabel lblCollection;
JLabel lblQuality;
JLabel lblFoil;
JLabel lblSigned;
JLabel lblAltered;
JSplitPane splitPane;
JLabel lblQte;
JLabel lblLanguage;
JLabel lblComment;
setLayout(new BorderLayout(0, 0));
model = new CardStockTableModel();
magicCardDetailPanel = new MagicCardDetailPanel();
JPanel centerPanel = new JPanel();
add(centerPanel, BorderLayout.CENTER);
centerPanel.setLayout(new BorderLayout(0, 0));
JPanel actionPanel = new JPanel();
centerPanel.add(actionPanel, BorderLayout.NORTH);
btnDelete.setEnabled(false);
btnDelete.setIcon(MTGConstants.ICON_DELETE);
actionPanel.add(btnDelete);
btnSave.setToolTipText(MTGControler.getInstance().getLangService().getCapitalize("BATCH_SAVE"));
btnSave.setIcon(MTGConstants.ICON_SAVE);
actionPanel.add(btnSave);
btnReload = new JButton("");
btnReload.setIcon(MTGConstants.ICON_REFRESH);
btnReload.setToolTipText(MTGControler.getInstance().getLangService().getCapitalize("RELOAD"));
actionPanel.add(btnReload);
lblLoading = new JLabel();
lblLoading.setVisible(false);
btnshowMassPanel = new JButton("");
btnImport = new JButton();
btnImport.setIcon(MTGConstants.ICON_IMPORT);
btnImport.setToolTipText(MTGControler.getInstance().getLangService().getCapitalize("IMPORT"));
actionPanel.add(btnImport);
btnExport = new JButton("");
btnExport.setToolTipText(MTGControler.getInstance().getLangService().getCapitalize("EXPORT"));
btnExport.setIcon(MTGConstants.ICON_EXPORT);
actionPanel.add(btnExport);
btnGeneratePrice = new JButton();
btnGeneratePrice.setIcon(MTGConstants.ICON_EURO);
btnGeneratePrice.setToolTipText(MTGControler.getInstance().getLangService().getCapitalize("GENERATE_PRICE"));
actionPanel.add(btnGeneratePrice);
btnshowMassPanel.setToolTipText(MTGControler.getInstance().getLangService().getCapitalize("MASS_MODIFICATION"));
btnshowMassPanel.setIcon(MTGConstants.ICON_MANUAL);
actionPanel.add(btnshowMassPanel);
lblLoading.setIcon(MTGConstants.ICON_LOADING);
actionPanel.add(lblLoading);
JScrollPane scrollTable = new JScrollPane();
table = new JXTable(model);
StockTableRenderer render = new StockTableRenderer();
table.setDefaultRenderer(Object.class, render);
table.setDefaultEditor(EnumCondition.class, new EnumConditionEditor());
table.setDefaultEditor(Integer.class, new IntegerCellEditor());
table.getColumnModel().getColumn(2).setCellEditor(new MagicEditionListEditor());
table.getColumnModel().getColumn(2).setCellRenderer(new MagicEditionRenderer());
table.packAll();
new TableFilterHeader(table, AutoChoices.ENABLED);
scrollTable.setViewportView(table);
magicCardDetailPanel.enableThumbnail(true);
splitPane = new JSplitPane();
splitPane.setDividerLocation(0.5);
splitPane.setResizeWeight(0.5);
splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
centerPanel.add(splitPane, BorderLayout.CENTER);
splitPane.setLeftComponent(scrollTable);
splitPane.setRightComponent(magicCardDetailPanel);
rightPanel = new JPanel();
rightPanel.setBackground(SystemColor.inactiveCaption);
rightPanel.setVisible(false);
add(rightPanel, BorderLayout.EAST);
GridBagLayout gblrightPanel = new GridBagLayout();
gblrightPanel.columnWidths = new int[] { 84, 103, 0 };
gblrightPanel.rowHeights = new int[] { 83, 56, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
gblrightPanel.columnWeights = new double[] { 0.0, 1.0, Double.MIN_VALUE };
gblrightPanel.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE };
rightPanel.setLayout(gblrightPanel);
lblSelect = new JLabel("Select :");
GridBagConstraints gbclblSelect = new GridBagConstraints();
gbclblSelect.anchor = GridBagConstraints.NORTHEAST;
gbclblSelect.insets = new Insets(0, 0, 5, 5);
gbclblSelect.gridx = 0;
gbclblSelect.gridy = 1;
rightPanel.add(lblSelect, gbclblSelect);
cboSelections = new JComboBox<>();
cboSelections.setModel(new DefaultComboBoxModel<String>(selections));
GridBagConstraints gbccomboBox = new GridBagConstraints();
gbccomboBox.anchor = GridBagConstraints.NORTH;
gbccomboBox.insets = new Insets(0, 0, 5, 0);
gbccomboBox.fill = GridBagConstraints.HORIZONTAL;
gbccomboBox.gridx = 1;
gbccomboBox.gridy = 1;
rightPanel.add(cboSelections, gbccomboBox);
lblQte = new JLabel(MTGControler.getInstance().getLangService().getCapitalize("QTY") + " :");
GridBagConstraints gbclblQte = new GridBagConstraints();
gbclblQte.anchor = GridBagConstraints.EAST;
gbclblQte.insets = new Insets(0, 0, 5, 5);
gbclblQte.gridx = 0;
gbclblQte.gridy = 2;
rightPanel.add(lblQte, gbclblQte);
spinner = new JSpinner();
spinner.setModel(new SpinnerNumberModel(0, 0, null, 1));
GridBagConstraints gbcspinner = new GridBagConstraints();
gbcspinner.fill = GridBagConstraints.HORIZONTAL;
gbcspinner.insets = new Insets(0, 0, 5, 0);
gbcspinner.gridx = 1;
gbcspinner.gridy = 2;
rightPanel.add(spinner, gbcspinner);
lblLanguage = new JLabel(MTGControler.getInstance().getLangService().getCapitalize("CARD_LANGUAGE") + " :");
GridBagConstraints gbclblLanguage = new GridBagConstraints();
gbclblLanguage.anchor = GridBagConstraints.EAST;
gbclblLanguage.insets = new Insets(0, 0, 5, 5);
gbclblLanguage.gridx = 0;
gbclblLanguage.gridy = 3;
rightPanel.add(lblLanguage, gbclblLanguage);
DefaultComboBoxModel<String> lModel = new DefaultComboBoxModel<>();
lModel.addElement(null);
for (Locale l : Locale.getAvailableLocales()) lModel.addElement(l.getDisplayLanguage(Locale.US));
cboLanguages = new JComboBox<>(lModel);
GridBagConstraints gbccboLanguages = new GridBagConstraints();
gbccboLanguages.insets = new Insets(0, 0, 5, 0);
gbccboLanguages.fill = GridBagConstraints.HORIZONTAL;
gbccboLanguages.gridx = 1;
gbccboLanguages.gridy = 3;
rightPanel.add(cboLanguages, gbccboLanguages);
lblFoil = new JLabel(MTGControler.getInstance().getLangService().getCapitalize("FOIL") + " :");
GridBagConstraints gbclblFoil = new GridBagConstraints();
gbclblFoil.anchor = GridBagConstraints.EAST;
gbclblFoil.insets = new Insets(0, 0, 5, 5);
gbclblFoil.gridx = 0;
gbclblFoil.gridy = 4;
rightPanel.add(lblFoil, gbclblFoil);
cboFoil = new JComboBox<>(new DefaultComboBoxModel<Boolean>(values));
GridBagConstraints gbccboFoil = new GridBagConstraints();
gbccboFoil.insets = new Insets(0, 0, 5, 0);
gbccboFoil.fill = GridBagConstraints.HORIZONTAL;
gbccboFoil.gridx = 1;
gbccboFoil.gridy = 4;
rightPanel.add(cboFoil, gbccboFoil);
lblSigned = new JLabel(MTGControler.getInstance().getLangService().getCapitalize("SIGNED") + " :");
GridBagConstraints gbclblSigned = new GridBagConstraints();
gbclblSigned.anchor = GridBagConstraints.EAST;
gbclblSigned.insets = new Insets(0, 0, 5, 5);
gbclblSigned.gridx = 0;
gbclblSigned.gridy = 5;
rightPanel.add(lblSigned, gbclblSigned);
cboSigned = new JComboBox<>(new DefaultComboBoxModel<Boolean>(values));
GridBagConstraints gbccboSigned = new GridBagConstraints();
gbccboSigned.insets = new Insets(0, 0, 5, 0);
gbccboSigned.fill = GridBagConstraints.HORIZONTAL;
gbccboSigned.gridx = 1;
gbccboSigned.gridy = 5;
rightPanel.add(cboSigned, gbccboSigned);
lblAltered = new JLabel(MTGControler.getInstance().getLangService().getCapitalize("ALTERED") + " :");
GridBagConstraints gbclblAltered = new GridBagConstraints();
gbclblAltered.anchor = GridBagConstraints.EAST;
gbclblAltered.insets = new Insets(0, 0, 5, 5);
gbclblAltered.gridx = 0;
gbclblAltered.gridy = 6;
rightPanel.add(lblAltered, gbclblAltered);
cboAltered = new JComboBox<>(new DefaultComboBoxModel<Boolean>(values));
GridBagConstraints gbccboAltered = new GridBagConstraints();
gbccboAltered.insets = new Insets(0, 0, 5, 0);
gbccboAltered.fill = GridBagConstraints.HORIZONTAL;
gbccboAltered.gridx = 1;
gbccboAltered.gridy = 6;
rightPanel.add(cboAltered, gbccboAltered);
lblQuality = new JLabel(MTGControler.getInstance().getLangService().getCapitalize("QUALITY") + " :");
GridBagConstraints gbclblQuality = new GridBagConstraints();
gbclblQuality.anchor = GridBagConstraints.EAST;
gbclblQuality.insets = new Insets(0, 0, 5, 5);
gbclblQuality.gridx = 0;
gbclblQuality.gridy = 7;
rightPanel.add(lblQuality, gbclblQuality);
DefaultComboBoxModel<EnumCondition> qModel = new DefaultComboBoxModel<>();
qModel.addElement(null);
for (EnumCondition l : EnumCondition.values()) qModel.addElement(l);
cboQuality = new JComboBox<>(qModel);
GridBagConstraints gbccboQuality = new GridBagConstraints();
gbccboQuality.insets = new Insets(0, 0, 5, 0);
gbccboQuality.fill = GridBagConstraints.HORIZONTAL;
gbccboQuality.gridx = 1;
gbccboQuality.gridy = 7;
rightPanel.add(cboQuality, gbccboQuality);
lblCollection = new JLabel(MTGControler.getInstance().getLangService().getCapitalize("COLLECTION") + " :");
GridBagConstraints gbclblCollection = new GridBagConstraints();
gbclblCollection.anchor = GridBagConstraints.EAST;
gbclblCollection.insets = new Insets(0, 0, 5, 5);
gbclblCollection.gridx = 0;
gbclblCollection.gridy = 8;
rightPanel.add(lblCollection, gbclblCollection);
DefaultComboBoxModel<MagicCollection> cModel = new DefaultComboBoxModel<>();
cModel.addElement(null);
try {
for (MagicCollection l : MTGControler.getInstance().getEnabledDAO().getCollections()) cModel.addElement(l);
} catch (SQLException e1) {
MTGLogger.printStackTrace(e1);
}
cboCollection = new JComboBox<>(cModel);
GridBagConstraints gbccboCollection = new GridBagConstraints();
gbccboCollection.insets = new Insets(0, 0, 5, 0);
gbccboCollection.fill = GridBagConstraints.HORIZONTAL;
gbccboCollection.gridx = 1;
gbccboCollection.gridy = 8;
rightPanel.add(cboCollection, gbccboCollection);
lblComment = new JLabel("Comment :");
GridBagConstraints gbclblComment = new GridBagConstraints();
gbclblComment.insets = new Insets(0, 0, 5, 5);
gbclblComment.gridx = 0;
gbclblComment.gridy = 9;
rightPanel.add(lblComment, gbclblComment);
textPane = new JTextPane();
GridBagConstraints gbctextPane = new GridBagConstraints();
gbctextPane.insets = new Insets(0, 0, 5, 0);
gbctextPane.gridwidth = 2;
gbctextPane.gridheight = 3;
gbctextPane.fill = GridBagConstraints.BOTH;
gbctextPane.gridx = 0;
gbctextPane.gridy = 10;
rightPanel.add(textPane, gbctextPane);
btnApplyModification = new JButton(MTGControler.getInstance().getLangService().getCapitalize("APPLY"));
GridBagConstraints gbcbtnApplyModification = new GridBagConstraints();
gbcbtnApplyModification.gridwidth = 2;
gbcbtnApplyModification.gridx = 0;
gbcbtnApplyModification.gridy = 13;
rightPanel.add(btnApplyModification, gbcbtnApplyModification);
bottomPanel = new JPanel();
add(bottomPanel, BorderLayout.SOUTH);
lblCount = new JLabel();
bottomPanel.add(lblCount);
ThreadManager.getInstance().execute(() -> {
try {
lblLoading.setVisible(true);
model.init();
} catch (SQLException e1) {
JOptionPane.showMessageDialog(null, e1.getMessage(), MTGControler.getInstance().getLangService().getError(), JOptionPane.ERROR_MESSAGE);
}
lblLoading.setVisible(false);
updateCount();
}, "init stock");
}
Aggregations