📄 jpanelconfiguration.java
字号:
// Tina POS is a point of sales application designed for touch screens.// Copyright (C) 2005 Adrian Romero Corchado.// http://sourceforge.net/projects/tinapos//// This program is free software; you can redistribute it and/or modify// it under the terms of the GNU General Public License as published by// the Free Software Foundation; either version 2 of the License, or// (at your option) any later version.//// This program is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the// GNU General Public License for more details.//// You should have received a copy of the GNU General Public License// along with this program; if not, write to the Free Software// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USApackage net.adrianromero.tpv.config;import javax.swing.*;import java.io.IOException;import java.util.ArrayList;import java.util.List;import net.adrianromero.basic.BasicException;import net.adrianromero.tpv.forms.*;import net.adrianromero.data.gui.MessageInf;import net.adrianromero.data.gui.JMessageDialog;public class JPanelConfiguration extends JPanel implements JPanelView { private List<PanelConfig> m_panelconfig; /** Creates new form JPanelConfiguration */ public JPanelConfiguration(AppView oApp) { initComponents(); // Inicio lista de paneles m_panelconfig = new ArrayList<PanelConfig>(); m_panelconfig.add(new JPanelConfigDatabase()); m_panelconfig.add(new JPanelConfigGeneral()); m_panelconfig.add(new JPanelConfigPayment()); // m_panelconfig.add(new JPanelConfigERP()); // paneles auxiliares for (PanelConfig c: m_panelconfig) { m_jConfigOptions.add(c.getConfigComponent()); } } private void restoreProperties() { AppConfig config = new AppConfig(); if (config.delete()) { loadProperties(); } else { JMessageDialog.showMessage(this, new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotdeleteconfig"))); } } private void loadProperties() { AppConfig config = new AppConfig(); config.load(); // paneles auxiliares for (PanelConfig c: m_panelconfig) { c.loadProperties(config); } } private void saveProperties() { AppConfig config = new AppConfig(); // paneles auxiliares for (PanelConfig c: m_panelconfig) { c.saveProperties(config); } try { config.save(); JOptionPane.showMessageDialog(this, AppLocal.getIntString("message.restartchanges"), AppLocal.getIntString("message.title"), JOptionPane.INFORMATION_MESSAGE); } catch (IOException e) { JMessageDialog.showMessage(this, new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotsaveconfig"), e)); } } public JComponent getComponent() { return this; } public String getTitle() { return AppLocal.getIntString("Menu.Configuration"); } public void activate() throws BasicException { loadProperties(); } public boolean deactivate() { return true; } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents private void initComponents() { jPanel14 = new javax.swing.JPanel(); jScrollPane1 = new javax.swing.JScrollPane(); m_jConfigOptions = new javax.swing.JPanel(); jPanel15 = new javax.swing.JPanel(); jbtnSave = new javax.swing.JButton(); jbtnRestore = new javax.swing.JButton(); jbtnCancel = new javax.swing.JButton(); setLayout(new java.awt.BorderLayout()); jPanel14.setLayout(new java.awt.BorderLayout()); jPanel14.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); m_jConfigOptions.setLayout(new javax.swing.BoxLayout(m_jConfigOptions, javax.swing.BoxLayout.Y_AXIS)); jScrollPane1.setViewportView(m_jConfigOptions); jPanel14.add(jScrollPane1, java.awt.BorderLayout.CENTER); add(jPanel14, java.awt.BorderLayout.CENTER); jPanel15.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT)); jbtnSave.setText(AppLocal.getIntString("Button.Save")); jbtnSave.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jbtnSaveActionPerformed(evt); } }); jPanel15.add(jbtnSave); jbtnRestore.setText(AppLocal.getIntString("Button.Factory")); jbtnRestore.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jbtnRestoreActionPerformed(evt); } }); jPanel15.add(jbtnRestore); jbtnCancel.setText(AppLocal.getIntString("Button.Restore")); jbtnCancel.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jbtnCancelActionPerformed(evt); } }); jPanel15.add(jbtnCancel); add(jPanel15, java.awt.BorderLayout.SOUTH); }// </editor-fold>//GEN-END:initComponents private void jbtnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnCancelActionPerformed if (JOptionPane.showConfirmDialog(this, AppLocal.getIntString("message.configrestore"), AppLocal.getIntString("message.title"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) { loadProperties(); } }//GEN-LAST:event_jbtnCancelActionPerformed private void jbtnRestoreActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnRestoreActionPerformed if (JOptionPane.showConfirmDialog(this, AppLocal.getIntString("message.configfactory"), AppLocal.getIntString("message.title"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) { restoreProperties(); } }//GEN-LAST:event_jbtnRestoreActionPerformed private void jbtnSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnSaveActionPerformed saveProperties(); }//GEN-LAST:event_jbtnSaveActionPerformed // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JPanel jPanel14; private javax.swing.JPanel jPanel15; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JButton jbtnCancel; private javax.swing.JButton jbtnRestore; private javax.swing.JButton jbtnSave; private javax.swing.JPanel m_jConfigOptions; // End of variables declaration//GEN-END:variables }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -