Disabling uncertified boards warning even in java code, for good measure

This commit is contained in:
Federico Fissore 2015-05-05 09:17:50 +02:00
parent 060ec30e1c
commit 7e7a9d0fe8
7 changed files with 3 additions and 351 deletions

View File

@ -1,59 +0,0 @@
/*
* This file is part of Arduino.
*
* Arduino 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* As a special exception, you may use this file as part of a free software
* library without restriction. Specifically, if other files instantiate
* templates or use macros or inline functions from this file, or you compile
* this file and link it with other files to produce an executable, this
* file does not by itself cause the resulting executable to be covered by
* the GNU General Public License. This exception does not however
* invalidate any other reasons why the executable file might be covered by
* the GNU General Public License.
*
* Copyright 2015 Arduino LLC (http://www.arduino.cc/)
*/
package cc.arduino.view;
import processing.app.Preferences;
import java.awt.*;
public class ShowUncertifiedBoardWarning implements Runnable {
private final Frame parent;
public ShowUncertifiedBoardWarning(Frame parent) {
this.parent = parent;
}
@Override
public void run() {
UncertifiedBoardWarning uncertifiedBoardWarning = new UncertifiedBoardWarning(parent, new EventListener() {
@Override
public void eventHappened(cc.arduino.view.Event event) {
if (!"uncertified_board_warning_ok_pressed".equals(event.getActionCommand())) {
return;
}
Preferences.set("uncertifiedBoardWarning_dontShowMeAgain", event.getPayload().get("dontShowMeAgain").toString());
}
});
uncertifiedBoardWarning.setLocationRelativeTo(parent);
uncertifiedBoardWarning.setVisible(true);
}
}

View File

@ -1,81 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
<Properties>
<Property name="defaultCloseOperation" type="int" value="2"/>
<Property name="title" type="java.lang.String" value="_(&quot;Not supported board&quot;)"/>
<Property name="modal" type="boolean" value="true"/>
<Property name="name" type="java.lang.String" value="uncertifiedBoardWarning" noResource="true"/>
<Property name="resizable" type="boolean" value="false"/>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
</SyntheticProperties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jLabel1" pref="0" max="32767" attributes="0"/>
<Group type="102" attributes="0">
<Component id="dontShowMeAgain" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="206" max="32767" attributes="0"/>
<Component id="ok" min="-2" pref="82" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel1" min="-2" pref="87" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="dontShowMeAgain" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="ok" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="text" type="java.lang.String" value="&lt;html&gt;&lt;body&gt;This board comes from an non certified manufacturer.&lt;br&gt;We won&apos;t be able to provide any support if it doesn&apos;t work as expected.&lt;/body&gt;&lt;/html&gt;"/>
<Property name="verticalAlignment" type="int" value="1"/>
</Properties>
</Component>
<Component class="javax.swing.JCheckBox" name="dontShowMeAgain">
<Properties>
<Property name="text" type="java.lang.String" value="Don&apos;t show me again"/>
<Property name="name" type="java.lang.String" value="dontShowMeAgain" noResource="true"/>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="ok">
<Properties>
<Property name="text" type="java.lang.String" value="OK"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="okActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Form>

View File

@ -1,146 +0,0 @@
/*
* This file is part of Arduino.
*
* Arduino 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* As a special exception, you may use this file as part of a free software
* library without restriction. Specifically, if other files instantiate
* templates or use macros or inline functions from this file, or you compile
* this file and link it with other files to produce an executable, this
* file does not by itself cause the resulting executable to be covered by
* the GNU General Public License. This exception does not however
* invalidate any other reasons why the executable file might be covered by
* the GNU General Public License.
*
* Copyright 2015 Arduino LLC (http://www.arduino.cc/)
*/
package cc.arduino.view;
import javax.swing.*;
import java.awt.*;
import static processing.app.I18n._;
public class UncertifiedBoardWarning extends javax.swing.JDialog {
private final EventListener listener;
public UncertifiedBoardWarning(Frame parent, EventListener listener) {
super(parent);
initComponents();
this.listener = listener;
}
/**
* 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.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
dontShowMeAgain = new javax.swing.JCheckBox();
ok = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setTitle(_("Uncertified board"));
setModal(true);
setName("uncertifiedBoardWarning"); // NOI18N
setResizable(false);
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>");
jLabel1.setVerticalAlignment(javax.swing.SwingConstants.TOP);
dontShowMeAgain.setText(_("Don't show me again"));
dontShowMeAgain.setName("dontShowMeAgain"); // NOI18N
ok.setText(_("OK"));
ok.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
okActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addComponent(dontShowMeAgain)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 206, Short.MAX_VALUE)
.addComponent(ok, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(dontShowMeAgain)
.addComponent(ok))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void okActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okActionPerformed
Event event = new Event(evt.getSource(), evt.getID(), "uncertified_board_warning_ok_pressed");
event.getPayload().put("dontShowMeAgain", dontShowMeAgain.isSelected());
listener.eventHappened(event);
this.dispose();
}//GEN-LAST:event_okActionPerformed
/**
* @param args the command line arguments
*/
public static void main(String args[]) throws Exception {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
/* Create and display the dialog */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
UncertifiedBoardWarning dialog = new UncertifiedBoardWarning(new javax.swing.JFrame(), new EventListener() {
@Override
public void eventHappened(Event event) {
System.out.println(event);
}
});
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent e) {
System.exit(0);
}
});
dialog.setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JCheckBox dontShowMeAgain;
private javax.swing.JLabel jLabel1;
private javax.swing.JButton ok;
// End of variables declaration//GEN-END:variables
}

