Search in sources :

Example 96 with KeyEvent

use of java.awt.event.KeyEvent in project MtgDesktopCompanion by nicho92.

the class ConstructPanel method initGUI.

private void initGUI() {
    JPanel panneauHaut = new JPanel();
    JButton btnSearch;
    JButton btnUpdate;
    HandPanel thumbnail;
    JPanel panelBottom;
    JTextField txtSearch;
    JComboBox<String> cboAttributs;
    JScrollPane scrollResult;
    JTabbedPane tabbedPane;
    ButtonGroup groupsFilterResult;
    lblExport.setIcon(MTGConstants.ICON_LOADING);
    lblExport.setVisible(false);
    setLayout(new BorderLayout(0, 0));
    deckmodel = new DeckModel(DeckModel.TYPE.DECK);
    deckSidemodel = new DeckModel(DeckModel.TYPE.SIDE);
    deckDetailsPanel = new DeckDetailsPanel();
    panelBottom = new JPanel();
    thumbnail = new HandPanel();
    thumbnail.setThumbnailSize(new Dimension(223, 311));
    thumbnail.enableDragging(false);
    thumbnail.setMaxCardsRow(4);
    FlowLayout flowLayout = (FlowLayout) panneauHaut.getLayout();
    flowLayout.setAlignment(FlowLayout.LEFT);
    add(panneauHaut, BorderLayout.NORTH);
    cboAttributs = new JComboBox<>(new DefaultComboBoxModel<String>(MTGControler.getInstance().getEnabledProviders().getQueryableAttributs()));
    panneauHaut.add(cboAttributs);
    txtSearch = new JTextField();
    panneauHaut.add(txtSearch);
    txtSearch.setColumns(25);
    btnSearch = new JButton(MTGConstants.ICON_SEARCH);
    panneauHaut.add(btnSearch);
    final JLabel lblCards = new JLabel();
    panneauHaut.add(lblCards);
    JButton btnNewDeck = new JButton(MTGConstants.ICON_NEW);
    btnNewDeck.setToolTipText(MTGControler.getInstance().getLangService().getCapitalize("CREATE_NEW_DECK"));
    panneauHaut.add(btnNewDeck);
    btnNewDeck.addActionListener(newDeckEvent -> {
        MagicDeck newDeck = new MagicDeck();
        setDeck(newDeck);
        deckmodel.init(newDeck);
        deckSidemodel.init(newDeck);
    });
    JButton btnOpen = new JButton(MTGConstants.ICON_OPEN);
    btnOpen.setToolTipText(MTGControler.getInstance().getLangService().getCapitalize("OPEN_DECK"));
    panneauHaut.add(btnOpen);
    btnOpen.addActionListener(openEvent -> {
        try {
            JDeckChooserDialog choose = new JDeckChooserDialog();
            choose.setVisible(true);
            deck = choose.getSelectedDeck();
            if (deck != null) {
                deckDetailsPanel.setMagicDeck(deck);
                deckmodel.init(deck);
                deckSidemodel.init(deck);
                setDeck(deck);
                updatePanels();
            }
        } catch (Exception ex) {
            logger.error(ex);
            JOptionPane.showMessageDialog(null, ex, MTGControler.getInstance().getLangService().getError(), JOptionPane.ERROR_MESSAGE);
        }
    });
    btnUpdate = new JButton();
    btnUpdate.setToolTipText(MTGControler.getInstance().getLangService().getCapitalize("UPDATE_DECK"));
    btnUpdate.addActionListener(updateEvent -> ThreadManager.getInstance().execute(() -> {
        Map<MagicCard, Integer> updateM = new HashMap<>();
        Map<MagicCard, Integer> updateS = new HashMap<>();
        btnUpdate.setEnabled(false);
        lblExport.setVisible(true);
        for (MagicCard mc : deck.getMap().keySet()) {
            try {
                updateM.put(MTGControler.getInstance().getEnabledProviders().getCardById(mc.getId()), deck.getMap().get(mc));
            } catch (Exception e) {
                logger.error(e);
                btnUpdate.setEnabled(true);
                lblExport.setVisible(false);
            }
        }
        for (MagicCard mc : deck.getMapSideBoard().keySet()) {
            try {
                updateS.put(MTGControler.getInstance().getEnabledProviders().getCardById(mc.getId()), deck.getMapSideBoard().get(mc));
            } catch (Exception e) {
                btnUpdate.setEnabled(true);
                lblExport.setVisible(false);
            }
        }
        deck.getMap().clear();
        deck.setMapDeck(updateM);
        deck.getMapSideBoard().clear();
        deck.setMapSideBoard(updateS);
        updatePanels();
        btnUpdate.setEnabled(true);
        lblExport.setVisible(false);
        JOptionPane.showMessageDialog(null, MTGControler.getInstance().getLangService().getCapitalize("UPDATED_DECK"), MTGControler.getInstance().getLangService().getCapitalize("FINISHED"), JOptionPane.INFORMATION_MESSAGE);
    }, "Update Deck"));
    btnUpdate.setIcon(MTGConstants.ICON_REFRESH);
    panneauHaut.add(btnUpdate);
    JButton btnSave = new JButton(MTGConstants.ICON_SAVE);
    btnSave.setToolTipText(MTGControler.getInstance().getLangService().getCapitalize("SAVE_DECK"));
    panneauHaut.add(btnSave);
    btnSave.addActionListener(e -> {
        try {
            String name = JOptionPane.showInputDialog(MTGControler.getInstance().getLangService().getCapitalize("DECK_NAME") + " ?", deck.getName());
            deck.setName(name);
            MTGControler.getInstance().saveDeck(deck);
        } catch (Exception ex) {
            logger.error("error saving", ex);
            JOptionPane.showMessageDialog(null, ex, MTGControler.getInstance().getLangService().getError(), JOptionPane.ERROR_MESSAGE);
        }
    });
    JButton btnImport = new JButton(MTGConstants.ICON_IMPORT);
    btnImport.setToolTipText(MTGControler.getInstance().getLangService().getCapitalize("DECK_IMPORT_AS"));
    btnImport.addActionListener(ae -> {
        JPopupMenu menu = new JPopupMenu();
        for (final MTGCardsExport exp : MTGControler.getInstance().getEnabledDeckExports()) {
            if (exp.getMods() == MODS.BOTH || exp.getMods() == MODS.IMPORT) {
                JMenuItem it = new JMenuItem();
                it.setIcon(exp.getIcon());
                it.setText(exp.getName());
                it.addActionListener(itEvent -> {
                    JFileChooser jf = new JFileChooser(".");
                    jf.setFileFilter(new FileFilter() {

                        @Override
                        public String getDescription() {
                            return exp.getName();
                        }

                        @Override
                        public boolean accept(File f) {
                            return (f.isDirectory() || f.getName().endsWith(exp.getFileExtension()));
                        }
                    });
                    int res = -1;
                    f = new File("");
                    if (!exp.needDialogGUI()) {
                        res = jf.showOpenDialog(null);
                        f = jf.getSelectedFile();
                    } else {
                        res = JFileChooser.APPROVE_OPTION;
                    }
                    if (res == JFileChooser.APPROVE_OPTION)
                        ThreadManager.getInstance().execute(() -> {
                            try {
                                loading(true, MTGControler.getInstance().getLangService().get("LOADING_FILE", f.getName(), exp));
                                deck = exp.importDeck(f);
                                JOptionPane.showMessageDialog(null, MTGControler.getInstance().getLangService().getCapitalize("FINISHED"), exp.getName() + " " + MTGControler.getInstance().getLangService().get("FINISHED"), JOptionPane.INFORMATION_MESSAGE);
                                setDeck(deck);
                                loading(false, "");
                                deckmodel.init(deck);
                                deckSidemodel.init(deck);
                                setDeck(deck);
                                updatePanels();
                            } catch (Exception e) {
                                logger.error("error import", e);
                                MTGLogger.printStackTrace(e);
                                loading(false, "");
                                JOptionPane.showMessageDialog(null, e, MTGControler.getInstance().getLangService().getError(), JOptionPane.ERROR_MESSAGE);
                            }
                        }, "import " + exp);
                });
                menu.add(it);
            }
        }
        Component b = (Component) ae.getSource();
        Point point = b.getLocationOnScreen();
        menu.show(b, 0, 0);
        menu.setLocation(point.x, point.y + b.getHeight());
    });
    panneauHaut.add(btnImport);
    btnExports = new JButton();
    btnExports.setEnabled(false);
    btnExports.setToolTipText(MTGControler.getInstance().getLangService().getCapitalize("EXPORT_AS"));
    btnExports.setIcon(MTGConstants.ICON_EXPORT);
    btnExports.addActionListener(exportsAction -> {
        JPopupMenu menu = new JPopupMenu();
        for (final MTGCardsExport exp : MTGControler.getInstance().getEnabledDeckExports()) {
            if (exp.getMods() == MODS.BOTH || exp.getMods() == MODS.EXPORT) {
                JMenuItem it = new JMenuItem();
                it.setIcon(exp.getIcon());
                it.setText(exp.getName());
                it.addActionListener(pluginExportEvent -> {
                    JFileChooser jf = new JFileChooser(".");
                    jf.setSelectedFile(new File(deck.getName() + exp.getFileExtension()));
                    jf.showSaveDialog(null);
                    exportedFile = jf.getSelectedFile();
                    ThreadManager.getInstance().execute(() -> {
                        try {
                            loading(true, MTGControler.getInstance().getLangService().get("EXPORT_TO", deck, exp));
                            exp.export(deck, exportedFile);
                            JOptionPane.showMessageDialog(null, MTGControler.getInstance().getLangService().combine("EXPORT", "FINISHED"), exp.getName() + " " + MTGControler.getInstance().getLangService().getCapitalize("FINISHED"), JOptionPane.INFORMATION_MESSAGE);
                            loading(false, "");
                        } catch (Exception e) {
                            logger.error(e);
                            loading(false, "");
                            JOptionPane.showMessageDialog(null, e, MTGControler.getInstance().getLangService().getError(), JOptionPane.ERROR_MESSAGE);
                        }
                    }, "Export " + deck + " to " + exp.getName());
                });
                menu.add(it);
            }
        }
        Component b = (Component) exportsAction.getSource();
        Point point = b.getLocationOnScreen();
        menu.show(b, 0, 0);
        menu.setLocation(point.x, point.y + b.getHeight());
    });
    panneauHaut.add(btnExports);
    panneauHaut.add(lblExport);
    JPanel panneauBas = new JPanel();
    add(panneauBas, BorderLayout.SOUTH);
    tabbedPane = new JTabbedPane(JTabbedPane.TOP);
    add(tabbedPane, BorderLayout.CENTER);
    JSplitPane panneauDeck = new JSplitPane();
    panneauDeck.setOrientation(JSplitPane.VERTICAL_SPLIT);
    tabbedPane.addTab(MTGControler.getInstance().getLangService().getCapitalize("DECK"), null, panneauDeck, null);
    DefaultRowSorter sorterCards = new TableRowSorter<DefaultTableModel>(deckmodel);
    magicCardDetailPanel = new MagicCardDetailPanel();
    magicCardDetailPanel.setPreferredSize(new Dimension(0, 0));
    magicCardDetailPanel.enableThumbnail(true);
    panelBottom.setLayout(new BorderLayout(0, 0));
    panelBottom.add(magicCardDetailPanel);
    panneauDeck.setRightComponent(panelBottom);
    cardDrawProbaPanel = new DrawProbabilityPanel();
    panelBottom.add(cardDrawProbaPanel, BorderLayout.EAST);
    final JTabbedPane tabbedDeckSide = new JTabbedPane(JTabbedPane.BOTTOM);
    panneauDeck.setLeftComponent(tabbedDeckSide);
    JScrollPane scrollDeck = new JScrollPane();
    tabbedDeckSide.addTab("Main", null, scrollDeck, null);
    tableDeck = new JTable();
    scrollDeck.setViewportView(tableDeck);
    tableDeck.setModel(deckmodel);
    tableDeck.getColumnModel().getColumn(2).setCellRenderer(new ManaCellRenderer());
    tableDeck.setRowHeight(MTGConstants.TABLE_ROW_HEIGHT);
    tableDeck.setRowSorter(sorterCards);
    tableDeck.getColumnModel().getColumn(4).setCellEditor(new IntegerCellEditor());
    tableDeck.getColumnModel().getColumn(3).setCellRenderer(new MagicEditionRenderer());
    tableDeck.getColumnModel().getColumn(3).setCellEditor(new MagicEditionListEditor());
    JScrollPane scrollSideboard = new JScrollPane();
    tabbedDeckSide.addTab("SideBoard", null, scrollSideboard, null);
    tableSide = new JTable();
    tableSide.setModel(deckSidemodel);
    tableSide.setRowHeight(MTGConstants.TABLE_ROW_HEIGHT);
    tableSide.getColumnModel().getColumn(2).setCellRenderer(new ManaCellRenderer());
    tableSide.getColumnModel().getColumn(4).setCellEditor(new IntegerCellEditor());
    tableSide.getColumnModel().getColumn(3).setCellRenderer(new MagicEditionRenderer());
    tableSide.getColumnModel().getColumn(3).setCellEditor(new MagicEditionListEditor());
    tableSide.getColumnModel().getColumn(4).setCellEditor(new IntegerCellEditor());
    scrollSideboard.setViewportView(tableSide);
    tableDeck.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent ev) {
            MagicCard mc = (MagicCard) tableDeck.getValueAt(tableDeck.getSelectedRow(), 0);
            magicCardDetailPanel.setMagicCard(mc);
            cardDrawProbaPanel.init(deck, mc);
        }
    });
    tableSide.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent ev) {
            MagicCard mc = (MagicCard) tableSide.getValueAt(tableSide.getSelectedRow(), 0);
            magicCardDetailPanel.setMagicCard(mc);
        }
    });
    tableDeck.addKeyListener(new KeyAdapter() {

        @Override
        public void keyTyped(KeyEvent e) {
            MagicCard mc = (MagicCard) tableDeck.getValueAt(tableDeck.getSelectedRow(), 0);
            if (e.getKeyCode() == 0) {
                deck.getMap().remove(mc);
                deckmodel.init(deck);
            }
        }
    });
    tableSide.addKeyListener(new KeyAdapter() {

        @Override
        public void keyTyped(KeyEvent e) {
            MagicCard mc = (MagicCard) tableSide.getValueAt(tableSide.getSelectedRow(), 0);
            if (e.getKeyCode() == 0) {
                deck.getMapSideBoard().remove(mc);
                deckmodel.init(deck);
            }
        }
    });
    tableDeck.getModel().addTableModelListener(e -> updatePanels());
    tableSide.getModel().addTableModelListener(e -> updatePanels());
    tableDeck.getDefaultEditor(String.class).addCellEditorListener(new CellEditorListener() {

        @Override
        public void editingStopped(ChangeEvent e) {
            updatePanels();
        }

        @Override
        public void editingCanceled(ChangeEvent e) {
            updatePanels();
        }
    });
    tableSide.getDefaultEditor(String.class).addCellEditorListener(new CellEditorListener() {

        @Override
        public void editingStopped(ChangeEvent e) {
            updatePanels();
        }

        @Override
        public void editingCanceled(ChangeEvent e) {
            updatePanels();
        }
    });
    JPanel panelInfoDeck = new JPanel();
    tabbedPane.addTab(MTGControler.getInstance().getLangService().getCapitalize("INFORMATIONS"), null, panelInfoDeck, null);
    panelInfoDeck.setLayout(new BorderLayout(0, 0));
    panelInfoDeck.add(deckDetailsPanel, BorderLayout.NORTH);
    deckDetailsPanel.setMagicDeck(deck);
    cmcChartPanel = new CmcChartPanel();
    manaRepartitionPanel = new ManaRepartitionPanel();
    typeRepartitionPanel = new TypeRepartitionPanel();
    rarityRepartitionPanel = new RarityRepartitionPanel();
    drawProbabilityPanel = new DrawProbabilityPanel();
    JPanel randomHandPanel = new JPanel();
    JPanel statPanel = new JPanel();
    randomHandPanel.setLayout(new BorderLayout(0, 0));
    randomHandPanel.add(thumbnail, BorderLayout.CENTER);
    statPanel.setLayout(new GridLayout(3, 2, 0, 0));
    statPanel.add(manaRepartitionPanel);
    statPanel.add(typeRepartitionPanel);
    statPanel.add(rarityRepartitionPanel);
    statPanel.add(cmcChartPanel);
    statPanel.add(drawProbabilityPanel);
    tabbedPane.addTab(MTGControler.getInstance().getLangService().getCapitalize("STATS"), null, statPanel, null);
    deckPricePanel = new DeckPricePanel();
    statPanel.add(deckPricePanel);
    tabbedPane.addTab(MTGControler.getInstance().getLangService().getCapitalize("SAMPLE_HAND"), null, randomHandPanel, null);
    JPanel panel = new JPanel();
    randomHandPanel.add(panel, BorderLayout.NORTH);
    JButton btnDrawAHand = new JButton(MTGControler.getInstance().getLangService().getCapitalize("DRAW_HAND"));
    btnDrawAHand.addActionListener(ae -> {
        thumbnail.removeAll();
        p.mixHandAndLibrary();
        p.shuffleLibrary();
        p.drawCard(7);
        thumbnail.initThumbnails(p.getHand(), false, false);
    });
    panel.add(btnDrawAHand);
    JPanel panneauGauche = new JPanel();
    add(panneauGauche, BorderLayout.WEST);
    panneauGauche.setLayout(new BorderLayout(0, 0));
    scrollResult = new JScrollPane();
    panneauGauche.add(scrollResult);
    listResult = new JList<>(new DefaultListModel<MagicCard>());
    listResult.setCellRenderer(new MagicCardListRenderer());
    listResult.setMinimumSize(new Dimension(100, 0));
    listResult.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    scrollResult.setViewportView(listResult);
    JPanel panneauResultFilter = new JPanel();
    panneauGauche.add(panneauResultFilter, BorderLayout.NORTH);
    groupsFilterResult = new ButtonGroup() {

        @Override
        public void setSelected(ButtonModel model, boolean selected) {
            if (selected) {
                super.setSelected(model, selected);
            } else {
                clearSelection();
            }
        }
    };
    JToggleButton tglbtnStd = new JToggleButton("STD");
    tglbtnStd.setActionCommand("Standard");
    panneauResultFilter.add(tglbtnStd);
    JToggleButton tglbtnMdn = new JToggleButton("MDN");
    tglbtnMdn.setActionCommand("Modern");
    panneauResultFilter.add(tglbtnMdn);
    JToggleButton tglbtnLeg = new JToggleButton("LEG");
    tglbtnLeg.setActionCommand("Legacy");
    panneauResultFilter.add(tglbtnLeg);
    JToggleButton tglbtnVin = new JToggleButton("VIN");
    tglbtnVin.setActionCommand("Vintage");
    panneauResultFilter.add(tglbtnVin);
    groupsFilterResult.add(tglbtnStd);
    groupsFilterResult.add(tglbtnMdn);
    groupsFilterResult.add(tglbtnLeg);
    groupsFilterResult.add(tglbtnVin);
    listResult.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent ev) {
            if (ev.getClickCount() == 1 && !ev.isConsumed()) {
                ev.consume();
                MagicCard mc = listResult.getSelectedValue();
                magicCardDetailPanel.setMagicCard(mc);
            }
            if (ev.getClickCount() == 2 && !ev.isConsumed()) {
                ev.consume();
                MagicCard mc = listResult.getSelectedValue();
                if (getSelectedMap().get(mc) != null) {
                    getSelectedMap().put(mc, deck.getMap().get(mc) + 1);
                } else {
                    getSelectedMap().put(mc, 1);
                }
                deckmodel.init(deck);
                deckSidemodel.init(deck);
            }
        }
    });
    txtSearch.addActionListener(e -> btnSearch.doClick());
    tabbedDeckSide.addChangeListener(e -> selectedIndex = tabbedDeckSide.getSelectedIndex());
    btnSearch.addActionListener(aeSearch -> {
        if (txtSearch.getText().equals(""))
            return;
        resultListModel.removeAllElements();
        ThreadManager.getInstance().execute(() -> {
            try {
                String searchName = txtSearch.getText();
                List<MagicCard> cards = MTGControler.getInstance().getEnabledProviders().searchCardByCriteria(cboAttributs.getSelectedItem().toString(), searchName, null, false);
                MagicFormat form = new MagicFormat();
                for (MagicCard m : cards) {
                    if (groupsFilterResult.getSelection() != null) {
                        form.setFormat(groupsFilterResult.getSelection().getActionCommand());
                        if (m.getLegalities().contains(form))
                            resultListModel.addElement(m);
                    } else {
                        resultListModel.addElement(m);
                    }
                }
                lblCards.setText(resultListModel.size() + " " + MTGControler.getInstance().getLangService().get("RESULTS"));
                listResult.setModel(resultListModel);
                listResult.updateUI();
            } catch (Exception e) {
                JOptionPane.showMessageDialog(null, e.getMessage(), MTGControler.getInstance().getLangService().getError(), JOptionPane.ERROR_MESSAGE);
            }
        }, "search deck");
    });
}
Also used : JPanel(javax.swing.JPanel) KeyAdapter(java.awt.event.KeyAdapter) HandPanel(org.magic.game.gui.components.HandPanel) BorderLayout(java.awt.BorderLayout) JToggleButton(javax.swing.JToggleButton) DrawProbabilityPanel(org.magic.gui.components.charts.DrawProbabilityPanel) MagicDeck(org.magic.api.beans.MagicDeck) ManaCellRenderer(org.magic.gui.renderer.ManaCellRenderer) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) MagicFormat(org.magic.api.beans.MagicFormat) ManaRepartitionPanel(org.magic.gui.components.charts.ManaRepartitionPanel) JFileChooser(javax.swing.JFileChooser) JTable(javax.swing.JTable) MagicEditionRenderer(org.magic.gui.renderer.MagicEditionRenderer) JSplitPane(javax.swing.JSplitPane) Map(java.util.Map) HashMap(java.util.HashMap) File(java.io.File) FlowLayout(java.awt.FlowLayout) JTabbedPane(javax.swing.JTabbedPane) MTGCardsExport(org.magic.api.interfaces.MTGCardsExport) JButton(javax.swing.JButton) DefaultListModel(javax.swing.DefaultListModel) CellEditorListener(javax.swing.event.CellEditorListener) JTextField(javax.swing.JTextField) MagicCardListRenderer(org.magic.gui.renderer.MagicCardListRenderer) MagicEditionListEditor(org.magic.gui.renderer.MagicEditionListEditor) KeyEvent(java.awt.event.KeyEvent) GridLayout(java.awt.GridLayout) IntegerCellEditor(org.magic.gui.renderer.IntegerCellEditor) JMenuItem(javax.swing.JMenuItem) FileFilter(javax.swing.filechooser.FileFilter) Component(java.awt.Component) TableRowSorter(javax.swing.table.TableRowSorter) JScrollPane(javax.swing.JScrollPane) MouseEvent(java.awt.event.MouseEvent) JDeckChooserDialog(org.magic.gui.components.dialog.JDeckChooserDialog) MouseAdapter(java.awt.event.MouseAdapter) JLabel(javax.swing.JLabel) DefaultRowSorter(javax.swing.DefaultRowSorter) RarityRepartitionPanel(org.magic.gui.components.charts.RarityRepartitionPanel) Dimension(java.awt.Dimension) Point(java.awt.Point) JPopupMenu(javax.swing.JPopupMenu) Point(java.awt.Point) TypeRepartitionPanel(org.magic.gui.components.charts.TypeRepartitionPanel) DeckModel(org.magic.gui.models.DeckModel) MagicCard(org.magic.api.beans.MagicCard) ChangeEvent(javax.swing.event.ChangeEvent) ButtonGroup(javax.swing.ButtonGroup) CmcChartPanel(org.magic.gui.components.charts.CmcChartPanel) ButtonModel(javax.swing.ButtonModel)

Example 97 with KeyEvent

use of java.awt.event.KeyEvent in project sic by belluccifranco.

the class PedidosGUI method cargarRenglonesDelPedidoSeleccionadoEnTabla.

private void cargarRenglonesDelPedidoSeleccionadoEnTabla(KeyEvent evt) {
    int row = Utilidades.getSelectedRowModelIndice(tbl_Pedidos);
    if (evt != null) {
        if ((evt.getKeyCode() == KeyEvent.VK_UP) && row > 0) {
            row--;
        }
        if ((evt.getKeyCode() == KeyEvent.VK_DOWN) && (row + 1) < tbl_Pedidos.getRowCount()) {
            row++;
        }
    }
    this.limpiarTablaRenglones();
    this.setColumnasRenglonesPedido();
    try {
        List<RenglonPedido> renglones = Arrays.asList(RestClient.getRestTemplate().getForObject("/pedidos/" + pedidosTotal.get(row).getId_Pedido() + "/renglones", RenglonPedido[].class));
        renglones.stream().map(r -> {
            Object[] fila = new Object[6];
            fila[0] = r.getProducto().getCodigo();
            fila[1] = r.getProducto().getDescripcion();
            fila[2] = r.getCantidad();
            fila[3] = r.getProducto().getPrecioLista();
            fila[4] = r.getDescuento_porcentaje();
            fila[5] = r.getSubTotal();
            return fila;
        }).forEach(fila -> {
            modeloTablaRenglones.addRow(fila);
        });
        tbl_RenglonesPedido.setModel(modeloTablaRenglones);
    } catch (RestClientResponseException ex) {
        JOptionPane.showMessageDialog(this, ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
    } catch (ResourceAccessException ex) {
        LOGGER.error(ex.getMessage());
        JOptionPane.showMessageDialog(this, ResourceBundle.getBundle("Mensajes").getString("mensaje_error_conexion"), "Error", JOptionPane.ERROR_MESSAGE);
    }
}
Also used : RenderTabla(sic.util.RenderTabla) Arrays(java.util.Arrays) RestClient(sic.RestClient) RenglonPedido(sic.modelo.RenglonPedido) JInternalFrame(javax.swing.JInternalFrame) Date(java.util.Date) ParameterizedTypeReference(org.springframework.core.ParameterizedTypeReference) LoggerFactory(org.slf4j.LoggerFactory) Utilidades(sic.util.Utilidades) Point(java.awt.Point) ArrayList(java.util.ArrayList) PropertyVetoException(java.beans.PropertyVetoException) ResourceBundle(java.util.ResourceBundle) RestClientResponseException(org.springframework.web.client.RestClientResponseException) Pedido(sic.modelo.Pedido) Usuario(sic.modelo.Usuario) SwingWorker(javax.swing.SwingWorker) Cliente(sic.modelo.Cliente) Desktop(java.awt.Desktop) AdjustmentEvent(java.awt.event.AdjustmentEvent) Logger(org.slf4j.Logger) Files(java.nio.file.Files) EstadoPedido(sic.modelo.EstadoPedido) HttpMethod(org.springframework.http.HttpMethod) IOException(java.io.IOException) ResourceAccessException(org.springframework.web.client.ResourceAccessException) KeyEvent(java.awt.event.KeyEvent) JOptionPane(javax.swing.JOptionPane) File(java.io.File) ExecutionException(java.util.concurrent.ExecutionException) Dimension(java.awt.Dimension) List(java.util.List) JScrollBar(javax.swing.JScrollBar) EmpresaActiva(sic.modelo.EmpresaActiva) PaginaRespuestaRest(sic.modelo.PaginaRespuestaRest) ColoresEstadosRenderer(sic.util.ColoresEstadosRenderer) RenglonPedido(sic.modelo.RenglonPedido) RestClientResponseException(org.springframework.web.client.RestClientResponseException) Point(java.awt.Point) ResourceAccessException(org.springframework.web.client.ResourceAccessException)

Example 98 with KeyEvent

use of java.awt.event.KeyEvent in project UniversalMediaServer by UniversalMediaServer.

the class FFmpegDVRMSRemux method config.

@Override
public JComponent config() {
    FormLayout layout = new FormLayout("left:pref, 3dlu, p, 3dlu, 0:grow", "p, 3dlu, p, 3dlu, 0:grow");
    PanelBuilder builder = new PanelBuilder(layout);
    builder.border(Borders.EMPTY);
    builder.opaque(false);
    CellConstraints cc = new CellConstraints();
    JComponent cmp = builder.addSeparator(Messages.getString("NetworkTab.5"), cc.xyw(1, 1, 5));
    cmp = (JComponent) cmp.getComponent(0);
    cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));
    builder.addLabel(Messages.getString("FFmpegDVRMSRemux.0"), cc.xy(1, 3));
    altffpath = new JTextField(configuration.getFfmpegAlternativePath());
    altffpath.addKeyListener(new KeyAdapter() {

        @Override
        public void keyReleased(KeyEvent e) {
            configuration.setFfmpegAlternativePath(altffpath.getText());
        }
    });
    builder.add(altffpath, cc.xyw(3, 3, 3));
    return builder.getPanel();
}
Also used : FormLayout(com.jgoodies.forms.layout.FormLayout) KeyEvent(java.awt.event.KeyEvent) PanelBuilder(com.jgoodies.forms.builder.PanelBuilder) KeyAdapter(java.awt.event.KeyAdapter) JComponent(javax.swing.JComponent) JTextField(javax.swing.JTextField) CellConstraints(com.jgoodies.forms.layout.CellConstraints)

