|
| 1 | +/* |
| 2 | + * This file is part of Arduino. |
| 3 | + * |
| 4 | + * Arduino is free software; you can redistribute it and/or modify |
| 5 | + * it under the terms of the GNU General Public License as published by |
| 6 | + * the Free Software Foundation; either version 2 of the License, or |
| 7 | + * (at your option) any later version. |
| 8 | + * |
| 9 | + * This program is distributed in the hope that it will be useful, |
| 10 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | + * GNU General Public License for more details. |
| 13 | + * |
| 14 | + * You should have received a copy of the GNU General Public License |
| 15 | + * along with this program; if not, write to the Free Software |
| 16 | + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 17 | + * |
| 18 | + * As a special exception, you may use this file as part of a free software |
| 19 | + * library without restriction. Specifically, if other files instantiate |
| 20 | + * templates or use macros or inline functions from this file, or you compile |
| 21 | + * this file and link it with other files to produce an executable, this |
| 22 | + * file does not by itself cause the resulting executable to be covered by |
| 23 | + * the GNU General Public License. This exception does not however |
| 24 | + * invalidate any other reasons why the executable file might be covered by |
| 25 | + * the GNU General Public License. |
| 26 | + * |
| 27 | + * Copyright 2015 Arduino LLC (http://www.arduino.cc/) |
| 28 | + */ |
| 29 | + |
| 30 | +package cc.arduino.view; |
| 31 | + |
| 32 | +import javax.swing.*; |
| 33 | +import java.awt.*; |
| 34 | + |
| 35 | +import static processing.app.I18n._; |
| 36 | + |
| 37 | +public class UncertifiedBoardWarning extends javax.swing.JDialog { |
| 38 | + |
| 39 | + private final EventListener listener; |
| 40 | + |
| 41 | + public UncertifiedBoardWarning(Frame parent, EventListener listener) { |
| 42 | + super(parent); |
| 43 | + initComponents(); |
| 44 | + this.listener = listener; |
| 45 | + } |
| 46 | + |
| 47 | + /** |
| 48 | + * This method is called from within the constructor to initialize the form. |
| 49 | + * WARNING: Do NOT modify this code. The content of this method is always |
| 50 | + * regenerated by the Form Editor. |
| 51 | + */ |
| 52 | + @SuppressWarnings("unchecked") |
| 53 | + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents |
| 54 | + private void initComponents() { |
| 55 | + |
| 56 | + jLabel1 = new javax.swing.JLabel(); |
| 57 | + dontShowMeAgain = new javax.swing.JCheckBox(); |
| 58 | + ok = new javax.swing.JButton(); |
| 59 | + |
| 60 | + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); |
| 61 | + setTitle(_("Uncertified board")); |
| 62 | + setModal(true); |
| 63 | + setName("uncertifiedBoardWarning"); // NOI18N |
| 64 | + setResizable(false); |
| 65 | + |
| 66 | + jLabel1.setText("<html><body>" + _("This board comes from an uncertified manufacturer.") + "<br>" + _("We won't be able to provide any support if it doesn't work as expected.") + "</body></html>"); |
| 67 | + jLabel1.setVerticalAlignment(javax.swing.SwingConstants.TOP); |
| 68 | + |
| 69 | + dontShowMeAgain.setText("Don't show me again"); |
| 70 | + dontShowMeAgain.setName("dontShowMeAgain"); // NOI18N |
| 71 | + |
| 72 | + ok.setText("OK"); |
| 73 | + ok.addActionListener(new java.awt.event.ActionListener() { |
| 74 | + public void actionPerformed(java.awt.event.ActionEvent evt) { |
| 75 | + okActionPerformed(evt); |
| 76 | + } |
| 77 | + }); |
| 78 | + |
| 79 | + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); |
| 80 | + getContentPane().setLayout(layout); |
| 81 | + layout.setHorizontalGroup( |
| 82 | + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
| 83 | + .addGroup(layout.createSequentialGroup() |
| 84 | + .addContainerGap() |
| 85 | + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
| 86 | + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE) |
| 87 | + .addGroup(layout.createSequentialGroup() |
| 88 | + .addComponent(dontShowMeAgain) |
| 89 | + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 206, Short.MAX_VALUE) |
| 90 | + .addComponent(ok, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE))) |
| 91 | + .addContainerGap()) |
| 92 | + ); |
| 93 | + layout.setVerticalGroup( |
| 94 | + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
| 95 | + .addGroup(layout.createSequentialGroup() |
| 96 | + .addContainerGap() |
| 97 | + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE) |
| 98 | + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) |
| 99 | + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) |
| 100 | + .addComponent(dontShowMeAgain) |
| 101 | + .addComponent(ok)) |
| 102 | + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) |
| 103 | + ); |
| 104 | + |
| 105 | + pack(); |
| 106 | + }// </editor-fold>//GEN-END:initComponents |
| 107 | + |
| 108 | + private void okActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okActionPerformed |
| 109 | + Event event = new Event(evt.getSource(), evt.getID(), "uncertified_board_warning_ok_pressed"); |
| 110 | + event.getPayload().put("dontShowMeAgain", dontShowMeAgain.isSelected()); |
| 111 | + listener.eventHappened(event); |
| 112 | + this.dispose(); |
| 113 | + }//GEN-LAST:event_okActionPerformed |
| 114 | + |
| 115 | + /** |
| 116 | + * @param args the command line arguments |
| 117 | + */ |
| 118 | + public static void main(String args[]) throws Exception { |
| 119 | + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); |
| 120 | + /* Create and display the dialog */ |
| 121 | + java.awt.EventQueue.invokeLater(new Runnable() { |
| 122 | + public void run() { |
| 123 | + UncertifiedBoardWarning dialog = new UncertifiedBoardWarning(new javax.swing.JFrame(), new EventListener() { |
| 124 | + |
| 125 | + @Override |
| 126 | + public void eventHappened(Event event) { |
| 127 | + System.out.println(event); |
| 128 | + } |
| 129 | + }); |
| 130 | + dialog.addWindowListener(new java.awt.event.WindowAdapter() { |
| 131 | + @Override |
| 132 | + public void windowClosing(java.awt.event.WindowEvent e) { |
| 133 | + System.exit(0); |
| 134 | + } |
| 135 | + }); |
| 136 | + dialog.setVisible(true); |
| 137 | + } |
| 138 | + }); |
| 139 | + } |
| 140 | + |
| 141 | + // Variables declaration - do not modify//GEN-BEGIN:variables |
| 142 | + private javax.swing.JCheckBox dontShowMeAgain; |
| 143 | + private javax.swing.JLabel jLabel1; |
| 144 | + private javax.swing.JButton ok; |
| 145 | + // End of variables declaration//GEN-END:variables |
| 146 | +} |
0 commit comments