View File

@ -966,22 +966,15 @@ public class Editor extends JFrame implements RunnerListener {
class SerialMenuListener implements ActionListener {
private final Frame parent;
private final String serialPort;
private final String warning;
public SerialMenuListener(Frame parent, String serialPort, String warning) {
this.parent = parent;
public SerialMenuListener(String serialPort) {
this.serialPort = serialPort;
this.warning = warning;
}
public void actionPerformed(ActionEvent e) {
selectSerialPort(serialPort);
base.onBoardOrPortChange();
if (warning != null && !Preferences.getBoolean("uncertifiedBoardWarning_dontShowMeAgain")) {
SwingUtilities.invokeLater(new ShowUncertifiedBoardWarning(parent));
}
}
}
@ -1063,7 +1056,7 @@ public class Editor extends JFrame implements RunnerListener {
String label = port.getLabel();
JCheckBoxMenuItem item = new JCheckBoxMenuItem(label, address.equals(selectedPort));
item.addActionListener(new SerialMenuListener(this, address, port.getPrefs().get("warning")));
item.addActionListener(new SerialMenuListener(address));
serialMenu.add(item);
}

View File

@ -23,16 +23,12 @@
package processing.app;
import cc.arduino.packages.BoardPort;
import cc.arduino.packages.Uploader;
import cc.arduino.view.*;
import processing.app.debug.Compiler;
import processing.app.debug.Compiler.ProgressListener;
import processing.app.debug.RunnerException;
import processing.app.debug.TargetBoard;
import processing.app.forms.PasswordAuthorizationDialog;
import processing.app.helpers.OSUtils;
import processing.app.helpers.PreferencesMap;
import processing.app.helpers.PreferencesMapException;
import processing.app.packages.UserLibrary;
import static processing.app.I18n._;
@ -46,8 +42,6 @@ import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import static processing.app.I18n._;
/**
* Stores information about files in the current sketch
@ -1153,8 +1147,6 @@ public class Sketch {
* @return null if compilation failed, main class name if not
*/
public String build(String buildPath, boolean verbose) throws RunnerException, PreferencesMapException {
useOriginalVidPidIfUncertified();
// run the preprocessor
editor.status.progressUpdate(20);
@ -1204,38 +1196,6 @@ public class Sketch {
return success;
}
private void useOriginalVidPidIfUncertified() {
BoardPort boardPort = BaseNoGui.getDiscoveryManager().find(PreferencesData.get("serial.port"));
if (boardPort == null) {
return;
}
TargetBoard targetBoard = BaseNoGui.getTargetBoard();
if (targetBoard == null) {
return;
}
PreferencesMap boardPreferences = targetBoard.getPreferences();
if (boardPreferences.containsKey("build.vid") && boardPreferences.containsKey("build.pid")) {
if (!boardPreferences.containsKey("backup.build.vid")) {
boardPreferences.put("backup.build.vid", boardPreferences.get("build.vid"));
boardPreferences.put("backup.build.pid", boardPreferences.get("build.pid"));
}
if (boardPort.getPrefs().get("warning") != null) {
boardPreferences.put("build.vid", boardPort.getPrefs().get("vid"));
boardPreferences.put("build.pid", boardPort.getPrefs().get("pid"));
} else {
boardPreferences.put("build.vid", boardPreferences.get("backup.build.vid"));
boardPreferences.put("build.pid", boardPreferences.get("backup.build.pid"));
}
}
if (boardPort.getPrefs().get("warning") != null && !Preferences.getBoolean("uncertifiedBoardWarning_dontShowMeAgain")) {
SwingUtilities.invokeLater(new ShowUncertifiedBoardWarning(editor));
}
}
protected boolean upload(String buildPath, String suggestedClassName, boolean usingProgrammer) throws Exception {
Uploader uploader = Compiler.getUploaderByPreferences(false);

View File

@ -41,11 +41,6 @@ import static processing.app.I18n._;
public class SerialDiscovery implements Discovery {
static {
//makes transifex happy
_("Uncertified");
}
private Timer serialBoardsListerTimer;
private final List<BoardPort> serialBoardPorts;

View File

@ -39,8 +39,6 @@ import processing.app.helpers.PreferencesMap;
import java.util.*;
import static processing.app.I18n._;
public class SerialBoardsLister extends TimerTask {
private static final int MAX_TIME_AWAITING_FOR_PACKAGES = 5000;
@ -98,17 +96,9 @@ public class SerialBoardsLister extends TimerTask {
TargetBoard board = (TargetBoard) boardData.get("board");
if (board != null) {
String warningKey = "vid." + boardData.get("vid").toString() + ".warning";
String warning = board.getPreferences().get(warningKey);
prefs.put("warning", warning);
String boardName = board.getName();
if (boardName != null) {
if (warning != null) {
label += " (" + boardName + " - " + _(warning) + ")";
} else {
label += " (" + boardName + ")";
}
label += " (" + boardName + ")";
}
boardPort.setBoardName(boardName);
}