Example 99 with KeyEvent

use of java.awt.event.KeyEvent in project SeqMonk by s-andrews.

the class SmoothingSubtractionQuantitation method getOptionsPanel.

/* (non-Javadoc)
	 * @see uk.ac.babraham.SeqMonk.Quantitation.Quantitation#getOptionsPanel(uk.ac.babraham.SeqMonk.SeqMonkApplication)
	 */
public JPanel getOptionsPanel() {
    if (optionPanel != null) {
        // We've done this already
        return optionPanel;
    }
    optionPanel = new JPanel();
    optionPanel.setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 1;
    gbc.weightx = 0.5;
    gbc.weighty = 0.1;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    optionPanel.add(new JLabel("Smoothing method"), gbc);
    gbc.gridx = 2;
    correctionActions = new JComboBox(new String[] { "Adjacent Probes", "Window Size" });
    optionPanel.add(correctionActions, gbc);
    gbc.gridx = 1;
    gbc.gridy++;
    optionPanel.add(new JLabel("Size"), gbc);
    distanceField = new JTextField("" + distance);
    distanceField.addKeyListener(new NumberKeyListener(false, false));
    distanceField.addKeyListener(new KeyListener() {

        public void keyTyped(KeyEvent arg0) {
        }

        public void keyReleased(KeyEvent arg0) {
            optionsChanged();
        }

        public void keyPressed(KeyEvent arg0) {
        }
    });
    gbc.gridx++;
    optionPanel.add(distanceField, gbc);
    return optionPanel;
}
Also used : KeyEvent(java.awt.event.KeyEvent) JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) GridBagLayout(java.awt.GridBagLayout) JComboBox(javax.swing.JComboBox) JLabel(javax.swing.JLabel) KeyListener(java.awt.event.KeyListener) NumberKeyListener(uk.ac.babraham.SeqMonk.Utilities.NumberKeyListener) JTextField(javax.swing.JTextField) NumberKeyListener(uk.ac.babraham.SeqMonk.Utilities.NumberKeyListener)

Example 100 with KeyEvent

use of java.awt.event.KeyEvent in project SeqMonk by s-andrews.

the class LogTransformQuantitation method getOptionsPanel.

/* (non-Javadoc)
	 * @see uk.ac.babraham.SeqMonk.Quantitation.Quantitation#getOptionsPanel(uk.ac.babraham.SeqMonk.SeqMonkApplication)
	 */
public JPanel getOptionsPanel() {
    if (optionPanel != null) {
        // We've done this already
        return optionPanel;
    }
    optionPanel = new JPanel();
    optionPanel.setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 1;
    gbc.weightx = 0.5;
    gbc.weighty = 0.1;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    optionPanel.add(new JLabel("Log Base "), gbc);
    gbc.gridx = 2;
    logBaseField = new JTextField("" + logBase);
    logBaseField.addKeyListener(new NumberKeyListener(true, false));
    logBaseField.addKeyListener(new KeyListener() {

        public void keyTyped(KeyEvent arg0) {
        }

        public void keyReleased(KeyEvent arg0) {
            optionsChanged();
        }

        public void keyPressed(KeyEvent arg0) {
        }
    });
    optionPanel.add(logBaseField, gbc);
    gbc.gridx = 1;
    gbc.gridy++;
    optionPanel.add(new JLabel("Threshold "), gbc);
    thresholdField = new JTextField("" + threshold);
    thresholdField.addKeyListener(new NumberKeyListener(true, false));
    thresholdField.addKeyListener(new KeyListener() {

        public void keyTyped(KeyEvent arg0) {
        }

        public void keyReleased(KeyEvent arg0) {
            optionsChanged();
        }

        public void keyPressed(KeyEvent arg0) {
        }
    });
    gbc.gridx++;
    optionPanel.add(thresholdField, gbc);
    return optionPanel;
}
Also used : KeyEvent(java.awt.event.KeyEvent) JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) GridBagLayout(java.awt.GridBagLayout) JLabel(javax.swing.JLabel) KeyListener(java.awt.event.KeyListener) NumberKeyListener(uk.ac.babraham.SeqMonk.Utilities.NumberKeyListener) JTextField(javax.swing.JTextField) NumberKeyListener(uk.ac.babraham.SeqMonk.Utilities.NumberKeyListener)

Aggregations

KeyEvent (java.awt.event.KeyEvent)301 KeyAdapter (java.awt.event.KeyAdapter)159 MouseEvent (java.awt.event.MouseEvent)79 ActionEvent (java.awt.event.ActionEvent)74 JPanel (javax.swing.JPanel)69 ActionListener (java.awt.event.ActionListener)61 MouseAdapter (java.awt.event.MouseAdapter)59 KeyListener (java.awt.event.KeyListener)54 Dimension (java.awt.Dimension)50 JLabel (javax.swing.JLabel)48 JTextField (javax.swing.JTextField)44 BorderLayout (java.awt.BorderLayout)40 JButton (javax.swing.JButton)40 JScrollPane (javax.swing.JScrollPane)35 Insets (java.awt.Insets)33 Point (java.awt.Point)33 FocusEvent (java.awt.event.FocusEvent)31 GridBagConstraints (java.awt.GridBagConstraints)23 BoxLayout (javax.swing.BoxLayout)22 GridBagLayout (java.awt.GridBagLayout)20