mirror of
https://github.com/arduino/Arduino.git
synced 2024-12-04 15:24:12 +01:00
commit
3ed980f04d
@ -3,7 +3,6 @@
|
||||
<classpathentry excluding="processing/app/tools/format/|processing/app/tools/format/src/|processing/app/Trace.java|processing/app/RunnerClassLoader.java" kind="src" path="app/src"/>
|
||||
<classpathentry kind="src" path="app/test"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="lib" path="app/lib/antlr.jar"/>
|
||||
<classpathentry kind="lib" path="app/lib/apple.jar"/>
|
||||
<classpathentry kind="lib" path="app/lib/ecj.jar"/>
|
||||
<classpathentry kind="lib" path="app/test-lib/junit-4.11.jar"/>
|
||||
@ -16,6 +15,7 @@
|
||||
<classpathentry kind="lib" path="app/lib/commons-exec-1.1.jar"/>
|
||||
<classpathentry kind="lib" path="app/lib/commons-httpclient-3.1.jar"/>
|
||||
<classpathentry kind="lib" path="app/lib/commons-logging-1.0.4.jar"/>
|
||||
<classpathentry kind="lib" path="app/lib/commons-net-3.3.jar"/>
|
||||
<classpathentry kind="lib" path="app/lib/jmdns-3.4.1.jar"/>
|
||||
<classpathentry kind="lib" path="app/lib/jsch-0.1.50.jar"/>
|
||||
<classpathentry kind="lib" path="app/lib/jssc-2.8.0.jar"/>
|
||||
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -14,6 +14,7 @@ hardware/arduino/bootloaders/caterina_LUFA/Caterina.elf
|
||||
hardware/arduino/bootloaders/caterina_LUFA/Caterina.eep
|
||||
hardware/arduino/bootloaders/caterina_LUFA/.dep/
|
||||
build/*.zip
|
||||
build/*.tar.bz2
|
||||
build/windows/work/
|
||||
build/windows/*.zip
|
||||
build/windows/*.tgz
|
||||
@ -33,7 +34,7 @@ build/macosx/libastylej*
|
||||
build/macosx/appbundler*.jar
|
||||
build/macosx/appbundler*.zip
|
||||
build/macosx/appbundler
|
||||
build/macosx/appbundler-1.0ea-arduino3
|
||||
build/macosx/appbundler-1.0ea-arduino?
|
||||
build/macosx/appbundler-1.0ea-arduino*.zip
|
||||
build/macosx/appbundler-1.0ea-upstream*.zip
|
||||
build/linux/work/
|
||||
|
18
README.md
18
README.md
@ -10,7 +10,8 @@ IDE can be downloaded for free at http://www.arduino.cc/en/Main/Software
|
||||
|
||||
* For more information, see the website at: http://www.arduino.cc/
|
||||
or the forums at: http://www.arduino.cc/forum/
|
||||
You can also follow Arduino on twitter at: https://twitter.com/arduino or like Arduino on Facebook at: https://www.facebook.com/official.arduino
|
||||
You can also follow Arduino on twitter at: https://twitter.com/arduino or
|
||||
like Arduino on Facebook at: https://www.facebook.com/official.arduino
|
||||
|
||||
* To report a *bug* in the software or to request *a simple enhancement* go to:
|
||||
http://github.com/arduino/Arduino/issues
|
||||
@ -35,11 +36,18 @@ Credits
|
||||
--------
|
||||
Arduino is an open source project, supported by many.
|
||||
|
||||
The Arduino team is composed of Massimo Banzi, David Cuartielles, Tom Igoe,
|
||||
Gianluca Martino, Daniela Antonietti, and David A. Mellis.
|
||||
The Arduino team is composed of Massimo Banzi, David Cuartielles, Tom Igoe
|
||||
and David A. Mellis.
|
||||
|
||||
Arduino uses the [GNU avr-gcc toolchain](http://gcc.gnu.org/wiki/avr-gcc), [avrdude](http://www.nongnu.org/avrdude/), [avr-libc](http://www.nongnu.org/avr-libc/), and code from
|
||||
[Processing](http://www.processing.org) and [Wiring](http://wiring.org.co).
|
||||
Arduino uses
|
||||
[GNU avr-gcc toolchain](http://gcc.gnu.org/wiki/avr-gcc),
|
||||
[GCC ARM Embedded toolchain](https://launchpad.net/gcc-arm-embedded),
|
||||
[avr-libc](http://www.nongnu.org/avr-libc/),
|
||||
[avrdude](http://www.nongnu.org/avrdude/),
|
||||
[bossac](http://www.shumatech.com/web/products/bossa),
|
||||
[openOCD](http://openocd.org/)
|
||||
and code from [Processing](http://www.processing.org)
|
||||
and [Wiring](http://wiring.org.co).
|
||||
|
||||
Icon and about image designed by [ToDo](http://www.todo.to.it/)
|
||||
|
||||
|
@ -3,8 +3,6 @@
|
||||
<classpathentry excluding="processing/app/tools/format/" kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="test"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
|
||||
<classpathentry kind="lib" path="lib/antlr.jar"/>
|
||||
<classpathentry kind="lib" path="lib/ecj.jar"/>
|
||||
<classpathentry kind="lib" path="lib/apple.jar"/>
|
||||
<classpathentry kind="lib" path="lib/bcpg-jdk15on-152.jar"/>
|
||||
<classpathentry kind="lib" path="lib/bcprov-jdk15on-152.jar"/>
|
||||
@ -13,6 +11,7 @@
|
||||
<classpathentry kind="lib" path="lib/commons-exec-1.1.jar"/>
|
||||
<classpathentry kind="lib" path="lib/commons-httpclient-3.1.jar"/>
|
||||
<classpathentry kind="lib" path="lib/commons-logging-1.0.4.jar"/>
|
||||
<classpathentry kind="lib" path="lib/commons-net-3.3.jar"/>
|
||||
<classpathentry kind="lib" path="lib/jackson-annotations-2.2.3.jar"/>
|
||||
<classpathentry kind="lib" path="lib/jackson-core-2.2.3.jar"/>
|
||||
<classpathentry kind="lib" path="lib/jackson-databind-2.2.3.jar"/>
|
||||
@ -28,8 +27,7 @@
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/arduino-core"/>
|
||||
<classpathentry kind="lib" path="test-lib/jcip-annotations-1.0.jar"/>
|
||||
<classpathentry kind="lib" path="lib/commons-lang3-3.3.2.jar"/>
|
||||
<classpathentry kind="lib" path="lib/guava-18.0.jar"/>
|
||||
<classpathentry kind="lib" path="lib/java-semver-0.8.0.jar"/>
|
||||
<classpathentry kind="lib" path="lib/rsyntaxtextarea-2.5.7.1+arduino.jar"/>
|
||||
<classpathentry kind="lib" path="lib/rsyntaxtextarea-2.5.8.1+arduino.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
@ -13,7 +13,6 @@
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/pdf"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/serial"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/video"/>
|
||||
<classpathentry kind="lib" path="lib/antlr.jar"/>
|
||||
<classpathentry kind="lib" path="lib/ecj.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
@ -102,6 +102,7 @@
|
||||
<fileset dir="test" includes="**/*.json*" />
|
||||
<fileset dir="test" includes="**/*.key" />
|
||||
<fileset dir="test" includes="**/*.hex" />
|
||||
<fileset dir="test" includes="**/*.pac" />
|
||||
</copy>
|
||||
|
||||
<junit printsummary="yes" dir="${work.dir}" fork="true">
|
||||
@ -111,7 +112,6 @@
|
||||
<classpath>
|
||||
<pathelement location="bin"/>
|
||||
<pathelement location="test-bin"/>
|
||||
<pathelement path="../build/macosx/work/Arduino.app/Contents/Resources/Java/quaqua.jar"/>
|
||||
<path refid="class.path.test"/>
|
||||
</classpath>
|
||||
|
||||
|
@ -1,160 +0,0 @@
|
||||
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2006 Ben Fry and Casey Reas
|
||||
|
||||
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 USA
|
||||
*/
|
||||
|
||||
package processing.app.tools;
|
||||
|
||||
import processing.app.*;
|
||||
import processing.core.*;
|
||||
import static processing.app.I18n._;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
|
||||
/**
|
||||
* Tool for auto-formatting code that interfaces to
|
||||
* <A HREF="http://jalopy.sourceforge.net/">Jalopy</A>. This is to replace
|
||||
* the buggy code formatter found in previous releases.
|
||||
*/
|
||||
public class AutoFormat {
|
||||
Editor editor;
|
||||
|
||||
|
||||
public AutoFormat(Editor editor) {
|
||||
this.editor = editor;
|
||||
}
|
||||
|
||||
|
||||
public void show() {
|
||||
String originalText = editor.textarea.getText();
|
||||
int indentSize = PreferencesData.getInteger("editor.tabs.size");
|
||||
|
||||
//
|
||||
|
||||
String formattedText = null; //strOut.toString();
|
||||
if (formattedText.equals(originalText)) {
|
||||
editor.message(_("No changes necessary for Auto Format."));
|
||||
|
||||
} else {
|
||||
// replace with new bootiful text
|
||||
// selectionEnd hopefully at least in the neighborhood
|
||||
editor.setText(formattedText, selectionEnd, selectionEnd);
|
||||
editor.sketch.setModified(true);
|
||||
|
||||
/*
|
||||
// warn user if there are too many parens in either direction
|
||||
if (paren != 0) {
|
||||
editor.error("Warning: Too many " +
|
||||
((paren < 0) ? "right" : "left") +
|
||||
" parentheses.");
|
||||
|
||||
} else if (c_level != 0) { // check braces only if parens are ok
|
||||
editor.error("Warning: Too many " +
|
||||
((c_level < 0) ? "right" : "left") +
|
||||
" curly braces.");
|
||||
} else {
|
||||
editor.message("Auto Format finished.");
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
||||
|
||||
|
||||
private static class PluginImpl extends AbstractPlugin {
|
||||
JEditStatusBar statusBar;
|
||||
Project project;
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new PluginImpl object.
|
||||
*/
|
||||
public PluginImpl()
|
||||
{
|
||||
super(new JEditAppender());
|
||||
}
|
||||
|
||||
|
||||
public Project getActiveProject()
|
||||
{
|
||||
if (this.project == null)
|
||||
{
|
||||
this.project = new JEditProject();
|
||||
}
|
||||
|
||||
return this.project;
|
||||
}
|
||||
|
||||
|
||||
public FileFormat getFileFormat()
|
||||
{
|
||||
// there is a bug(?) in jEdit's text area whereas inserting text with
|
||||
// DOS file format results in displaying EOF characters, so we always
|
||||
// use UNIX format and let jEdit handle the specified file format upon
|
||||
// file saving
|
||||
return FileFormat.UNIX;
|
||||
}
|
||||
|
||||
|
||||
public Frame getMainWindow()
|
||||
{
|
||||
return jEdit.getActiveView();
|
||||
}
|
||||
|
||||
|
||||
public StatusBar getStatusBar()
|
||||
{
|
||||
return this.statusBar;
|
||||
}
|
||||
|
||||
|
||||
public void afterEnd()
|
||||
{
|
||||
super.afterEnd();
|
||||
MessageView.getInstance().update();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Formats the currently active buffer.
|
||||
*/
|
||||
public void formatActive()
|
||||
{
|
||||
// only perform the action if the current Buffer contains
|
||||
// a Java source file
|
||||
//if (isJava(jEdit.getActiveView().getBuffer()))
|
||||
//{
|
||||
performAction(Action.FORMAT_ACTIVE);
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Formats the currently open buffers.
|
||||
*/
|
||||
public void formatOpen()
|
||||
{
|
||||
performAction(Action.FORMAT_OPEN);
|
||||
}
|
||||
}
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
app/lib/commons-net-3.3.jar
Normal file
BIN
app/lib/commons-net-3.3.jar
Normal file
Binary file not shown.
@ -200,4 +200,3 @@
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
BIN
app/lib/ecj.jar
BIN
app/lib/ecj.jar
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -116,9 +116,9 @@ public class ConsoleOutputStream extends ByteArrayOutputStream {
|
||||
if (document != null) {
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
try {
|
||||
String lineWithoutSlashR = line.replace("\r\n", "\n").replace("\r", "\n");
|
||||
String lineWithoutCR = line.replace("\r\n", "\n").replace("\r", "\n");
|
||||
int offset = document.getLength();
|
||||
document.insertString(offset, lineWithoutSlashR, attributes);
|
||||
document.insertString(offset, lineWithoutCR, attributes);
|
||||
} catch (BadLocationException ble) {
|
||||
//ignore
|
||||
}
|
||||
|
74
app/src/cc/arduino/UpdatableBoardsLibsFakeURLsHandler.java
Normal file
74
app/src/cc/arduino/UpdatableBoardsLibsFakeURLsHandler.java
Normal file
@ -0,0 +1,74 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import processing.app.Base;
|
||||
|
||||
import javax.swing.event.HyperlinkEvent;
|
||||
import javax.swing.event.HyperlinkListener;
|
||||
import java.net.URL;
|
||||
|
||||
public class UpdatableBoardsLibsFakeURLsHandler implements HyperlinkListener {
|
||||
|
||||
private static final String BOARDSMANAGER = "boardsmanager";
|
||||
private static final String LIBRARYMANAGER = "librarymanager";
|
||||
|
||||
private final Base base;
|
||||
|
||||
public UpdatableBoardsLibsFakeURLsHandler(Base base) {
|
||||
this.base = base;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hyperlinkUpdate(HyperlinkEvent event) {
|
||||
if (event.getEventType() != HyperlinkEvent.EventType.ACTIVATED) {
|
||||
return;
|
||||
}
|
||||
|
||||
URL url = event.getURL();
|
||||
|
||||
if (BOARDSMANAGER.equals(url.getHost())) {
|
||||
try {
|
||||
base.openBoardsManager("", "DropdownUpdatableCoresItem");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (LIBRARYMANAGER.equals(url.getHost())) {
|
||||
base.openLibraryManager("DropdownUpdatableLibrariesItem");
|
||||
return;
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException(url.getHost() + " is invalid");
|
||||
}
|
||||
|
||||
}
|
@ -34,11 +34,6 @@ import cc.arduino.contributions.filters.InstalledPredicate;
|
||||
import cc.arduino.contributions.packages.ContributedPackage;
|
||||
import cc.arduino.contributions.packages.ContributedPlatform;
|
||||
import cc.arduino.view.Event;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Predicates;
|
||||
import com.google.common.collect.Collections2;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
import processing.app.Base;
|
||||
import processing.app.BaseNoGui;
|
||||
import processing.app.I18n;
|
||||
@ -46,10 +41,11 @@ import processing.app.PreferencesData;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static processing.app.I18n._;
|
||||
import static processing.app.I18n.tr;
|
||||
|
||||
public class BuiltInCoreIsNewerCheck implements Runnable {
|
||||
|
||||
@ -73,14 +69,9 @@ public class BuiltInCoreIsNewerCheck implements Runnable {
|
||||
return;
|
||||
}
|
||||
|
||||
LinkedList<ContributedPlatform> contributedPlatforms = Lists.newLinkedList(Iterables.concat(Collections2.transform(BaseNoGui.indexer.getPackages(), new Function<ContributedPackage, List<ContributedPlatform>>() {
|
||||
@Override
|
||||
public List<ContributedPlatform> apply(ContributedPackage input) {
|
||||
return input.getPlatforms();
|
||||
}
|
||||
})));
|
||||
List<ContributedPlatform> contributedPlatforms = BaseNoGui.indexer.getPackages().stream().map(ContributedPackage::getPlatforms).flatMap(Collection::stream).collect(Collectors.toList());
|
||||
|
||||
List<ContributedPlatform> installedBuiltInPlatforms = new LinkedList<ContributedPlatform>(Collections2.filter(contributedPlatforms, Predicates.and(new InstalledPredicate(), new BuiltInPredicate())));
|
||||
List<ContributedPlatform> installedBuiltInPlatforms = contributedPlatforms.stream().filter(new InstalledPredicate()).filter(new BuiltInPredicate()).collect(Collectors.toList());
|
||||
if (installedBuiltInPlatforms.size() != 1) {
|
||||
return;
|
||||
}
|
||||
@ -96,17 +87,15 @@ public class BuiltInCoreIsNewerCheck implements Runnable {
|
||||
}
|
||||
|
||||
if (VersionHelper.valueOf(installedBuiltIn.getParsedVersion()).greaterThan(VersionHelper.valueOf(installedNotBuiltIn.getParsedVersion()))) {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PreferencesData.setInteger("builtin_platform_is_newer", BaseNoGui.REVISION);
|
||||
assert base.hasActiveEditor();
|
||||
int chosenOption = JOptionPane.showConfirmDialog(base.getActiveEditor(), I18n.format(_("The IDE includes an updated {0} package, but you're using an older one.\nDo you want to upgrade {0}?"), installedBuiltIn.getName()), I18n.format(_("A newer {0} package is available"), installedBuiltIn.getName()), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
|
||||
if (chosenOption == JOptionPane.YES_OPTION) {
|
||||
Action openBoardsManager = base.getOpenBoardsManager();
|
||||
Event event = new Event(base.getActiveEditor(), ActionEvent.ACTION_PERFORMED, installedBuiltIn.getName());
|
||||
event.getPayload().put("filterText", installedBuiltIn.getName());
|
||||
openBoardsManager.actionPerformed(event);
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
PreferencesData.setInteger("builtin_platform_is_newer", BaseNoGui.REVISION);
|
||||
assert base.hasActiveEditor();
|
||||
int chosenOption = JOptionPane.showConfirmDialog(base.getActiveEditor(), I18n.format(tr("The IDE includes an updated {0} package, but you're using an older one.\nDo you want to upgrade {0}?"), installedBuiltIn.getName()), I18n.format(tr("A newer {0} package is available"), installedBuiltIn.getName()), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
|
||||
if (chosenOption == JOptionPane.YES_OPTION) {
|
||||
try {
|
||||
base.openBoardsManager(installedBuiltIn.getName(), "");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
138
app/src/cc/arduino/contributions/ContributionsSelfCheck.java
Normal file
138
app/src/cc/arduino/contributions/ContributionsSelfCheck.java
Normal file
@ -0,0 +1,138 @@
|
||||
/*
|
||||
* This file is part of Arduino.
|
||||
*
|
||||
* Copyright 2015 Arduino LLC (http://www.arduino.cc/)
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package cc.arduino.contributions;
|
||||
|
||||
import cc.arduino.contributions.libraries.LibrariesIndexer;
|
||||
import cc.arduino.contributions.libraries.LibraryInstaller;
|
||||
import cc.arduino.contributions.libraries.filters.UpdatableLibraryPredicate;
|
||||
import cc.arduino.contributions.packages.ContributionInstaller;
|
||||
import cc.arduino.contributions.packages.ContributionsIndexer;
|
||||
import cc.arduino.contributions.packages.filters.UpdatablePlatformPredicate;
|
||||
import cc.arduino.view.NotificationPopup;
|
||||
import processing.app.Base;
|
||||
import processing.app.I18n;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.HyperlinkListener;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import static processing.app.I18n.tr;
|
||||
|
||||
public class ContributionsSelfCheck extends TimerTask {
|
||||
|
||||
private final Base base;
|
||||
private final HyperlinkListener hyperlinkListener;
|
||||
private final ContributionsIndexer contributionsIndexer;
|
||||
private final ContributionInstaller contributionInstaller;
|
||||
private final LibrariesIndexer librariesIndexer;
|
||||
private final LibraryInstaller libraryInstaller;
|
||||
private final ProgressListener progressListener;
|
||||
|
||||
private volatile boolean cancelled;
|
||||
private volatile NotificationPopup notificationPopup;
|
||||
|
||||
public ContributionsSelfCheck(Base base, HyperlinkListener hyperlinkListener, ContributionsIndexer contributionsIndexer, ContributionInstaller contributionInstaller, LibrariesIndexer librariesIndexer, LibraryInstaller libraryInstaller) {
|
||||
this.base = base;
|
||||
this.hyperlinkListener = hyperlinkListener;
|
||||
this.contributionsIndexer = contributionsIndexer;
|
||||
this.contributionInstaller = contributionInstaller;
|
||||
this.librariesIndexer = librariesIndexer;
|
||||
this.libraryInstaller = libraryInstaller;
|
||||
this.progressListener = new NoopProgressListener();
|
||||
this.cancelled = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
updateContributionIndex();
|
||||
updateLibrariesIndex();
|
||||
|
||||
long updatablePlatforms = contributionsIndexer.getPackages().stream()
|
||||
.flatMap(pack -> pack.getPlatforms().stream())
|
||||
.filter(new UpdatablePlatformPredicate(contributionsIndexer)).count();
|
||||
|
||||
long updatableLibraries = librariesIndexer.getInstalledLibraries().stream()
|
||||
.filter(new UpdatableLibraryPredicate(librariesIndexer))
|
||||
.count();
|
||||
|
||||
if (updatableLibraries <= 0 && updatablePlatforms <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
String text;
|
||||
if (updatableLibraries > 0 && updatablePlatforms <= 0) {
|
||||
text = I18n.format(tr("<br/>Update available for some of your {0}libraries{1}"), "<a href=\"http://librarymanager\">", "</a>");
|
||||
} else if (updatableLibraries <= 0 && updatablePlatforms > 0) {
|
||||
text = I18n.format(tr("<br/>Update available for some of your {0}boards{1}"), "<a href=\"http://boardsmanager\">", "</a>");
|
||||
} else {
|
||||
text = I18n.format(tr("<br/>Update available for some of your {0}boards{1} and {2}libraries{3}"), "<a href=\"http://boardsmanager\">", "</a>", "<a href=\"http://librarymanager\">", "</a>");
|
||||
}
|
||||
|
||||
if (cancelled) {
|
||||
return;
|
||||
}
|
||||
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
notificationPopup = new NotificationPopup(base.getActiveEditor(), hyperlinkListener, text);
|
||||
notificationPopup.setVisible(true);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean cancel() {
|
||||
cancelled = true;
|
||||
if (notificationPopup != null) {
|
||||
notificationPopup.close();
|
||||
}
|
||||
return super.cancel();
|
||||
}
|
||||
|
||||
private void updateLibrariesIndex() {
|
||||
if (cancelled) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
libraryInstaller.updateIndex(progressListener);
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
private void updateContributionIndex() {
|
||||
if (cancelled) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
contributionInstaller.updateIndex(progressListener);
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
}
|
@ -29,12 +29,12 @@
|
||||
|
||||
package cc.arduino.contributions.filters;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class NoopPredicate<T> implements Predicate<T> {
|
||||
|
||||
@Override
|
||||
public boolean apply(T input) {
|
||||
public boolean test(T input) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,8 @@
|
||||
package cc.arduino.contributions.libraries.filters;
|
||||
|
||||
import cc.arduino.contributions.libraries.ContributedLibrary;
|
||||
import com.google.common.base.Predicate;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class CategoryPredicate implements Predicate<ContributedLibrary> {
|
||||
|
||||
@ -41,7 +42,7 @@ public class CategoryPredicate implements Predicate<ContributedLibrary> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(ContributedLibrary input) {
|
||||
public boolean test(ContributedLibrary input) {
|
||||
return input.getCategory() != null && category.equals(input.getCategory());
|
||||
}
|
||||
|
||||
|
@ -32,10 +32,9 @@ package cc.arduino.contributions.libraries.filters;
|
||||
import cc.arduino.contributions.filters.InstalledPredicate;
|
||||
import cc.arduino.contributions.libraries.ContributedLibrary;
|
||||
import cc.arduino.contributions.libraries.LibrariesIndex;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.Collections2;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class InstalledLibraryPredicate implements Predicate<ContributedLibrary> {
|
||||
|
||||
@ -46,14 +45,15 @@ public class InstalledLibraryPredicate implements Predicate<ContributedLibrary>
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(ContributedLibrary input) {
|
||||
public boolean test(ContributedLibrary input) {
|
||||
if (input.isInstalled()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Collection<ContributedLibrary> installed = Collections2.filter(index.find(input.getName()), new InstalledPredicate());
|
||||
|
||||
return !installed.isEmpty();
|
||||
List<ContributedLibrary> libraries = index.find(input.getName());
|
||||
return libraries.stream()
|
||||
.filter(new InstalledPredicate())
|
||||
.count() > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -30,13 +30,14 @@
|
||||
package cc.arduino.contributions.libraries.filters;
|
||||
|
||||
import cc.arduino.contributions.libraries.ContributedLibrary;
|
||||
import com.google.common.base.Predicate;
|
||||
import processing.app.packages.UserLibrary;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class OnlyUpstreamReleasePredicate implements Predicate<ContributedLibrary> {
|
||||
|
||||
@Override
|
||||
public boolean apply(ContributedLibrary input) {
|
||||
public boolean test(ContributedLibrary input) {
|
||||
return !(input instanceof UserLibrary);
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* This file is part of Arduino.
|
||||
*
|
||||
* Copyright 2015 Arduino LLC (http://www.arduino.cc/)
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package cc.arduino.contributions.libraries.filters;
|
||||
|
||||
import cc.arduino.contributions.VersionComparator;
|
||||
import cc.arduino.contributions.libraries.ContributedLibrary;
|
||||
import cc.arduino.contributions.libraries.LibrariesIndexer;
|
||||
import processing.app.packages.UserLibrary;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class UpdatableLibraryPredicate implements Predicate<ContributedLibrary> {
|
||||
|
||||
private final LibrariesIndexer indexer;
|
||||
private final VersionComparator versionComparator;
|
||||
|
||||
public UpdatableLibraryPredicate(LibrariesIndexer indexer) {
|
||||
this.indexer = indexer;
|
||||
this.versionComparator = new VersionComparator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(ContributedLibrary contributedLibrary) {
|
||||
String libraryName = contributedLibrary.getName();
|
||||
UserLibrary installed = indexer.getInstalledLibraries().getByName(libraryName);
|
||||
if (installed == null) {
|
||||
return false;
|
||||
}
|
||||
List<ContributedLibrary> libraries = indexer.getIndex().find(libraryName);
|
||||
return libraries.stream()
|
||||
.filter(library -> versionComparator.greaterThan(library.getParsedVersion(), installed.getParsedVersion()))
|
||||
.count() > 0;
|
||||
}
|
||||
}
|
@ -29,7 +29,6 @@
|
||||
|
||||
package cc.arduino.contributions.libraries.ui;
|
||||
|
||||
import cc.arduino.contributions.DownloadableContribution;
|
||||
import cc.arduino.contributions.DownloadableContributionVersionComparator;
|
||||
import cc.arduino.contributions.VersionComparator;
|
||||
import cc.arduino.contributions.filters.BuiltInPredicate;
|
||||
@ -39,87 +38,65 @@ import cc.arduino.contributions.libraries.filters.OnlyUpstreamReleasePredicate;
|
||||
import cc.arduino.contributions.ui.InstallerTableCell;
|
||||
import cc.arduino.contributions.ui.listeners.DelegatingKeyListener;
|
||||
import cc.arduino.utils.ReverseComparator;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Predicates;
|
||||
import com.google.common.collect.Collections2;
|
||||
import com.google.common.collect.Lists;
|
||||
import processing.app.Base;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.event.HyperlinkEvent;
|
||||
import javax.swing.event.HyperlinkListener;
|
||||
import javax.swing.text.Document;
|
||||
import javax.swing.text.html.HTMLDocument;
|
||||
import javax.swing.text.html.StyleSheet;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ItemEvent;
|
||||
import java.awt.event.ItemListener;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static processing.app.I18n._;
|
||||
import static processing.app.I18n.format;
|
||||
import static processing.app.I18n.tr;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class ContributedLibraryTableCell extends InstallerTableCell {
|
||||
|
||||
private JPanel panel;
|
||||
private JButton installButton;
|
||||
private Component installButtonPlaceholder;
|
||||
private final JPanel panel;
|
||||
private final JButton installButton;
|
||||
private final Component installButtonPlaceholder;
|
||||
private JComboBox downgradeChooser;
|
||||
private JComboBox versionToInstallChooser;
|
||||
private JButton downgradeButton;
|
||||
private JPanel buttonsPanel;
|
||||
private JPanel inactiveButtonsPanel;
|
||||
private JLabel statusLabel;
|
||||
private final JComboBox versionToInstallChooser;
|
||||
private final JButton downgradeButton;
|
||||
private final JPanel buttonsPanel;
|
||||
private final JPanel inactiveButtonsPanel;
|
||||
private final JLabel statusLabel;
|
||||
|
||||
public ContributedLibraryTableCell() {
|
||||
{
|
||||
installButton = new JButton(_("Install"));
|
||||
installButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
onInstall(editorValue.getSelected(), editorValue.getInstalled());
|
||||
}
|
||||
});
|
||||
installButton = new JButton(tr("Install"));
|
||||
installButton.addActionListener(e -> onInstall(editorValue.getSelected(), editorValue.getInstalled()));
|
||||
int width = installButton.getPreferredSize().width;
|
||||
installButtonPlaceholder = Box.createRigidArea(new Dimension(width, 1));
|
||||
}
|
||||
|
||||
downgradeButton = new JButton(_("Install"));
|
||||
downgradeButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
ContributedLibrary selected = (ContributedLibrary) downgradeChooser.getSelectedItem();
|
||||
onInstall(selected, editorValue.getInstalled());
|
||||
}
|
||||
downgradeButton = new JButton(tr("Install"));
|
||||
downgradeButton.addActionListener(e -> {
|
||||
ContributedLibrary selected = (ContributedLibrary) downgradeChooser.getSelectedItem();
|
||||
onInstall(selected, editorValue.getInstalled());
|
||||
});
|
||||
|
||||
downgradeChooser = new JComboBox();
|
||||
downgradeChooser.addItem("-");
|
||||
downgradeChooser.setMaximumSize(downgradeChooser.getPreferredSize());
|
||||
downgradeChooser.addItemListener(new ItemListener() {
|
||||
@Override
|
||||
public void itemStateChanged(ItemEvent e) {
|
||||
Object selectVersionItem = downgradeChooser.getItemAt(0);
|
||||
boolean disableDowngrade = (e.getItem() == selectVersionItem);
|
||||
downgradeButton.setEnabled(!disableDowngrade);
|
||||
}
|
||||
downgradeChooser.addItemListener(e -> {
|
||||
Object selectVersionItem = downgradeChooser.getItemAt(0);
|
||||
boolean disableDowngrade = (e.getItem() == selectVersionItem);
|
||||
downgradeButton.setEnabled(!disableDowngrade);
|
||||
});
|
||||
|
||||
versionToInstallChooser = new JComboBox();
|
||||
versionToInstallChooser.addItem("-");
|
||||
versionToInstallChooser.setMaximumSize(versionToInstallChooser.getPreferredSize());
|
||||
versionToInstallChooser.addItemListener(new ItemListener() {
|
||||
@Override
|
||||
public void itemStateChanged(ItemEvent e) {
|
||||
editorValue.select((ContributedLibrary) versionToInstallChooser.getSelectedItem());
|
||||
}
|
||||
});
|
||||
versionToInstallChooser.addItemListener(e -> editorValue.select((ContributedLibrary) versionToInstallChooser.getSelectedItem()));
|
||||
|
||||
panel = new JPanel();
|
||||
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
|
||||
@ -181,19 +158,16 @@ public class ContributedLibraryTableCell extends InstallerTableCell {
|
||||
HTMLDocument html = (HTMLDocument) doc;
|
||||
StyleSheet stylesheet = html.getStyleSheet();
|
||||
stylesheet.addRule("body { margin: 0; padding: 0;"
|
||||
+ "font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;"
|
||||
+ "font-size: 100%;" + "font-size: 0.95em; }");
|
||||
+ "font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;"
|
||||
+ "font-size: 100%;" + "font-size: 0.95em; }");
|
||||
}
|
||||
description.setOpaque(false);
|
||||
description.setBorder(new EmptyBorder(4, 7, 7, 7));
|
||||
description.setHighlighter(null);
|
||||
description.setEditable(false);
|
||||
description.addHyperlinkListener(new HyperlinkListener() {
|
||||
@Override
|
||||
public void hyperlinkUpdate(HyperlinkEvent e) {
|
||||
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
|
||||
Base.openURL(e.getDescription());
|
||||
}
|
||||
description.addHyperlinkListener(e -> {
|
||||
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
|
||||
Base.openURL(e.getDescription());
|
||||
}
|
||||
});
|
||||
description.addKeyListener(new DelegatingKeyListener(parentTable));
|
||||
@ -248,50 +222,39 @@ public class ContributedLibraryTableCell extends InstallerTableCell {
|
||||
|
||||
final ContributedLibrary installed = editorValue.getInstalled();
|
||||
|
||||
List<ContributedLibrary> releases = new LinkedList<ContributedLibrary>(Collections2.filter(editorValue.releases, new OnlyUpstreamReleasePredicate()));
|
||||
List<ContributedLibrary> uninstalledReleases = new LinkedList<ContributedLibrary>(Collections2.filter(releases, Predicates.not(new InstalledPredicate())));
|
||||
List<ContributedLibrary> releases = editorValue.releases.stream().filter(new OnlyUpstreamReleasePredicate()).collect(Collectors.toList());
|
||||
List<ContributedLibrary> uninstalledReleases = releases.stream().filter(new InstalledPredicate().negate()).collect(Collectors.toList());
|
||||
|
||||
List<ContributedLibrary> installedBuiltIn = new LinkedList<ContributedLibrary>(Collections2.filter(releases, Predicates.and(new InstalledPredicate(), new BuiltInPredicate())));
|
||||
List<ContributedLibrary> installedBuiltIn = releases.stream().filter(new InstalledPredicate()).filter(new BuiltInPredicate()).collect(Collectors.toList());
|
||||
|
||||
if (installed != null && !installedBuiltIn.contains(installed)) {
|
||||
uninstalledReleases.addAll(installedBuiltIn);
|
||||
}
|
||||
|
||||
Collections.sort(uninstalledReleases, new ReverseComparator<DownloadableContribution>(new DownloadableContributionVersionComparator()));
|
||||
Collections.sort(uninstalledReleases, new ReverseComparator<>(new DownloadableContributionVersionComparator()));
|
||||
|
||||
downgradeChooser.removeAllItems();
|
||||
downgradeChooser.addItem(_("Select version"));
|
||||
downgradeChooser.addItem(tr("Select version"));
|
||||
|
||||
final List<ContributedLibrary> uninstalledPreviousReleases = Lists.newLinkedList();
|
||||
final List<ContributedLibrary> uninstalledNewerReleases = Lists.newLinkedList();
|
||||
final List<ContributedLibrary> uninstalledPreviousReleases = new LinkedList<>();
|
||||
final List<ContributedLibrary> uninstalledNewerReleases = new LinkedList<>();
|
||||
|
||||
final VersionComparator versionComparator = new VersionComparator();
|
||||
Lists.newLinkedList(Lists.transform(uninstalledReleases, new Function<ContributedLibrary, ContributedLibrary>() {
|
||||
@Override
|
||||
public ContributedLibrary apply(ContributedLibrary input) {
|
||||
if (installed == null || versionComparator.greaterThan(installed.getParsedVersion(), input.getParsedVersion())) {
|
||||
uninstalledPreviousReleases.add(input);
|
||||
} else {
|
||||
uninstalledNewerReleases.add(input);
|
||||
}
|
||||
|
||||
return input;
|
||||
uninstalledReleases.stream().forEach(input -> {
|
||||
if (installed == null || versionComparator.greaterThan(installed.getParsedVersion(), input.getParsedVersion())) {
|
||||
uninstalledPreviousReleases.add(input);
|
||||
} else {
|
||||
uninstalledNewerReleases.add(input);
|
||||
}
|
||||
}));
|
||||
for (ContributedLibrary release : uninstalledNewerReleases) {
|
||||
downgradeChooser.addItem(release);
|
||||
}
|
||||
for (ContributedLibrary release : uninstalledPreviousReleases) {
|
||||
downgradeChooser.addItem(release);
|
||||
}
|
||||
});
|
||||
uninstalledNewerReleases.forEach(downgradeChooser::addItem);
|
||||
uninstalledPreviousReleases.forEach(downgradeChooser::addItem);
|
||||
|
||||
downgradeChooser.setVisible(installed != null && (!uninstalledPreviousReleases.isEmpty() || uninstalledNewerReleases.size() > 1));
|
||||
downgradeButton.setVisible(installed != null && (!uninstalledPreviousReleases.isEmpty() || uninstalledNewerReleases.size() > 1));
|
||||
|
||||
versionToInstallChooser.removeAllItems();
|
||||
for (ContributedLibrary release : uninstalledReleases) {
|
||||
versionToInstallChooser.addItem(release);
|
||||
}
|
||||
uninstalledReleases.forEach(versionToInstallChooser::addItem);
|
||||
versionToInstallChooser.setVisible(installed == null && uninstalledReleases.size() > 1);
|
||||
|
||||
Component component = getUpdatedCellComponent(value, true, row, !installedBuiltIn.isEmpty());
|
||||
@ -312,21 +275,19 @@ public class ContributedLibraryTableCell extends InstallerTableCell {
|
||||
ContributedLibrary selected = releases.getSelected();
|
||||
ContributedLibrary installed = releases.getInstalled();
|
||||
|
||||
boolean removable, installable, upgradable;
|
||||
boolean installable, upgradable;
|
||||
if (installed == null) {
|
||||
installable = true;
|
||||
removable = false;
|
||||
upgradable = false;
|
||||
} else {
|
||||
installable = false;
|
||||
removable = !installed.isReadOnly() && !hasBuiltInRelease;
|
||||
upgradable = new DownloadableContributionVersionComparator().compare(selected, installed) > 0;
|
||||
}
|
||||
if (installable) {
|
||||
installButton.setText(_("Install"));
|
||||
installButton.setText(tr("Install"));
|
||||
}
|
||||
if (upgradable) {
|
||||
installButton.setText(_("Update"));
|
||||
installButton.setText(tr("Update"));
|
||||
}
|
||||
installButton.setVisible(installable || upgradable);
|
||||
installButtonPlaceholder.setVisible(!(installable || upgradable));
|
||||
@ -360,9 +321,9 @@ public class ContributedLibraryTableCell extends InstallerTableCell {
|
||||
if (installed != null) {
|
||||
String installedVer = installed.getParsedVersion();
|
||||
if (installedVer == null) {
|
||||
desc += " " + _("Version unknown");
|
||||
desc += " " + tr("Version unknown");
|
||||
} else {
|
||||
desc += " " + format(_("Version <b>{0}</b>"), installedVer);
|
||||
desc += " " + format(tr("Version <b>{0}</b>"), installedVer);
|
||||
}
|
||||
}
|
||||
desc += "</font>";
|
||||
@ -407,7 +368,7 @@ public class ContributedLibraryTableCell extends InstallerTableCell {
|
||||
return panel;
|
||||
}
|
||||
|
||||
private Timer enabler = new Timer(100, new ActionListener() {
|
||||
private final Timer enabler = new Timer(100, new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
enable(true);
|
||||
|
@ -33,9 +33,10 @@ import cc.arduino.contributions.libraries.ContributedLibrary;
|
||||
import cc.arduino.contributions.libraries.LibrariesIndex;
|
||||
import cc.arduino.contributions.libraries.filters.InstalledLibraryPredicate;
|
||||
import cc.arduino.contributions.ui.DropdownItem;
|
||||
import com.google.common.base.Predicate;
|
||||
|
||||
import static processing.app.I18n._;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import static processing.app.I18n.tr;
|
||||
|
||||
public class DropdownInstalledLibraryItem implements DropdownItem<ContributedLibrary> {
|
||||
|
||||
@ -46,7 +47,7 @@ public class DropdownInstalledLibraryItem implements DropdownItem<ContributedLib
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return _("Installed");
|
||||
return tr("Installed");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -32,7 +32,8 @@ package cc.arduino.contributions.libraries.ui;
|
||||
import cc.arduino.contributions.libraries.ContributedLibrary;
|
||||
import cc.arduino.contributions.libraries.filters.CategoryPredicate;
|
||||
import cc.arduino.contributions.ui.DropdownItem;
|
||||
import com.google.common.base.Predicate;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class DropdownLibraryOfCategoryItem implements DropdownItem<ContributedLibrary> {
|
||||
|
||||
|
@ -32,7 +32,8 @@ package cc.arduino.contributions.libraries.ui;
|
||||
import cc.arduino.contributions.libraries.ContributedLibrary;
|
||||
import cc.arduino.contributions.libraries.filters.TypePredicate;
|
||||
import cc.arduino.contributions.ui.DropdownItem;
|
||||
import com.google.common.base.Predicate;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class DropdownLibraryOfTypeItem implements DropdownItem<ContributedLibrary> {
|
||||
|
||||
|
@ -0,0 +1,64 @@
|
||||
/*
|
||||
* This file is part of Arduino.
|
||||
*
|
||||
* Copyright 2015 Arduino LLC (http://www.arduino.cc/)
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package cc.arduino.contributions.libraries.ui;
|
||||
|
||||
import cc.arduino.contributions.libraries.ContributedLibrary;
|
||||
import cc.arduino.contributions.libraries.LibrariesIndexer;
|
||||
import cc.arduino.contributions.libraries.filters.UpdatableLibraryPredicate;
|
||||
import cc.arduino.contributions.ui.DropdownItem;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import static processing.app.I18n.tr;
|
||||
|
||||
public class DropdownUpdatableLibrariesItem implements DropdownItem<ContributedLibrary> {
|
||||
|
||||
private final LibrariesIndexer indexer;
|
||||
|
||||
public DropdownUpdatableLibrariesItem(LibrariesIndexer indexer) {
|
||||
this.indexer = indexer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Predicate<ContributedLibrary> getFilterPredicate() {
|
||||
return new UpdatableLibraryPredicate(indexer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return tr("Updatable");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return obj instanceof DropdownUpdatableLibrariesItem;
|
||||
}
|
||||
|
||||
}
|
@ -35,14 +35,14 @@ import cc.arduino.contributions.libraries.ContributedLibrary;
|
||||
import cc.arduino.contributions.libraries.LibrariesIndexer;
|
||||
import cc.arduino.contributions.packages.ContributedPlatform;
|
||||
import cc.arduino.contributions.ui.FilteredAbstractTableModel;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Predicates;
|
||||
import com.google.common.collect.Collections2;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class LibrariesIndexTableModel extends FilteredAbstractTableModel<ContributedLibrary> {
|
||||
@ -59,8 +59,8 @@ public class LibrariesIndexTableModel extends FilteredAbstractTableModel<Contrib
|
||||
|
||||
public ContributedLibraryReleases(ContributedLibrary library) {
|
||||
this.name = library.getName();
|
||||
this.versions = new LinkedList<String>();
|
||||
this.releases = new LinkedList<ContributedLibrary>();
|
||||
this.versions = new LinkedList<>();
|
||||
this.releases = new LinkedList<>();
|
||||
this.selected = null;
|
||||
add(library);
|
||||
}
|
||||
@ -79,7 +79,7 @@ public class LibrariesIndexTableModel extends FilteredAbstractTableModel<Contrib
|
||||
}
|
||||
|
||||
public ContributedLibrary getInstalled() {
|
||||
List<ContributedLibrary> installedReleases = new LinkedList<ContributedLibrary>(Collections2.filter(releases, new InstalledPredicate()));
|
||||
List<ContributedLibrary> installedReleases = releases.stream().filter(new InstalledPredicate()).collect(Collectors.toList());
|
||||
Collections.sort(installedReleases, new DownloadableContributionBuiltInAtTheBottomComparator());
|
||||
|
||||
if (installedReleases.isEmpty()) {
|
||||
@ -112,7 +112,7 @@ public class LibrariesIndexTableModel extends FilteredAbstractTableModel<Contrib
|
||||
}
|
||||
}
|
||||
|
||||
private final List<ContributedLibraryReleases> contributions = new ArrayList<ContributedLibraryReleases>();
|
||||
private final List<ContributedLibraryReleases> contributions = new ArrayList<>();
|
||||
|
||||
private final String[] columnNames = {"Description"};
|
||||
|
||||
@ -127,8 +127,8 @@ public class LibrariesIndexTableModel extends FilteredAbstractTableModel<Contrib
|
||||
Predicate<ContributedLibrary> selectedCategoryFilter = null;
|
||||
String selectedFilters[] = null;
|
||||
|
||||
public void updateIndexFilter(String filters[], Predicate<ContributedLibrary>... additionalFilters) {
|
||||
selectedCategoryFilter = Predicates.and(additionalFilters);
|
||||
public void updateIndexFilter(String filters[], Stream<Predicate<ContributedLibrary>> additionalFilters) {
|
||||
selectedCategoryFilter = additionalFilters.reduce(Predicate::and).get();
|
||||
selectedFilters = filters;
|
||||
update();
|
||||
}
|
||||
@ -229,10 +229,12 @@ public class LibrariesIndexTableModel extends FilteredAbstractTableModel<Contrib
|
||||
}
|
||||
|
||||
private void applyFilterToLibrary(ContributedLibrary lib) {
|
||||
if (selectedCategoryFilter != null && !selectedCategoryFilter.apply(lib)) {
|
||||
if (selectedCategoryFilter != null && !selectedCategoryFilter.test(lib)) {
|
||||
return;
|
||||
}
|
||||
if (!stringContainsAll(lib.getName(), selectedFilters) && !stringContainsAll(lib.getParagraph(), selectedFilters) && !stringContainsAll(lib.getSentence(), selectedFilters)) {
|
||||
|
||||
String compoundTargetSearchText = lib.getName() + "\n" + lib.getParagraph() + "\n" + lib.getSentence();
|
||||
if (!stringContainsAll(compoundTargetSearchText, selectedFilters)) {
|
||||
return;
|
||||
}
|
||||
addContribution(lib);
|
||||
@ -267,12 +269,8 @@ public class LibrariesIndexTableModel extends FilteredAbstractTableModel<Contrib
|
||||
|
||||
private void updateContributions() {
|
||||
contributions.clear();
|
||||
for (ContributedLibrary l : indexer.getIndex().getLibraries()) {
|
||||
applyFilterToLibrary(l);
|
||||
}
|
||||
for (ContributedLibrary l : indexer.getInstalledLibraries()) {
|
||||
applyFilterToLibrary(l);
|
||||
}
|
||||
indexer.getIndex().getLibraries().forEach(this::applyFilterToLibrary);
|
||||
indexer.getInstalledLibraries().forEach(this::applyFilterToLibrary);
|
||||
Collections.sort(contributions);
|
||||
}
|
||||
|
||||
|
@ -36,8 +36,6 @@ import cc.arduino.contributions.libraries.LibraryInstaller;
|
||||
import cc.arduino.contributions.libraries.LibraryTypeComparator;
|
||||
import cc.arduino.contributions.ui.*;
|
||||
import cc.arduino.utils.Progress;
|
||||
import com.google.common.base.Predicate;
|
||||
import processing.app.Platform;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
@ -46,15 +44,16 @@ import java.awt.event.ActionListener;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import static processing.app.I18n._;
|
||||
import static processing.app.I18n.tr;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class LibraryManagerUI extends InstallerJDialog<ContributedLibrary> {
|
||||
|
||||
private final JComboBox typeChooser;
|
||||
private final Platform platform;
|
||||
private LibrariesIndexer indexer;
|
||||
private final LibrariesIndexer indexer;
|
||||
private final LibraryInstaller installer;
|
||||
private Predicate<ContributedLibrary> typeFilter;
|
||||
|
||||
@Override
|
||||
@ -90,11 +89,12 @@ public class LibraryManagerUI extends InstallerJDialog<ContributedLibrary> {
|
||||
};
|
||||
}
|
||||
|
||||
public LibraryManagerUI(Frame parent, Platform platform) {
|
||||
super(parent, "Library Manager", Dialog.ModalityType.APPLICATION_MODAL, _("Unable to reach Arduino.cc due to possible network issues."));
|
||||
this.platform = platform;
|
||||
public LibraryManagerUI(Frame parent, LibrariesIndexer indexer, LibraryInstaller installer) {
|
||||
super(parent, tr("Library Manager"), Dialog.ModalityType.APPLICATION_MODAL, tr("Unable to reach Arduino.cc due to possible network issues."));
|
||||
this.indexer = indexer;
|
||||
this.installer = installer;
|
||||
|
||||
filtersContainer.add(new JLabel(_("Topic")), 1);
|
||||
filtersContainer.add(new JLabel(tr("Topic")), 1);
|
||||
filtersContainer.remove(2);
|
||||
|
||||
typeChooser = new JComboBox();
|
||||
@ -102,7 +102,7 @@ public class LibraryManagerUI extends InstallerJDialog<ContributedLibrary> {
|
||||
typeChooser.setEnabled(false);
|
||||
|
||||
filtersContainer.add(Box.createHorizontalStrut(5), 0);
|
||||
filtersContainer.add(new JLabel(_("Type")), 1);
|
||||
filtersContainer.add(new JLabel(tr("Type")), 1);
|
||||
filtersContainer.add(Box.createHorizontalStrut(5), 2);
|
||||
filtersContainer.add(typeChooser, 3);
|
||||
}
|
||||
@ -125,14 +125,12 @@ public class LibraryManagerUI extends InstallerJDialog<ContributedLibrary> {
|
||||
@Override
|
||||
public void updateIndexFilter(String[] filters, Predicate<ContributedLibrary>... additionalFilters) {
|
||||
if (additionalFilters.length == 1) {
|
||||
additionalFilters = new Predicate[] { additionalFilters[0], typeFilter };
|
||||
additionalFilters = new Predicate[]{additionalFilters[0], typeFilter};
|
||||
}
|
||||
super.updateIndexFilter(filters, additionalFilters);
|
||||
}
|
||||
|
||||
public void setIndexer(LibrariesIndexer indexer) {
|
||||
this.indexer = indexer;
|
||||
|
||||
public void updateUI() {
|
||||
DropdownItem<DownloadableContribution> previouslySelectedCategory = (DropdownItem<DownloadableContribution>) categoryChooser.getSelectedItem();
|
||||
DropdownItem<DownloadableContribution> previouslySelectedType = (DropdownItem<DownloadableContribution>) typeChooser.getSelectedItem();
|
||||
|
||||
@ -165,8 +163,9 @@ public class LibraryManagerUI extends InstallerJDialog<ContributedLibrary> {
|
||||
typeFilter = null;
|
||||
typeChooser.removeAllItems();
|
||||
typeChooser.addItem(new DropdownAllItem());
|
||||
typeChooser.addItem(new DropdownUpdatableLibrariesItem(indexer));
|
||||
typeChooser.addItem(new DropdownInstalledLibraryItem(indexer.getIndex()));
|
||||
java.util.List<String> types = new LinkedList<String>(indexer.getIndex().getTypes());
|
||||
java.util.List<String> types = new LinkedList<>(indexer.getIndex().getTypes());
|
||||
Collections.sort(types, new LibraryTypeComparator());
|
||||
for (String type : types) {
|
||||
typeChooser.addItem(new DropdownLibraryOfTypeItem(type));
|
||||
@ -180,29 +179,16 @@ public class LibraryManagerUI extends InstallerJDialog<ContributedLibrary> {
|
||||
}
|
||||
|
||||
filterField.setEnabled(contribModel.getRowCount() > 0);
|
||||
|
||||
// Create LibrariesInstaller tied with the provided index
|
||||
installer = new LibraryInstaller(indexer, platform) {
|
||||
@Override
|
||||
public void onProgress(Progress progress) {
|
||||
setProgress(progress);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public LibrariesIndexer getIndexer() {
|
||||
return indexer;
|
||||
public void selectDropdownItemByClassName(String dropdownItem) {
|
||||
selectDropdownItemByClassName(typeChooser, dropdownItem);
|
||||
}
|
||||
|
||||
public void setProgress(Progress progress) {
|
||||
progressBar.setValue(progress);
|
||||
}
|
||||
|
||||
/*
|
||||
* Installer methods follows
|
||||
*/
|
||||
|
||||
private LibraryInstaller installer;
|
||||
private Thread installerThread = null;
|
||||
|
||||
@Override
|
||||
@ -216,18 +202,15 @@ public class LibraryManagerUI extends InstallerJDialog<ContributedLibrary> {
|
||||
@Override
|
||||
protected void onUpdatePressed() {
|
||||
super.onUpdatePressed();
|
||||
installerThread = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
setProgressVisible(true, "");
|
||||
installer.updateIndex();
|
||||
onIndexesUpdated();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
setProgressVisible(false, "");
|
||||
}
|
||||
installerThread = new Thread(() -> {
|
||||
try {
|
||||
setProgressVisible(true, "");
|
||||
installer.updateIndex(this::setProgress);
|
||||
onIndexesUpdated();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
setProgressVisible(false, "");
|
||||
}
|
||||
});
|
||||
installerThread.setUncaughtExceptionHandler(new InstallerJDialogUncaughtExceptionHandler(this, noConnectionErrorMessage));
|
||||
@ -236,19 +219,16 @@ public class LibraryManagerUI extends InstallerJDialog<ContributedLibrary> {
|
||||
|
||||
public void onInstallPressed(final ContributedLibrary lib, final ContributedLibrary replaced) {
|
||||
clearErrorMessage();
|
||||
installerThread = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
setProgressVisible(true, _("Installing..."));
|
||||
installer.install(lib, replaced);
|
||||
onIndexesUpdated(); // TODO: Do a better job in refreshing only the needed element
|
||||
//getContribModel().updateLibrary(lib);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
setProgressVisible(false, "");
|
||||
}
|
||||
installerThread = new Thread(() -> {
|
||||
try {
|
||||
setProgressVisible(true, tr("Installing..."));
|
||||
installer.install(lib, replaced, this::setProgress);
|
||||
onIndexesUpdated(); // TODO: Do a better job in refreshing only the needed element
|
||||
//getContribModel().updateLibrary(lib);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
setProgressVisible(false, "");
|
||||
}
|
||||
});
|
||||
installerThread.setUncaughtExceptionHandler(new InstallerJDialogUncaughtExceptionHandler(this, noConnectionErrorMessage));
|
||||
@ -259,26 +239,23 @@ public class LibraryManagerUI extends InstallerJDialog<ContributedLibrary> {
|
||||
boolean managedByIndex = indexer.getIndex().getLibraries().contains(lib);
|
||||
|
||||
if (!managedByIndex) {
|
||||
int chosenOption = JOptionPane.showConfirmDialog(this, _("This library is not listed on Library Manager. You won't be able to reinstall it from here.\nAre you sure you want to delete it?"), _("Please confirm library deletion"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
|
||||
int chosenOption = JOptionPane.showConfirmDialog(this, tr("This library is not listed on Library Manager. You won't be able to reinstall it from here.\nAre you sure you want to delete it?"), tr("Please confirm library deletion"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
|
||||
if (chosenOption != JOptionPane.YES_OPTION) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
clearErrorMessage();
|
||||
installerThread = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
setProgressVisible(true, _("Removing..."));
|
||||
installer.remove(lib);
|
||||
onIndexesUpdated(); // TODO: Do a better job in refreshing only the needed element
|
||||
//getContribModel().updateLibrary(lib);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
setProgressVisible(false, "");
|
||||
}
|
||||
installerThread = new Thread(() -> {
|
||||
try {
|
||||
setProgressVisible(true, tr("Removing..."));
|
||||
installer.remove(lib, this::setProgress);
|
||||
onIndexesUpdated(); // TODO: Do a better job in refreshing only the needed element
|
||||
//getContribModel().updateLibrary(lib);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
setProgressVisible(false, "");
|
||||
}
|
||||
});
|
||||
installerThread.setUncaughtExceptionHandler(new InstallerJDialogUncaughtExceptionHandler(this, noConnectionErrorMessage));
|
||||
|
@ -30,7 +30,8 @@
|
||||
package cc.arduino.contributions.packages.filters;
|
||||
|
||||
import cc.arduino.contributions.packages.ContributedPlatform;
|
||||
import com.google.common.base.Predicate;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class CategoryPredicate implements Predicate<ContributedPlatform> {
|
||||
|
||||
@ -41,7 +42,7 @@ public class CategoryPredicate implements Predicate<ContributedPlatform> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(ContributedPlatform input) {
|
||||
public boolean test(ContributedPlatform input) {
|
||||
return input.getCategory() != null && category.equals(input.getCategory());
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,64 @@
|
||||
/*
|
||||
* This file is part of Arduino.
|
||||
*
|
||||
* Copyright 2015 Arduino LLC (http://www.arduino.cc/)
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package cc.arduino.contributions.packages.filters;
|
||||
|
||||
import cc.arduino.contributions.VersionComparator;
|
||||
import cc.arduino.contributions.packages.ContributedPlatform;
|
||||
import cc.arduino.contributions.packages.ContributionsIndexer;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class UpdatablePlatformPredicate implements Predicate<ContributedPlatform> {
|
||||
|
||||
private final ContributionsIndexer indexer;
|
||||
private final VersionComparator versionComparator;
|
||||
|
||||
public UpdatablePlatformPredicate(ContributionsIndexer indexer) {
|
||||
this.indexer = indexer;
|
||||
this.versionComparator = new VersionComparator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(ContributedPlatform contributedPlatform) {
|
||||
String packageName = contributedPlatform.getParentPackage().getName();
|
||||
String architecture = contributedPlatform.getArchitecture();
|
||||
|
||||
ContributedPlatform installed = indexer.getInstalled(packageName, architecture);
|
||||
if (installed == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
List<ContributedPlatform> platforms = indexer.getIndex().findPlatforms(packageName, architecture);
|
||||
return platforms.stream()
|
||||
.filter(platform -> versionComparator.greaterThan(platform.getParsedVersion(), installed.getParsedVersion()))
|
||||
.count() > 0;
|
||||
}
|
||||
}
|
@ -29,7 +29,6 @@
|
||||
|
||||
package cc.arduino.contributions.packages.ui;
|
||||
|
||||
import cc.arduino.contributions.DownloadableContribution;
|
||||
import cc.arduino.contributions.DownloadableContributionVersionComparator;
|
||||
import cc.arduino.contributions.VersionComparator;
|
||||
import cc.arduino.contributions.filters.BuiltInPredicate;
|
||||
@ -40,100 +39,73 @@ import cc.arduino.contributions.packages.ContributedPlatform;
|
||||
import cc.arduino.contributions.ui.InstallerTableCell;
|
||||
import cc.arduino.contributions.ui.listeners.DelegatingKeyListener;
|
||||
import cc.arduino.utils.ReverseComparator;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Predicates;
|
||||
import com.google.common.collect.Collections2;
|
||||
import com.google.common.collect.Lists;
|
||||
import processing.app.Base;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.event.HyperlinkEvent;
|
||||
import javax.swing.event.HyperlinkListener;
|
||||
import javax.swing.text.Document;
|
||||
import javax.swing.text.html.HTMLDocument;
|
||||
import javax.swing.text.html.StyleSheet;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ItemEvent;
|
||||
import java.awt.event.ItemListener;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static processing.app.I18n._;
|
||||
import static processing.app.I18n.format;
|
||||
import static processing.app.I18n.tr;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class ContributedPlatformTableCell extends InstallerTableCell {
|
||||
|
||||
private JPanel panel;
|
||||
private JButton installButton;
|
||||
private JButton removeButton;
|
||||
private Component removeButtonPlaceholder;
|
||||
private Component installButtonPlaceholder;
|
||||
private final JPanel panel;
|
||||
private final JButton installButton;
|
||||
private final JButton removeButton;
|
||||
private final Component removeButtonPlaceholder;
|
||||
private final Component installButtonPlaceholder;
|
||||
private JComboBox downgradeChooser;
|
||||
private JComboBox versionToInstallChooser;
|
||||
private JButton downgradeButton;
|
||||
private JPanel buttonsPanel;
|
||||
private JPanel inactiveButtonsPanel;
|
||||
private JLabel statusLabel;
|
||||
private final JComboBox versionToInstallChooser;
|
||||
private final JButton downgradeButton;
|
||||
private final JPanel buttonsPanel;
|
||||
private final JPanel inactiveButtonsPanel;
|
||||
private final JLabel statusLabel;
|
||||
|
||||
public ContributedPlatformTableCell() {
|
||||
{
|
||||
installButton = new JButton(_("Install"));
|
||||
installButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
onInstall(editorValue.getSelected(), editorValue.getInstalled());
|
||||
}
|
||||
});
|
||||
installButton = new JButton(tr("Install"));
|
||||
installButton.addActionListener(e -> onInstall(editorValue.getSelected(), editorValue.getInstalled()));
|
||||
int width = installButton.getPreferredSize().width;
|
||||
installButtonPlaceholder = Box.createRigidArea(new Dimension(width, 1));
|
||||
}
|
||||
|
||||
{
|
||||
removeButton = new JButton(_("Remove"));
|
||||
removeButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
onRemove(editorValue.getInstalled());
|
||||
}
|
||||
});
|
||||
removeButton = new JButton(tr("Remove"));
|
||||
removeButton.addActionListener(e -> onRemove(editorValue.getInstalled()));
|
||||
int width = removeButton.getPreferredSize().width;
|
||||
removeButtonPlaceholder = Box.createRigidArea(new Dimension(width, 1));
|
||||
}
|
||||
|
||||
downgradeButton = new JButton(_("Install"));
|
||||
downgradeButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
ContributedPlatform selected = (ContributedPlatform) downgradeChooser.getSelectedItem();
|
||||
onInstall(selected, editorValue.getInstalled());
|
||||
}
|
||||
downgradeButton = new JButton(tr("Install"));
|
||||
downgradeButton.addActionListener(e -> {
|
||||
ContributedPlatform selected = (ContributedPlatform) downgradeChooser.getSelectedItem();
|
||||
onInstall(selected, editorValue.getInstalled());
|
||||
});
|
||||
|
||||
downgradeChooser = new JComboBox();
|
||||
downgradeChooser.addItem("-");
|
||||
downgradeChooser.setMaximumSize(downgradeChooser.getPreferredSize());
|
||||
downgradeChooser.addItemListener(new ItemListener() {
|
||||
@Override
|
||||
public void itemStateChanged(ItemEvent e) {
|
||||
Object selectVersionItem = downgradeChooser.getItemAt(0);
|
||||
boolean disableDowngrade = (e.getItem() == selectVersionItem);
|
||||
downgradeButton.setEnabled(!disableDowngrade);
|
||||
}
|
||||
downgradeChooser.addItemListener(e -> {
|
||||
Object selectVersionItem = downgradeChooser.getItemAt(0);
|
||||
boolean disableDowngrade = (e.getItem() == selectVersionItem);
|
||||
downgradeButton.setEnabled(!disableDowngrade);
|
||||
});
|
||||
|
||||
versionToInstallChooser = new JComboBox();
|
||||
versionToInstallChooser.addItem("-");
|
||||
versionToInstallChooser.setMaximumSize(versionToInstallChooser.getPreferredSize());
|
||||
versionToInstallChooser.addItemListener(new ItemListener() {
|
||||
@Override
|
||||
public void itemStateChanged(ItemEvent e) {
|
||||
editorValue.select((ContributedPlatform) versionToInstallChooser.getSelectedItem());
|
||||
}
|
||||
});
|
||||
versionToInstallChooser.addItemListener(e -> editorValue.select((ContributedPlatform) versionToInstallChooser.getSelectedItem()));
|
||||
|
||||
panel = new JPanel();
|
||||
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
|
||||
@ -197,19 +169,16 @@ public class ContributedPlatformTableCell extends InstallerTableCell {
|
||||
HTMLDocument html = (HTMLDocument) doc;
|
||||
StyleSheet stylesheet = html.getStyleSheet();
|
||||
stylesheet.addRule("body { margin: 0; padding: 0;"
|
||||
+ "font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;"
|
||||
+ "font-size: 100%;" + "font-size: 0.95em; }");
|
||||
+ "font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;"
|
||||
+ "font-size: 100%;" + "font-size: 0.95em; }");
|
||||
}
|
||||
description.setOpaque(false);
|
||||
description.setBorder(new EmptyBorder(4, 7, 7, 7));
|
||||
description.setHighlighter(null);
|
||||
description.setEditable(false);
|
||||
description.addHyperlinkListener(new HyperlinkListener() {
|
||||
@Override
|
||||
public void hyperlinkUpdate(HyperlinkEvent e) {
|
||||
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
|
||||
Base.openURL(e.getDescription());
|
||||
}
|
||||
description.addHyperlinkListener(e -> {
|
||||
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
|
||||
Base.openURL(e.getDescription());
|
||||
}
|
||||
});
|
||||
description.addKeyListener(new DelegatingKeyListener(parentTable));
|
||||
@ -264,50 +233,39 @@ public class ContributedPlatformTableCell extends InstallerTableCell {
|
||||
|
||||
final ContributedPlatform installed = editorValue.getInstalled();
|
||||
|
||||
java.util.List<ContributedPlatform> releases = new LinkedList<ContributedPlatform>(editorValue.releases);
|
||||
java.util.List<ContributedPlatform> uninstalledReleases = new LinkedList<ContributedPlatform>(Collections2.filter(releases, Predicates.not(new InstalledPredicate())));
|
||||
java.util.List<ContributedPlatform> releases = new LinkedList<>(editorValue.releases);
|
||||
java.util.List<ContributedPlatform> uninstalledReleases = releases.stream().filter(new InstalledPredicate().negate()).collect(Collectors.toList());
|
||||
|
||||
java.util.List<ContributedPlatform> installedBuiltIn = new LinkedList<ContributedPlatform>(Collections2.filter(releases, Predicates.and(new InstalledPredicate(), new BuiltInPredicate())));
|
||||
java.util.List<ContributedPlatform> installedBuiltIn = releases.stream().filter(new InstalledPredicate()).filter(new BuiltInPredicate()).collect(Collectors.toList());
|
||||
|
||||
if (installed != null && !installedBuiltIn.contains(installed)) {
|
||||
uninstalledReleases.addAll(installedBuiltIn);
|
||||
}
|
||||
|
||||
Collections.sort(uninstalledReleases, new ReverseComparator<DownloadableContribution>(new DownloadableContributionVersionComparator()));
|
||||
Collections.sort(uninstalledReleases, new ReverseComparator<>(new DownloadableContributionVersionComparator()));
|
||||
|
||||
downgradeChooser.removeAllItems();
|
||||
downgradeChooser.addItem(_("Select version"));
|
||||
downgradeChooser.addItem(tr("Select version"));
|
||||
|
||||
final java.util.List<ContributedPlatform> uninstalledPreviousReleases = Lists.newLinkedList();
|
||||
final java.util.List<ContributedPlatform> uninstalledNewerReleases = Lists.newLinkedList();
|
||||
final java.util.List<ContributedPlatform> uninstalledPreviousReleases = new LinkedList<>();
|
||||
final java.util.List<ContributedPlatform> uninstalledNewerReleases = new LinkedList<>();
|
||||
|
||||
final VersionComparator versionComparator = new VersionComparator();
|
||||
Lists.newLinkedList(Lists.transform(uninstalledReleases, new Function<ContributedPlatform, ContributedPlatform>() {
|
||||
@Override
|
||||
public ContributedPlatform apply(ContributedPlatform input) {
|
||||
if (installed == null || versionComparator.greaterThan(installed.getParsedVersion(), input.getParsedVersion())) {
|
||||
uninstalledPreviousReleases.add(input);
|
||||
} else {
|
||||
uninstalledNewerReleases.add(input);
|
||||
}
|
||||
|
||||
return input;
|
||||
uninstalledReleases.stream().forEach(input -> {
|
||||
if (installed == null || versionComparator.greaterThan(installed.getParsedVersion(), input.getParsedVersion())) {
|
||||
uninstalledPreviousReleases.add(input);
|
||||
} else {
|
||||
uninstalledNewerReleases.add(input);
|
||||
}
|
||||
}));
|
||||
for (ContributedPlatform release : uninstalledNewerReleases) {
|
||||
downgradeChooser.addItem(release);
|
||||
}
|
||||
for (ContributedPlatform release : uninstalledPreviousReleases) {
|
||||
downgradeChooser.addItem(release);
|
||||
}
|
||||
});
|
||||
uninstalledNewerReleases.forEach(downgradeChooser::addItem);
|
||||
uninstalledPreviousReleases.forEach(downgradeChooser::addItem);
|
||||
|
||||
downgradeChooser.setVisible(installed != null && (!uninstalledPreviousReleases.isEmpty() || uninstalledNewerReleases.size() > 1));
|
||||
downgradeButton.setVisible(installed != null && (!uninstalledPreviousReleases.isEmpty() || uninstalledNewerReleases.size() > 1));
|
||||
|
||||
versionToInstallChooser.removeAllItems();
|
||||
for (ContributedPlatform release : uninstalledReleases) {
|
||||
versionToInstallChooser.addItem(release);
|
||||
}
|
||||
uninstalledReleases.forEach(versionToInstallChooser::addItem);
|
||||
versionToInstallChooser.setVisible(installed == null && uninstalledReleases.size() > 1);
|
||||
|
||||
Component component = getUpdatedCellComponent(value, true, row, !installedBuiltIn.isEmpty());
|
||||
@ -339,10 +297,10 @@ public class ContributedPlatformTableCell extends InstallerTableCell {
|
||||
upgradable = new DownloadableContributionVersionComparator().compare(selected, installed) > 0;
|
||||
}
|
||||
if (installable) {
|
||||
installButton.setText(_("Install"));
|
||||
installButton.setText(tr("Install"));
|
||||
}
|
||||
if (upgradable) {
|
||||
installButton.setText(_("Update"));
|
||||
installButton.setText(tr("Update"));
|
||||
}
|
||||
installButton.setVisible(installable || upgradable);
|
||||
installButtonPlaceholder.setVisible(!(installable || upgradable));
|
||||
@ -360,11 +318,11 @@ public class ContributedPlatformTableCell extends InstallerTableCell {
|
||||
desc += " " + format("by <b>{0}</b>", author);
|
||||
}
|
||||
if (installed != null) {
|
||||
desc += " " + format(_("version <b>{0}</b>"), installed.getParsedVersion()) + " <strong><font color=\"#00979D\">INSTALLED</font></strong>";
|
||||
desc += " " + format(tr("version <b>{0}</b>"), installed.getParsedVersion()) + " <strong><font color=\"#00979D\">INSTALLED</font></strong>";
|
||||
}
|
||||
desc += "<br />";
|
||||
|
||||
desc += _("Boards included in this package:") + "<br />";
|
||||
desc += tr("Boards included in this package:") + "<br />";
|
||||
for (ContributedBoard board : selected.getBoards()) {
|
||||
desc += board.getName() + ", ";
|
||||
}
|
||||
@ -413,7 +371,7 @@ public class ContributedPlatformTableCell extends InstallerTableCell {
|
||||
return panel;
|
||||
}
|
||||
|
||||
private Timer enabler = new Timer(100, new ActionListener() {
|
||||
private final Timer enabler = new Timer(100, new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
enable(true);
|
||||
|
@ -31,18 +31,19 @@ package cc.arduino.contributions.packages.ui;
|
||||
|
||||
import cc.arduino.contributions.DownloadableContributionBuiltInAtTheBottomComparator;
|
||||
import cc.arduino.contributions.filters.InstalledPredicate;
|
||||
import cc.arduino.contributions.packages.ContributedBoard;
|
||||
import cc.arduino.contributions.packages.ContributedPackage;
|
||||
import cc.arduino.contributions.packages.ContributedPlatform;
|
||||
import cc.arduino.contributions.packages.ContributionsIndexer;
|
||||
import cc.arduino.contributions.ui.FilteredAbstractTableModel;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Predicates;
|
||||
import com.google.common.collect.Collections2;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class ContributionIndexTableModel extends FilteredAbstractTableModel<ContributedPlatform> {
|
||||
@ -59,8 +60,8 @@ public class ContributionIndexTableModel extends FilteredAbstractTableModel<Cont
|
||||
public ContributedPlatformReleases(ContributedPlatform platform) {
|
||||
this.packager = platform.getParentPackage();
|
||||
this.arch = platform.getArchitecture();
|
||||
this.releases = new LinkedList<ContributedPlatform>();
|
||||
this.versions = new LinkedList<String>();
|
||||
this.releases = new LinkedList<>();
|
||||
this.versions = new LinkedList<>();
|
||||
add(platform);
|
||||
}
|
||||
|
||||
@ -80,7 +81,7 @@ public class ContributionIndexTableModel extends FilteredAbstractTableModel<Cont
|
||||
}
|
||||
|
||||
public ContributedPlatform getInstalled() {
|
||||
List<ContributedPlatform> installedReleases = new LinkedList<ContributedPlatform>(Collections2.filter(releases, new InstalledPredicate()));
|
||||
List<ContributedPlatform> installedReleases = releases.stream().filter(new InstalledPredicate()).collect(Collectors.toList());
|
||||
Collections.sort(installedReleases, new DownloadableContributionBuiltInAtTheBottomComparator());
|
||||
|
||||
if (installedReleases.isEmpty()) {
|
||||
@ -108,11 +109,11 @@ public class ContributionIndexTableModel extends FilteredAbstractTableModel<Cont
|
||||
}
|
||||
}
|
||||
|
||||
private List<ContributedPlatformReleases> contributions = new ArrayList<ContributedPlatformReleases>();
|
||||
private final List<ContributedPlatformReleases> contributions = new ArrayList<>();
|
||||
|
||||
private String[] columnNames = {"Description"};
|
||||
private final String[] columnNames = {"Description"};
|
||||
|
||||
private Class<?>[] columnTypes = {ContributedPlatform.class};
|
||||
private final Class<?>[] columnTypes = {ContributedPlatform.class};
|
||||
|
||||
private ContributionsIndexer indexer;
|
||||
|
||||
@ -120,15 +121,16 @@ public class ContributionIndexTableModel extends FilteredAbstractTableModel<Cont
|
||||
this.indexer = indexer;
|
||||
}
|
||||
|
||||
public void updateIndexFilter(String filters[], Predicate<ContributedPlatform>... additionalFilters) {
|
||||
public void updateIndexFilter(String[] filters, Stream<Predicate<ContributedPlatform>> additionalFilters) {
|
||||
contributions.clear();
|
||||
Predicate<ContributedPlatform> filter = Predicates.and(additionalFilters);
|
||||
Predicate<ContributedPlatform> filter = additionalFilters.reduce(Predicate::and).get();
|
||||
for (ContributedPackage pack : indexer.getPackages()) {
|
||||
for (ContributedPlatform platform : pack.getPlatforms()) {
|
||||
if (!filter.apply(platform)) {
|
||||
String compoundTargetSearchText = platform.getName() + "\n" + platform.getBoards().stream().map(ContributedBoard::getName).collect(Collectors.joining(" "));
|
||||
if (!filter.test(platform)) {
|
||||
continue;
|
||||
}
|
||||
if (!stringContainsAll(platform.getName(), filters))
|
||||
if (!stringContainsAll(compoundTargetSearchText, filters))
|
||||
continue;
|
||||
addContribution(platform);
|
||||
}
|
||||
|
@ -30,14 +30,12 @@
|
||||
package cc.arduino.contributions.packages.ui;
|
||||
|
||||
import cc.arduino.contributions.DownloadableContribution;
|
||||
import cc.arduino.contributions.GPGDetachedSignatureVerifier;
|
||||
import cc.arduino.contributions.packages.ContributedPlatform;
|
||||
import cc.arduino.contributions.packages.ContributionInstaller;
|
||||
import cc.arduino.contributions.packages.ContributionsIndexer;
|
||||
import cc.arduino.contributions.ui.*;
|
||||
import cc.arduino.utils.Progress;
|
||||
import processing.app.I18n;
|
||||
import processing.app.Platform;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
@ -45,12 +43,13 @@ import java.util.Collection;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import static processing.app.I18n._;
|
||||
import static processing.app.I18n.tr;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class ContributionManagerUI extends InstallerJDialog {
|
||||
|
||||
private final Platform platform;
|
||||
private final ContributionsIndexer indexer;
|
||||
private final ContributionInstaller installer;
|
||||
|
||||
@Override
|
||||
protected FilteredAbstractTableModel createContribModel() {
|
||||
@ -85,12 +84,13 @@ public class ContributionManagerUI extends InstallerJDialog {
|
||||
};
|
||||
}
|
||||
|
||||
public ContributionManagerUI(Frame parent, Platform platform) {
|
||||
super(parent, _("Boards Manager"), Dialog.ModalityType.APPLICATION_MODAL, _("Unable to reach Arduino.cc due to possible network issues."));
|
||||
this.platform = platform;
|
||||
public ContributionManagerUI(Frame parent, ContributionsIndexer indexer, ContributionInstaller installer) {
|
||||
super(parent, tr("Boards Manager"), Dialog.ModalityType.APPLICATION_MODAL, tr("Unable to reach Arduino.cc due to possible network issues."));
|
||||
this.indexer = indexer;
|
||||
this.installer = installer;
|
||||
}
|
||||
|
||||
public void setIndexer(ContributionsIndexer indexer) {
|
||||
public void updateUI() {
|
||||
DropdownItem<DownloadableContribution> previouslySelectedCategory = (DropdownItem<DownloadableContribution>) categoryChooser.getSelectedItem();
|
||||
|
||||
categoryChooser.removeActionListener(categoryChooserActionListener);
|
||||
@ -106,6 +106,7 @@ public class ContributionManagerUI extends InstallerJDialog {
|
||||
|
||||
// Enable categories combo only if there are two or more choices
|
||||
categoryChooser.addItem(new DropdownAllCoresItem());
|
||||
categoryChooser.addItem(new DropdownUpdatableCoresItem(indexer));
|
||||
Collection<String> categories = indexer.getCategories();
|
||||
for (String s : categories) {
|
||||
categoryChooser.addItem(new DropdownCoreOfCategoryItem(s));
|
||||
@ -115,14 +116,6 @@ public class ContributionManagerUI extends InstallerJDialog {
|
||||
} else {
|
||||
categoryChooser.setSelectedIndex(0);
|
||||
}
|
||||
|
||||
// Create ConstributionInstaller tied with the provided index
|
||||
installer = new ContributionInstaller(indexer, platform, new GPGDetachedSignatureVerifier()) {
|
||||
@Override
|
||||
public void onProgress(Progress progress) {
|
||||
setProgress(progress);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public void setProgress(Progress progress) {
|
||||
@ -133,7 +126,6 @@ public class ContributionManagerUI extends InstallerJDialog {
|
||||
* Installer methods follows
|
||||
*/
|
||||
|
||||
private ContributionInstaller installer;
|
||||
private Thread installerThread = null;
|
||||
|
||||
@Override
|
||||
@ -147,19 +139,16 @@ public class ContributionManagerUI extends InstallerJDialog {
|
||||
@Override
|
||||
public void onUpdatePressed() {
|
||||
super.onUpdatePressed();
|
||||
installerThread = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
setProgressVisible(true, "");
|
||||
List<String> downloadedPackageIndexFiles = installer.updateIndex();
|
||||
installer.deleteUnknownFiles(downloadedPackageIndexFiles);
|
||||
onIndexesUpdated();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
setProgressVisible(false, "");
|
||||
}
|
||||
installerThread = new Thread(() -> {
|
||||
try {
|
||||
setProgressVisible(true, "");
|
||||
List<String> downloadedPackageIndexFiles = installer.updateIndex(this::setProgress);
|
||||
installer.deleteUnknownFiles(downloadedPackageIndexFiles);
|
||||
onIndexesUpdated();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
setProgressVisible(false, "");
|
||||
}
|
||||
});
|
||||
installerThread.setUncaughtExceptionHandler(new InstallerJDialogUncaughtExceptionHandler(this, noConnectionErrorMessage));
|
||||
@ -168,24 +157,21 @@ public class ContributionManagerUI extends InstallerJDialog {
|
||||
|
||||
public void onInstallPressed(final ContributedPlatform platformToInstall, final ContributedPlatform platformToRemove) {
|
||||
clearErrorMessage();
|
||||
installerThread = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
List<String> errors = new LinkedList<String>();
|
||||
try {
|
||||
setProgressVisible(true, _("Installing..."));
|
||||
errors.addAll(installer.install(platformToInstall));
|
||||
if (platformToRemove != null && !platformToRemove.isReadOnly()) {
|
||||
errors.addAll(installer.remove(platformToRemove));
|
||||
}
|
||||
onIndexesUpdated();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
setProgressVisible(false, "");
|
||||
if (!errors.isEmpty()) {
|
||||
setErrorMessage(errors.get(0));
|
||||
}
|
||||
installerThread = new Thread(() -> {
|
||||
List<String> errors = new LinkedList<>();
|
||||
try {
|
||||
setProgressVisible(true, tr("Installing..."));
|
||||
errors.addAll(installer.install(platformToInstall, this::setProgress));
|
||||
if (platformToRemove != null && !platformToRemove.isReadOnly()) {
|
||||
errors.addAll(installer.remove(platformToRemove));
|
||||
}
|
||||
onIndexesUpdated();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
setProgressVisible(false, "");
|
||||
if (!errors.isEmpty()) {
|
||||
setErrorMessage(errors.get(0));
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -197,24 +183,21 @@ public class ContributionManagerUI extends InstallerJDialog {
|
||||
clearErrorMessage();
|
||||
|
||||
if (showWarning) {
|
||||
int chosenOption = JOptionPane.showConfirmDialog(this, I18n.format(_("Do you want to remove {0}?\nIf you do so you won't be able to use {0} any more."), platform.getName()), _("Please confirm boards deletion"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
|
||||
int chosenOption = JOptionPane.showConfirmDialog(this, I18n.format(tr("Do you want to remove {0}?\nIf you do so you won't be able to use {0} any more."), platform.getName()), tr("Please confirm boards deletion"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
|
||||
if (chosenOption != JOptionPane.YES_OPTION) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
installerThread = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
setProgressVisible(true, _("Removing..."));
|
||||
installer.remove(platform);
|
||||
onIndexesUpdated();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
setProgressVisible(false, "");
|
||||
}
|
||||
installerThread = new Thread(() -> {
|
||||
try {
|
||||
setProgressVisible(true, tr("Removing..."));
|
||||
installer.remove(platform);
|
||||
onIndexesUpdated();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
setProgressVisible(false, "");
|
||||
}
|
||||
});
|
||||
installerThread.setUncaughtExceptionHandler(new InstallerJDialogUncaughtExceptionHandler(this, noConnectionErrorMessage));
|
||||
|
@ -32,19 +32,20 @@ package cc.arduino.contributions.packages.ui;
|
||||
import cc.arduino.contributions.filters.NoopPredicate;
|
||||
import cc.arduino.contributions.packages.ContributedPlatform;
|
||||
import cc.arduino.contributions.ui.DropdownItem;
|
||||
import com.google.common.base.Predicate;
|
||||
|
||||
import static processing.app.I18n._;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import static processing.app.I18n.tr;
|
||||
|
||||
public class DropdownAllCoresItem implements DropdownItem<ContributedPlatform> {
|
||||
|
||||
public String toString() {
|
||||
return _("All");
|
||||
return tr("All");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Predicate<ContributedPlatform> getFilterPredicate() {
|
||||
return new NoopPredicate<ContributedPlatform>();
|
||||
return new NoopPredicate<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -32,7 +32,8 @@ package cc.arduino.contributions.packages.ui;
|
||||
import cc.arduino.contributions.packages.ContributedPlatform;
|
||||
import cc.arduino.contributions.packages.filters.CategoryPredicate;
|
||||
import cc.arduino.contributions.ui.DropdownItem;
|
||||
import com.google.common.base.Predicate;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class DropdownCoreOfCategoryItem implements DropdownItem<ContributedPlatform> {
|
||||
|
||||
|
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* This file is part of Arduino.
|
||||
*
|
||||
* Copyright 2015 Arduino LLC (http://www.arduino.cc/)
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package cc.arduino.contributions.packages.ui;
|
||||
|
||||
import cc.arduino.contributions.packages.ContributedPlatform;
|
||||
import cc.arduino.contributions.packages.ContributionsIndexer;
|
||||
import cc.arduino.contributions.packages.filters.UpdatablePlatformPredicate;
|
||||
import cc.arduino.contributions.ui.DropdownItem;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import static processing.app.I18n.tr;
|
||||
|
||||
public class DropdownUpdatableCoresItem implements DropdownItem<ContributedPlatform> {
|
||||
|
||||
private final ContributionsIndexer indexer;
|
||||
|
||||
public DropdownUpdatableCoresItem(ContributionsIndexer indexer) {
|
||||
this.indexer = indexer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Predicate<ContributedPlatform> getFilterPredicate() {
|
||||
return new UpdatablePlatformPredicate(indexer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return tr("Updatable");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return obj instanceof DropdownUpdatableCoresItem;
|
||||
}
|
||||
}
|
@ -31,19 +31,20 @@ package cc.arduino.contributions.ui;
|
||||
|
||||
import cc.arduino.contributions.DownloadableContribution;
|
||||
import cc.arduino.contributions.filters.NoopPredicate;
|
||||
import com.google.common.base.Predicate;
|
||||
|
||||
import static processing.app.I18n._;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import static processing.app.I18n.tr;
|
||||
|
||||
public class DropdownAllItem implements DropdownItem<DownloadableContribution> {
|
||||
|
||||
public String toString() {
|
||||
return _("All");
|
||||
return tr("All");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Predicate<DownloadableContribution> getFilterPredicate() {
|
||||
return new NoopPredicate<DownloadableContribution>();
|
||||
return new NoopPredicate<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
package cc.arduino.contributions.ui;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public interface DropdownItem<T> {
|
||||
|
||||
|
@ -102,7 +102,7 @@ public class FilterJTextField extends JTextField {
|
||||
// Empty
|
||||
}
|
||||
|
||||
public void updateStyle() {
|
||||
private void updateStyle() {
|
||||
if (showingHint) {
|
||||
setText(filterHint);
|
||||
setForeground(Color.gray);
|
||||
|
@ -31,27 +31,22 @@ package cc.arduino.contributions.ui;
|
||||
|
||||
import cc.arduino.contributions.DownloadableContribution;
|
||||
import cc.arduino.contributions.VersionComparator;
|
||||
import com.google.common.base.Predicate;
|
||||
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public abstract class FilteredAbstractTableModel<T> extends AbstractTableModel {
|
||||
|
||||
abstract public void updateIndexFilter(String[] filters, Predicate<T>... additionalFilters);
|
||||
abstract public void updateIndexFilter(String[] filters, Stream<Predicate<T>> additionalFilters);
|
||||
|
||||
protected static <T extends DownloadableContribution> T getLatestOf(List<T> contribs) {
|
||||
contribs = new LinkedList<T>(contribs);
|
||||
contribs = new LinkedList<>(contribs);
|
||||
final VersionComparator versionComparator = new VersionComparator();
|
||||
Collections.sort(contribs, new Comparator<T>() {
|
||||
@Override
|
||||
public int compare(T contrib1, T contrib2) {
|
||||
return versionComparator.compare(contrib1.getParsedVersion(), contrib2.getParsedVersion());
|
||||
}
|
||||
});
|
||||
Collections.sort(contribs, (contrib1, contrib2) -> versionComparator.compare(contrib1.getParsedVersion(), contrib2.getParsedVersion()));
|
||||
|
||||
if (contribs.isEmpty()) {
|
||||
return null;
|
||||
|
@ -30,9 +30,6 @@
|
||||
package cc.arduino.contributions.ui;
|
||||
|
||||
import cc.arduino.contributions.ui.listeners.AbstractKeyListener;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Predicates;
|
||||
import com.google.common.collect.Collections2;
|
||||
import processing.app.Base;
|
||||
import processing.app.Theme;
|
||||
|
||||
@ -42,11 +39,11 @@ import javax.swing.table.TableColumn;
|
||||
import javax.swing.table.TableColumnModel;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static cc.arduino.contributions.packages.ui.ContributionIndexTableModel.DESCRIPTION_COL;
|
||||
import static processing.app.I18n._;
|
||||
import static processing.app.I18n.tr;
|
||||
|
||||
public abstract class InstallerJDialog<T> extends JDialog {
|
||||
|
||||
@ -95,7 +92,7 @@ public abstract class InstallerJDialog<T> extends JDialog {
|
||||
categoryChooser.setMaximumRowCount(20);
|
||||
categoryChooser.setEnabled(false);
|
||||
|
||||
filterField = new FilterJTextField(_("Filter your search...")) {
|
||||
filterField = new FilterJTextField(tr("Filter your search...")) {
|
||||
@Override
|
||||
protected void onFilter(String[] _filters) {
|
||||
filters = _filters;
|
||||
@ -109,7 +106,7 @@ public abstract class InstallerJDialog<T> extends JDialog {
|
||||
filtersContainer = new JPanel();
|
||||
filtersContainer.setLayout(new BoxLayout(filtersContainer, BoxLayout.X_AXIS));
|
||||
filtersContainer.add(Box.createHorizontalStrut(5));
|
||||
filtersContainer.add(new JLabel(_("Type")));
|
||||
filtersContainer.add(new JLabel(tr("Type")));
|
||||
filtersContainer.add(Box.createHorizontalStrut(5));
|
||||
filtersContainer.add(categoryChooser);
|
||||
filtersContainer.add(Box.createHorizontalStrut(5));
|
||||
@ -172,35 +169,22 @@ public abstract class InstallerJDialog<T> extends JDialog {
|
||||
errorMessage.setForeground(Color.RED);
|
||||
|
||||
{
|
||||
JButton cancelButton = new JButton(_("Cancel"));
|
||||
cancelButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
onCancelPressed();
|
||||
}
|
||||
});
|
||||
JButton cancelButton = new JButton(tr("Cancel"));
|
||||
cancelButton.addActionListener(arg0 -> onCancelPressed());
|
||||
|
||||
progressBox = Box.createHorizontalBox();
|
||||
progressBox.add(progressBar);
|
||||
progressBox.add(Box.createHorizontalStrut(5));
|
||||
progressBox.add(cancelButton);
|
||||
|
||||
dismissErrorMessageButton = new JButton(_("OK"));
|
||||
dismissErrorMessageButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
clearErrorMessage();
|
||||
setErrorMessageVisible(false);
|
||||
}
|
||||
dismissErrorMessageButton = new JButton(tr("OK"));
|
||||
dismissErrorMessageButton.addActionListener(arg0 -> {
|
||||
clearErrorMessage();
|
||||
setErrorMessageVisible(false);
|
||||
});
|
||||
|
||||
closeButton = new JButton(_("Close"));
|
||||
closeButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
InstallerJDialog.this.dispatchEvent(new WindowEvent(InstallerJDialog.this, WindowEvent.WINDOW_CLOSING));
|
||||
}
|
||||
});
|
||||
closeButton = new JButton(tr("Close"));
|
||||
closeButton.addActionListener(arg0 -> InstallerJDialog.this.dispatchEvent(new WindowEvent(InstallerJDialog.this, WindowEvent.WINDOW_CLOSING)));
|
||||
|
||||
errorMessageBox = Box.createHorizontalBox();
|
||||
errorMessageBox.add(Box.createHorizontalGlue());
|
||||
@ -225,24 +209,14 @@ public abstract class InstallerJDialog<T> extends JDialog {
|
||||
|
||||
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||
|
||||
Base.registerWindowCloseKeys(getRootPane(), new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
InstallerJDialog.this.dispatchEvent(new WindowEvent(InstallerJDialog.this, WindowEvent.WINDOW_CLOSING));
|
||||
}
|
||||
});
|
||||
Base.registerWindowCloseKeys(getRootPane(), e -> InstallerJDialog.this.dispatchEvent(new WindowEvent(InstallerJDialog.this, WindowEvent.WINDOW_CLOSING)));
|
||||
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
onUpdatePressed();
|
||||
}
|
||||
});
|
||||
SwingUtilities.invokeLater(InstallerJDialog.this::onUpdatePressed);
|
||||
}
|
||||
|
||||
public void updateIndexFilter(String[] filters, Predicate<T>... additionalFilters) {
|
||||
Collection<Predicate<T>> notNullAdditionalFilters = Collections2.filter(Arrays.asList(additionalFilters), Predicates.notNull());
|
||||
contribModel.updateIndexFilter(filters, notNullAdditionalFilters.toArray(new Predicate[notNullAdditionalFilters.size()]));
|
||||
Stream<Predicate<T>> notNullAdditionalFilters = Stream.of(additionalFilters).filter(filter -> filter != null);
|
||||
contribModel.updateIndexFilter(filters, notNullAdditionalFilters);
|
||||
}
|
||||
|
||||
public void setErrorMessage(String message) {
|
||||
@ -302,6 +276,19 @@ public abstract class InstallerJDialog<T> extends JDialog {
|
||||
filterField.setText(filterText);
|
||||
}
|
||||
|
||||
public void selectDropdownItemByClassName(String dropdownItem) {
|
||||
selectDropdownItemByClassName(categoryChooser, dropdownItem);
|
||||
}
|
||||
|
||||
public void selectDropdownItemByClassName(JComboBox combo, String dropdownItem) {
|
||||
for (int i = 0; i < combo.getItemCount(); i++) {
|
||||
if (dropdownItem.equals(combo.getItemAt(i).getClass().getSimpleName())) {
|
||||
combo.setSelectedIndex(i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Action performed when the Cancel button is pressed.
|
||||
*/
|
||||
|
@ -31,7 +31,7 @@ package cc.arduino.contributions.ui;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import static processing.app.I18n._;
|
||||
import static processing.app.I18n.tr;
|
||||
|
||||
public class InstallerJDialogUncaughtExceptionHandler implements Thread.UncaughtExceptionHandler {
|
||||
|
||||
@ -45,17 +45,14 @@ public class InstallerJDialogUncaughtExceptionHandler implements Thread.Uncaught
|
||||
|
||||
@Override
|
||||
public void uncaughtException(Thread t, final Throwable e) {
|
||||
String errorMessage = _(e.getMessage().substring(e.getMessage().indexOf(":") + 1));
|
||||
String errorMessage = tr(e.getMessage().substring(e.getMessage().indexOf(":") + 1));
|
||||
if (errorMessage.startsWith("Error downloading")) {
|
||||
errorMessage = connectionErrorMessage;
|
||||
}
|
||||
final String finalErrorMessage = errorMessage;
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
System.err.println(finalErrorMessage);
|
||||
e.printStackTrace();
|
||||
}
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
System.err.println(finalErrorMessage);
|
||||
e.printStackTrace();
|
||||
});
|
||||
parent.setErrorMessage(finalErrorMessage);
|
||||
}
|
||||
|
@ -1,5 +1,3 @@
|
||||
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
|
||||
/*
|
||||
* This file is part of Arduino.
|
||||
*
|
||||
@ -42,7 +40,7 @@ import javax.swing.text.BadLocationException;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import static processing.app.I18n._;
|
||||
import static processing.app.I18n.tr;
|
||||
|
||||
public class AStyle implements Tool {
|
||||
|
||||
@ -84,7 +82,7 @@ public class AStyle implements Tool {
|
||||
String formattedText = aStyleInterface.AStyleMain(originalText, formatterConfiguration);
|
||||
|
||||
if (formattedText.equals(originalText)) {
|
||||
editor.statusNotice(_("No changes necessary for Auto Format."));
|
||||
editor.statusNotice(tr("No changes necessary for Auto Format."));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -107,7 +105,7 @@ public class AStyle implements Tool {
|
||||
}
|
||||
|
||||
// mark as finished
|
||||
editor.statusNotice(_("Auto Format finished."));
|
||||
editor.statusNotice(tr("Auto Format finished."));
|
||||
}
|
||||
|
||||
private void setCaretPosition(SketchTextArea textArea, int line, int lineOffset) throws BadLocationException {
|
||||
@ -140,7 +138,7 @@ public class AStyle implements Tool {
|
||||
|
||||
@Override
|
||||
public String getMenuTitle() {
|
||||
return _("Auto Format");
|
||||
return tr("Auto Format");
|
||||
}
|
||||
|
||||
}
|
||||
|
114
app/src/cc/arduino/view/GoToLineNumber.form
Normal file
114
app/src/cc/arduino/view/GoToLineNumber.form
Normal file
@ -0,0 +1,114 @@
|
||||
<?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" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="tr("Go to line")" type="code"/>
|
||||
</Property>
|
||||
<Property name="modal" type="boolean" value="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" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="lineNumber" pref="203" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
<Component id="ok" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="cancel" min="-2" 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"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="lineNumber" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="cancel" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="ok" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JLabel" name="jLabel1">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="tr("Line number:")" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
<Component class="javax.swing.JTextField" name="lineNumber">
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="lineNumberActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="cancel">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="tr("Cancel")" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cancelActionPerformed"/>
|
||||
</Events>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="ok">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="tr("OK")" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="okActionPerformed"/>
|
||||
</Events>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
148
app/src/cc/arduino/view/GoToLineNumber.java
Normal file
148
app/src/cc/arduino/view/GoToLineNumber.java
Normal file
@ -0,0 +1,148 @@
|
||||
/*
|
||||
* 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.Base;
|
||||
import processing.app.Editor;
|
||||
|
||||
import java.awt.event.WindowEvent;
|
||||
|
||||
import static processing.app.I18n.tr;
|
||||
|
||||
public class GoToLineNumber extends javax.swing.JDialog {
|
||||
|
||||
private final Editor editor;
|
||||
|
||||
public GoToLineNumber(Editor editor) {
|
||||
super(editor);
|
||||
this.editor = editor;
|
||||
initComponents();
|
||||
|
||||
Base.registerWindowCloseKeys(getRootPane(), this::cancelActionPerformed);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
|
||||
javax.swing.JLabel jLabel1 = new javax.swing.JLabel();
|
||||
lineNumber = new javax.swing.JTextField();
|
||||
javax.swing.JButton cancel = new javax.swing.JButton();
|
||||
javax.swing.JButton ok = new javax.swing.JButton();
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
||||
setTitle(tr("Go to line"));
|
||||
setModal(true);
|
||||
setResizable(false);
|
||||
|
||||
jLabel1.setText(tr("Line number:"));
|
||||
|
||||
lineNumber.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
lineNumberActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
cancel.setText(tr("Cancel"));
|
||||
cancel.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
cancelActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
ok.setText(tr("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)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(jLabel1)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(lineNumber, javax.swing.GroupLayout.DEFAULT_SIZE, 203, Short.MAX_VALUE))
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addGap(0, 0, Short.MAX_VALUE)
|
||||
.addComponent(ok)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(cancel)))
|
||||
.addContainerGap())
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(jLabel1)
|
||||
.addComponent(lineNumber, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(cancel)
|
||||
.addComponent(ok))
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
pack();
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void okActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okActionPerformed
|
||||
try {
|
||||
int line = Integer.parseInt(lineNumber.getText());
|
||||
editor.goToLine(line);
|
||||
cancelActionPerformed(evt);
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
}
|
||||
}//GEN-LAST:event_okActionPerformed
|
||||
|
||||
private void cancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelActionPerformed
|
||||
dispatchEvent(new WindowEvent(this, WindowEvent.WINDOW_CLOSING));
|
||||
}//GEN-LAST:event_cancelActionPerformed
|
||||
|
||||
private void lineNumberActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_lineNumberActionPerformed
|
||||
okActionPerformed(evt);
|
||||
}//GEN-LAST:event_lineNumberActionPerformed
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JTextField lineNumber;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
89
app/src/cc/arduino/view/NotificationPopup.form
Normal file
89
app/src/cc/arduino/view/NotificationPopup.form
Normal file
@ -0,0 +1,89 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
|
||||
<Properties>
|
||||
<Property name="defaultCloseOperation" type="int" value="2"/>
|
||||
<Property name="alwaysOnTop" type="boolean" value="true"/>
|
||||
<Property name="focusable" type="boolean" value="false"/>
|
||||
<Property name="focusableWindowState" type="boolean" value="false"/>
|
||||
<Property name="undecorated" type="boolean" value="true"/>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[350, 70]"/>
|
||||
</Property>
|
||||
<Property name="resizable" type="boolean" value="false"/>
|
||||
<Property name="size" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[350, 70]"/>
|
||||
</Property>
|
||||
</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"/>
|
||||
<AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,0,0,0,2,14"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout">
|
||||
<Property name="useNullLayout" type="boolean" value="true"/>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JLabel" name="icon">
|
||||
<Properties>
|
||||
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="new ImageIcon(Paths.get(BaseNoGui.getContentFile("lib").getAbsolutePath(), "arduino_small.png").toFile().getAbsolutePath())" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription">
|
||||
<AbsoluteConstraints x="10" y="10" width="50" height="50"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
</Component>
|
||||
<Component class="javax.swing.JEditorPane" name="text">
|
||||
<Properties>
|
||||
<Property name="editable" type="boolean" value="false"/>
|
||||
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
|
||||
<Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo">
|
||||
<LineBorder roundedCorners="true" thickness="0"/>
|
||||
</Border>
|
||||
</Property>
|
||||
<Property name="contentType" type="java.lang.String" value="text/html" noResource="true"/>
|
||||
<Property name="opaque" type="boolean" value="false"/>
|
||||
</Properties>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription">
|
||||
<AbsoluteConstraints x="70" y="10" width="270" height="50"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="closeButton">
|
||||
<Properties>
|
||||
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="new ImageIcon(Paths.get(BaseNoGui.getContentFile("lib").getAbsolutePath(), "theme", "close.png").toFile().getAbsolutePath())" type="code"/>
|
||||
</Property>
|
||||
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
|
||||
<Border info="null"/>
|
||||
</Property>
|
||||
<Property name="borderPainted" type="boolean" value="false"/>
|
||||
<Property name="hideActionText" type="boolean" value="true"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="closeButtonActionPerformed"/>
|
||||
</Events>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription">
|
||||
<AbsoluteConstraints x="328" y="0" width="22" height="22"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
181
app/src/cc/arduino/view/NotificationPopup.java
Normal file
181
app/src/cc/arduino/view/NotificationPopup.java
Normal file
@ -0,0 +1,181 @@
|
||||
/*
|
||||
* 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.Base;
|
||||
import processing.app.BaseNoGui;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.HyperlinkEvent;
|
||||
import javax.swing.event.HyperlinkListener;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
public class NotificationPopup extends JDialog {
|
||||
|
||||
private final ComponentAdapter parentMovedListener;
|
||||
|
||||
public NotificationPopup(Frame parent, HyperlinkListener hyperlinkListener, String message) {
|
||||
super(parent, false);
|
||||
initComponents();
|
||||
|
||||
updateLocation(parent);
|
||||
parentMovedListener = new ComponentAdapter() {
|
||||
@Override
|
||||
public void componentMoved(ComponentEvent e) {
|
||||
updateLocation(parent);
|
||||
}
|
||||
};
|
||||
parent.addComponentListener(parentMovedListener);
|
||||
|
||||
text.setText("<html><body style=\"font-family:sans-serif;font-size:12pt\">" + message + "</body></html>");
|
||||
|
||||
text.addHyperlinkListener(hyperlinkListener);
|
||||
text.addHyperlinkListener(e -> {
|
||||
if (e.getEventType() != HyperlinkEvent.EventType.ACTIVATED) {
|
||||
return;
|
||||
}
|
||||
close();
|
||||
});
|
||||
|
||||
addWindowListener(new WindowAdapter() {
|
||||
@Override
|
||||
public void windowClosed(WindowEvent e) {
|
||||
parent.removeComponentListener(parentMovedListener);
|
||||
}
|
||||
});
|
||||
|
||||
Base.registerWindowCloseKeys(getRootPane(), e -> close());
|
||||
|
||||
MouseAdapter closeOnClick = new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
close();
|
||||
}
|
||||
};
|
||||
addMouseListener(closeOnClick);
|
||||
text.addMouseListener(closeOnClick);
|
||||
icon.addMouseListener(closeOnClick);
|
||||
}
|
||||
|
||||
private void updateLocation(Frame parent) {
|
||||
Point parentLocation = parent.getLocation();
|
||||
|
||||
int parentX = Double.valueOf(parentLocation.getX()).intValue();
|
||||
int parentY = Double.valueOf(parentLocation.getY()).intValue();
|
||||
setLocation(parentX, parentY + parent.getHeight() - getHeight());
|
||||
}
|
||||
|
||||
public void close() {
|
||||
dispatchEvent(new WindowEvent(NotificationPopup.this, WindowEvent.WINDOW_CLOSING));
|
||||
}
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
|
||||
icon = new javax.swing.JLabel();
|
||||
text = new javax.swing.JEditorPane();
|
||||
closeButton = new javax.swing.JButton();
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
||||
setAlwaysOnTop(true);
|
||||
setFocusable(false);
|
||||
setFocusableWindowState(false);
|
||||
setUndecorated(true);
|
||||
setPreferredSize(new java.awt.Dimension(350, 70));
|
||||
setResizable(false);
|
||||
setSize(new java.awt.Dimension(350, 70));
|
||||
getContentPane().setLayout(null);
|
||||
|
||||
icon.setIcon(new ImageIcon(Paths.get(BaseNoGui.getContentFile("lib").getAbsolutePath(), "arduino_small.png").toFile().getAbsolutePath()));
|
||||
getContentPane().add(icon);
|
||||
icon.setBounds(10, 10, 50, 50);
|
||||
|
||||
text.setEditable(false);
|
||||
text.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 0, true));
|
||||
text.setContentType("text/html"); // NOI18N
|
||||
text.setOpaque(false);
|
||||
getContentPane().add(text);
|
||||
text.setBounds(70, 10, 270, 50);
|
||||
|
||||
closeButton.setIcon(new ImageIcon(Paths.get(BaseNoGui.getContentFile("lib").getAbsolutePath(), "theme", "close.png").toFile().getAbsolutePath()));
|
||||
closeButton.setBorder(null);
|
||||
closeButton.setBorderPainted(false);
|
||||
closeButton.setHideActionText(true);
|
||||
closeButton.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
closeButtonActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
getContentPane().add(closeButton);
|
||||
closeButton.setBounds(328, 0, 22, 22);
|
||||
|
||||
pack();
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void closeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_closeButtonActionPerformed
|
||||
close();
|
||||
}//GEN-LAST:event_closeButtonActionPerformed
|
||||
|
||||
/**
|
||||
* @param args the command line arguments
|
||||
*/
|
||||
public static void main(String args[]) {
|
||||
|
||||
/* Create and display the dialog */
|
||||
EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
NotificationPopup dialog = new NotificationPopup(new JFrame(), System.out::println, "<a href='arduinoide://boardsmanager'>test</a> test test test test test test test test\n" +
|
||||
" test test test test test test test test test test test");
|
||||
dialog.addWindowListener(new WindowAdapter() {
|
||||
@Override
|
||||
public void windowClosing(WindowEvent e) {
|
||||
System.exit(0);
|
||||
}
|
||||
});
|
||||
dialog.setVisible(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JButton closeButton;
|
||||
private javax.swing.JLabel icon;
|
||||
private javax.swing.JEditorPane text;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
}
|
@ -79,7 +79,11 @@ public class SplashScreenHelper {
|
||||
splashGraphics.drawString(str, (int) splashTextArea.getX() + 10, (int) splashTextArea.getY() + (30 - metrics.getHeight()) + 4);
|
||||
|
||||
// make sure it's displayed
|
||||
splash.update();
|
||||
synchronized (SplashScreen.class) {
|
||||
if (splash.isVisible()) {
|
||||
splash.update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void close() {
|
||||
|
@ -40,7 +40,7 @@ import java.awt.event.WindowEvent;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static processing.app.I18n._;
|
||||
import static processing.app.I18n.tr;
|
||||
|
||||
public class FindReplace extends javax.swing.JFrame {
|
||||
|
||||
@ -137,25 +137,25 @@ public class FindReplace extends javax.swing.JFrame {
|
||||
replaceAllButton = new javax.swing.JButton();
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
||||
setTitle(_("Find"));
|
||||
setTitle(tr("Find"));
|
||||
|
||||
findLabel.setText(_("Find:"));
|
||||
findLabel.setText(tr("Find:"));
|
||||
|
||||
findField.setColumns(20);
|
||||
|
||||
replaceLabel.setText(_("Replace with:"));
|
||||
replaceLabel.setText(tr("Replace with:"));
|
||||
|
||||
replaceField.setColumns(20);
|
||||
|
||||
ignoreCaseBox.setSelected(true);
|
||||
ignoreCaseBox.setText(_("Ignore Case"));
|
||||
ignoreCaseBox.setText(tr("Ignore Case"));
|
||||
|
||||
wrapAroundBox.setSelected(true);
|
||||
wrapAroundBox.setText(_("Wrap Around"));
|
||||
wrapAroundBox.setText(tr("Wrap Around"));
|
||||
|
||||
searchAllFilesBox.setText(_("Search all Sketch Tabs"));
|
||||
searchAllFilesBox.setText(tr("Search all Sketch Tabs"));
|
||||
|
||||
findButton.setText(_("Find"));
|
||||
findButton.setText(tr("Find"));
|
||||
findButton.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
findButtonActionPerformed(evt);
|
||||
@ -163,7 +163,7 @@ public class FindReplace extends javax.swing.JFrame {
|
||||
});
|
||||
buttonsContainer.add(findButton);
|
||||
|
||||
previousButton.setText(_("Previous"));
|
||||
previousButton.setText(tr("Previous"));
|
||||
previousButton.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
previousButtonActionPerformed(evt);
|
||||
@ -171,7 +171,7 @@ public class FindReplace extends javax.swing.JFrame {
|
||||
});
|
||||
buttonsContainer.add(previousButton);
|
||||
|
||||
replaceFindButton.setText(_("Replace & Find"));
|
||||
replaceFindButton.setText(tr("Replace & Find"));
|
||||
replaceFindButton.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
replaceFindButtonActionPerformed(evt);
|
||||
@ -179,7 +179,7 @@ public class FindReplace extends javax.swing.JFrame {
|
||||
});
|
||||
buttonsContainer.add(replaceFindButton);
|
||||
|
||||
replaceButton.setText(_("Replace"));
|
||||
replaceButton.setText(tr("Replace"));
|
||||
replaceButton.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
replaceButtonActionPerformed(evt);
|
||||
@ -187,7 +187,7 @@ public class FindReplace extends javax.swing.JFrame {
|
||||
});
|
||||
buttonsContainer.add(replaceButton);
|
||||
|
||||
replaceAllButton.setText(_("Replace All"));
|
||||
replaceAllButton.setText(tr("Replace All"));
|
||||
replaceAllButton.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
replaceAllButtonActionPerformed(evt);
|
||||
|
@ -29,8 +29,6 @@
|
||||
|
||||
package cc.arduino.view.preferences;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.collect.FluentIterable;
|
||||
import processing.app.Base;
|
||||
|
||||
import java.awt.*;
|
||||
@ -39,8 +37,9 @@ import java.awt.event.ActionListener;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static processing.app.I18n._;
|
||||
import static processing.app.I18n.tr;
|
||||
|
||||
public class AdditionalBoardsManagerURLTextArea extends javax.swing.JDialog {
|
||||
|
||||
@ -70,7 +69,7 @@ public class AdditionalBoardsManagerURLTextArea extends javax.swing.JDialog {
|
||||
unofficialListURLLabel = new javax.swing.JLabel();
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
||||
setTitle(_("Additional Boards Manager URLs"));
|
||||
setTitle(tr("Additional Boards Manager URLs"));
|
||||
setModal(true);
|
||||
setModalExclusionType(java.awt.Dialog.ModalExclusionType.APPLICATION_EXCLUDE);
|
||||
|
||||
@ -79,23 +78,23 @@ public class AdditionalBoardsManagerURLTextArea extends javax.swing.JDialog {
|
||||
additionalBoardsManagerURLs.setName(""); // NOI18N
|
||||
jScrollPane1.setViewportView(additionalBoardsManagerURLs);
|
||||
|
||||
cancel.setText(_("Cancel"));
|
||||
cancel.setText(tr("Cancel"));
|
||||
cancel.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
cancelActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
ok.setText(_("OK"));
|
||||
ok.setText(tr("OK"));
|
||||
ok.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
okActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
jLabel1.setText(_("Enter additional URLs, one for each row"));
|
||||
jLabel1.setText(tr("Enter additional URLs, one for each row"));
|
||||
|
||||
unofficialListURLLabel.setText(_("Click for a list of unofficial boards support URLs"));
|
||||
unofficialListURLLabel.setText(tr("Click for a list of unofficial boards support URLs"));
|
||||
unofficialListURLLabel.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
|
||||
unofficialListURLLabel.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mouseClicked(java.awt.event.MouseEvent evt) {
|
||||
@ -174,17 +173,17 @@ public class AdditionalBoardsManagerURLTextArea extends javax.swing.JDialog {
|
||||
|
||||
public void setText(String text) {
|
||||
Collection<String> urls = splitAndTrim(text, ",");
|
||||
additionalBoardsManagerURLs.setText(Joiner.on("\n").skipNulls().join(urls));
|
||||
additionalBoardsManagerURLs.setText(urls.stream().filter(s -> s != null).collect(Collectors.joining("\n")));
|
||||
}
|
||||
|
||||
private Collection<String> splitAndTrim(String text, String separator) {
|
||||
Collection<String> urls = Arrays.asList(text.split(separator));
|
||||
return FluentIterable.from(urls).transform(String::trim).filter(url -> !url.isEmpty()).toList();
|
||||
return urls.stream().map(String::trim).filter(url -> !url.isEmpty()).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
Collection<String> urls = splitAndTrim(additionalBoardsManagerURLs.getText(), "\n");
|
||||
return Joiner.on(",").skipNulls().join(urls);
|
||||
return urls.stream().filter(s -> s != null).collect(Collectors.joining(","));
|
||||
}
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
|
@ -1,10 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
|
||||
<NonVisualComponents>
|
||||
<Component class="javax.swing.ButtonGroup" name="proxyTypeButtonGroup">
|
||||
</Component>
|
||||
<Component class="javax.swing.ButtonGroup" name="manualProxyTypeButtonGroup">
|
||||
</Component>
|
||||
</NonVisualComponents>
|
||||
<Properties>
|
||||
<Property name="defaultCloseOperation" type="int" value="2"/>
|
||||
<Property name="title" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="_("Preferences")" type="code"/>
|
||||
<Connection code="tr("Preferences")" type="code"/>
|
||||
</Property>
|
||||
<Property name="modal" type="boolean" value="true"/>
|
||||
<Property name="resizable" type="boolean" value="false"/>
|
||||
@ -28,354 +34,23 @@
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<Component id="sketchbookLocationField" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="browseButton" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="checkboxesContainer" max="32767" attributes="0"/>
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<Component id="okButton" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="cancelButton" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<Component id="additionalBoardsManagerLabel" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="additionalBoardsManagerField" min="-2" pref="500" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="extendedAdditionalUrlFieldWindow" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="sketchbookLocationLabel" min="-2" max="-2" attributes="0"/>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="comboWarningsLabel" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="comboWarnings" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="showVerboseLabel" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="verboseCompilationBox" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="verboseUploadBox" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="comboLanguageLabel" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="fontSizeLabel" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="fontSizeField" min="-2" max="-2" attributes="0"/>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="comboLanguage" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="requiresRestartLabel" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</Group>
|
||||
<Component id="arduinoNotRunningLabel" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="morePreferencesLabel" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="preferencesFileLabel" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<EmptySpace min="0" pref="691" max="32767" attributes="0"/>
|
||||
<Group type="103" rootIndex="1" groupAlignment="0" attributes="0">
|
||||
<Component id="jPanel2" alignment="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="sketchbookLocationLabel" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="sketchbookLocationField" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="browseButton" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="comboLanguageLabel" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="comboLanguage" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="requiresRestartLabel" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="fontSizeLabel" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="fontSizeField" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="showVerboseLabel" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="verboseCompilationBox" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="verboseUploadBox" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="comboWarningsLabel" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="comboWarnings" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="checkboxesContainer" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="103" alignment="0" groupAlignment="3" attributes="0">
|
||||
<Component id="additionalBoardsManagerLabel" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="additionalBoardsManagerField" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="extendedAdditionalUrlFieldWindow" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="morePreferencesLabel" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="preferencesFileLabel" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="arduinoNotRunningLabel" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="cancelButton" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="okButton" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<EmptySpace min="0" pref="610" max="32767" attributes="0"/>
|
||||
<Group type="103" rootIndex="1" groupAlignment="0" attributes="0">
|
||||
<Component id="jPanel2" alignment="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JLabel" name="sketchbookLocationLabel">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="_("Sketchbook location:")" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
<Component class="javax.swing.JTextField" name="sketchbookLocationField">
|
||||
<Properties>
|
||||
<Property name="columns" type="int" value="40"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="browseButton">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="I18n.PROMPT_BROWSE" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="browseButtonActionPerformed"/>
|
||||
</Events>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="comboLanguageLabel">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="_("Editor language: ")" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
<Component class="javax.swing.JComboBox" name="comboLanguage">
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new JComboBox(languages)"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="requiresRestartLabel">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="_(" (requires restart of Arduino)")" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="fontSizeLabel">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="_("Editor font size: ")" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
<Component class="javax.swing.JTextField" name="fontSizeField">
|
||||
<Properties>
|
||||
<Property name="columns" type="int" value="4"/>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value=""/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="showVerboseLabel">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="_("Show verbose output during: ")" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
<Component class="javax.swing.JCheckBox" name="verboseCompilationBox">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="_("compilation ")" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JCheckBox" name="verboseUploadBox">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="_("upload")" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="comboWarningsLabel">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="_("Compiler warnings: ")" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
<Component class="javax.swing.JComboBox" name="comboWarnings">
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new JComboBox(warningItems)"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="additionalBoardsManagerLabel">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="_("Additional Boards Manager URLs: ")" type="code"/>
|
||||
</Property>
|
||||
<Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="_("Enter a comma separated list of urls")" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
<Component class="javax.swing.JTextField" name="additionalBoardsManagerField">
|
||||
<Properties>
|
||||
<Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="_("Enter a comma separated list of urls")" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="extendedAdditionalUrlFieldWindow">
|
||||
<Properties>
|
||||
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="new ImageIcon(Base.getThemeImage("newwindow.gif", this))" type="code"/>
|
||||
</Property>
|
||||
<Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor">
|
||||
<Insets value="[1, 1, 1, 1]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="extendedAdditionalUrlFieldWindowActionPerformed"/>
|
||||
</Events>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="morePreferencesLabel">
|
||||
<Properties>
|
||||
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="Color.GRAY" type="code"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="_("More preferences can be edited directly in the file")" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="preferencesFileLabel">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="PreferencesData.getPreferencesFile().getAbsolutePath()" type="code"/>
|
||||
</Property>
|
||||
<Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
|
||||
<Color id="Cursore mano"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="mousePressed" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="preferencesFileLabelMousePressed"/>
|
||||
<EventHandler event="mouseExited" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="preferencesFileLabelMouseExited"/>
|
||||
<EventHandler event="mouseEntered" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="preferencesFileLabelMouseEntered"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="arduinoNotRunningLabel">
|
||||
<Properties>
|
||||
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="Color.GRAY" type="code"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="_("(edit only when Arduino is not running)")" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="okButton">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="I18n.PROMPT_OK" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="okButtonActionPerformed"/>
|
||||
</Events>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="cancelButton">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="I18n.PROMPT_CANCEL" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cancelButtonActionPerformed"/>
|
||||
</Events>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
<Container class="javax.swing.JPanel" name="checkboxesContainer">
|
||||
<Container class="javax.swing.JPanel" name="jPanel2">
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
|
||||
@ -385,55 +60,753 @@
|
||||
<Property name="axis" type="int" value="1"/>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JCheckBox" name="displayLineNumbersBox">
|
||||
<Container class="javax.swing.JTabbedPane" name="jTabbedPane1">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="_("Display line numbers")" type="code"/>
|
||||
</Property>
|
||||
<Property name="focusable" type="boolean" value="false"/>
|
||||
<Property name="requestFocusEnabled" type="boolean" value="false"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JCheckBox" name="enableCodeFoldingBox">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="_("Enable Code Folding")" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JCheckBox" name="verifyUploadBox">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="_("Verify code after upload")" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JCheckBox" name="externalEditorBox">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="_("Use external editor")" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JCheckBox" name="checkUpdatesBox">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="_("Check for updates on startup")" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JCheckBox" name="updateExtensionBox">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="_("Update sketch files to new extension on save (.pde -> .ino)")" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JCheckBox" name="saveVerifyUploadBox">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="_("Save when verifying or uploading")" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout"/>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JPanel" name="jPanel1">
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
|
||||
</AuxValues>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription">
|
||||
<JTabbedPaneConstraints tabName="<User Code>">
|
||||
<Property name="tabTitle" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="tr("Settings")" type="code"/>
|
||||
</Property>
|
||||
</JTabbedPaneConstraints>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<Component id="sketchbookLocationField" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="browseButton" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="checkboxesContainer" max="32767" attributes="0"/>
|
||||
<Group type="102" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="comboWarningsLabel" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="comboWarnings" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="showVerboseLabel" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="verboseCompilationBox" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="verboseUploadBox" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="comboLanguageLabel" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="fontSizeLabel" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="fontSizeField" min="-2" max="-2" attributes="0"/>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="comboLanguage" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="requiresRestartLabel" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</Group>
|
||||
<Component id="arduinoNotRunningLabel" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="morePreferencesLabel" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="preferencesFileLabel" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="sketchbookLocationLabel" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="additionalBoardsManagerLabel" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="additionalBoardsManagerField" min="-2" pref="500" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="extendedAdditionalUrlFieldWindow" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace min="0" pref="0" max="32767" 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="1" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="sketchbookLocationLabel" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="sketchbookLocationField" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="browseButton" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="comboLanguageLabel" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="comboLanguage" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="requiresRestartLabel" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="fontSizeLabel" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="fontSizeField" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="showVerboseLabel" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="verboseCompilationBox" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="verboseUploadBox" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="comboWarningsLabel" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="comboWarnings" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="checkboxesContainer" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="103" alignment="0" groupAlignment="3" attributes="0">
|
||||
<Component id="additionalBoardsManagerLabel" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="additionalBoardsManagerField" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="extendedAdditionalUrlFieldWindow" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="morePreferencesLabel" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="preferencesFileLabel" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="arduinoNotRunningLabel" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JLabel" name="sketchbookLocationLabel">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="tr("Sketchbook location:")" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
<Component class="javax.swing.JTextField" name="sketchbookLocationField">
|
||||
<Properties>
|
||||
<Property name="columns" type="int" value="40"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="browseButton">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="I18n.PROMPT_BROWSE" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="browseButtonActionPerformed"/>
|
||||
</Events>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="comboLanguageLabel">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="tr("Editor language: ")" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
<Component class="javax.swing.JComboBox" name="comboLanguage">
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new JComboBox(languages)"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="requiresRestartLabel">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="tr(" (requires restart of Arduino)")" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="fontSizeLabel">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="tr("Editor font size: ")" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
<Component class="javax.swing.JTextField" name="fontSizeField">
|
||||
<Properties>
|
||||
<Property name="columns" type="int" value="4"/>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value=""/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="showVerboseLabel">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="tr("Show verbose output during: ")" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
<Component class="javax.swing.JCheckBox" name="verboseCompilationBox">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="tr("compilation ")" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JCheckBox" name="verboseUploadBox">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="tr("upload")" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="comboWarningsLabel">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="tr("Compiler warnings: ")" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
<Component class="javax.swing.JComboBox" name="comboWarnings">
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new JComboBox(warningItems)"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="additionalBoardsManagerLabel">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="tr("Additional Boards Manager URLs: ")" type="code"/>
|
||||
</Property>
|
||||
<Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="tr("Enter a comma separated list of urls")" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
<Component class="javax.swing.JTextField" name="additionalBoardsManagerField">
|
||||
<Properties>
|
||||
<Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="tr("Enter a comma separated list of urls")" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="extendedAdditionalUrlFieldWindow">
|
||||
<Properties>
|
||||
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="new ImageIcon(Base.getThemeImage("newwindow.gif", this))" type="code"/>
|
||||
</Property>
|
||||
<Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor">
|
||||
<Insets value="[1, 1, 1, 1]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="extendedAdditionalUrlFieldWindowActionPerformed"/>
|
||||
</Events>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="morePreferencesLabel">
|
||||
<Properties>
|
||||
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="Color.GRAY" type="code"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="tr("More preferences can be edited directly in the file")" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="preferencesFileLabel">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="PreferencesData.getPreferencesFile().getAbsolutePath()" type="code"/>
|
||||
</Property>
|
||||
<Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
|
||||
<Color id="Cursore mano"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="mousePressed" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="preferencesFileLabelMousePressed"/>
|
||||
<EventHandler event="mouseExited" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="preferencesFileLabelMouseExited"/>
|
||||
<EventHandler event="mouseEntered" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="preferencesFileLabelMouseEntered"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="arduinoNotRunningLabel">
|
||||
<Properties>
|
||||
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="Color.GRAY" type="code"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="tr("(edit only when Arduino is not running)")" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
<Container class="javax.swing.JPanel" name="checkboxesContainer">
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout">
|
||||
<Property name="axis" type="int" value="1"/>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JCheckBox" name="displayLineNumbersBox">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="tr("Display line numbers")" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JCheckBox" name="enableCodeFoldingBox">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="tr("Enable Code Folding")" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JCheckBox" name="verifyUploadBox">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="tr("Verify code after upload")" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JCheckBox" name="externalEditorBox">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="tr("Use external editor")" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JCheckBox" name="checkUpdatesBox">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="tr("Check for updates on startup")" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JCheckBox" name="updateExtensionBox">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="tr("Update sketch files to new extension on save (.pde -> .ino)")" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JCheckBox" name="saveVerifyUploadBox">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="tr("Save when verifying or uploading")" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Container class="javax.swing.JPanel" name="jPanel4">
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
|
||||
</AuxValues>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription">
|
||||
<JTabbedPaneConstraints tabName="<User Code>">
|
||||
<Property name="tabTitle" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="tr("Network")" type="code"/>
|
||||
</Property>
|
||||
</JTabbedPaneConstraints>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace min="12" pref="12" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="autoProxyUsePAC" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace min="12" pref="12" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="autoProxyUsernameLabel" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="autoProxyPasswordLabel" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="autoProxyPACURL" max="32767" attributes="0"/>
|
||||
<Group type="102" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="autoProxyUsername" min="-2" pref="178" max="-2" attributes="0"/>
|
||||
<Component id="autoProxyPassword" min="-2" pref="180" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</Group>
|
||||
<Group type="102" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="noProxy" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="autoProxy" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="manualProxy" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace min="12" pref="12" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="manualProxyHTTP" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="manualProxySOCKS" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="manualProxyHostNameLabel" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="manualProxyPortLabel" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="manualProxyUsernameLabel" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="manualProxyPasswordLabel" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace type="separate" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="manualProxyHostName" min="-2" pref="541" max="-2" attributes="0"/>
|
||||
<Component id="manualProxyPort" alignment="0" min="-2" pref="74" max="-2" attributes="0"/>
|
||||
<Group type="103" alignment="0" groupAlignment="1" max="-2" attributes="0">
|
||||
<Component id="manualProxyPassword" alignment="0" max="32767" attributes="0"/>
|
||||
<Component id="manualProxyUsername" alignment="0" min="-2" pref="180" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</Group>
|
||||
</Group>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace min="0" pref="0" max="32767" 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="noProxy" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="autoProxy" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="autoProxyUsePAC" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="autoProxyPACURL" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="autoProxyUsername" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="autoProxyUsernameLabel" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="autoProxyPasswordLabel" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="autoProxyPassword" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="manualProxy" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="manualProxyHTTP" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="manualProxySOCKS" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="manualProxyHostNameLabel" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="manualProxyHostName" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="manualProxyPort" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="manualProxyPortLabel" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="manualProxyUsername" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="manualProxyUsernameLabel" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="manualProxyPassword" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="manualProxyPasswordLabel" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace pref="163" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JRadioButton" name="noProxy">
|
||||
<Properties>
|
||||
<Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
|
||||
<ComponentRef name="proxyTypeButtonGroup"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="tr("No proxy")" type="code"/>
|
||||
</Property>
|
||||
<Property name="actionCommand" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="Constants.PROXY_TYPE_NONE" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JRadioButton" name="autoProxy">
|
||||
<Properties>
|
||||
<Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
|
||||
<ComponentRef name="proxyTypeButtonGroup"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="tr("Auto-detect proxy settings")" type="code"/>
|
||||
</Property>
|
||||
<Property name="actionCommand" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="Constants.PROXY_TYPE_AUTO" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="autoProxyItemStateChanged"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JRadioButton" name="manualProxy">
|
||||
<Properties>
|
||||
<Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
|
||||
<ComponentRef name="proxyTypeButtonGroup"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="tr("Manual proxy configuration")" type="code"/>
|
||||
</Property>
|
||||
<Property name="actionCommand" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="Constants.PROXY_TYPE_MANUAL" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="manualProxyItemStateChanged"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JCheckBox" name="autoProxyUsePAC">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="tr("Automatic proxy configuration URL:")" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="autoProxyUsePACItemStateChanged"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JTextField" name="autoProxyPACURL">
|
||||
</Component>
|
||||
<Component class="javax.swing.JRadioButton" name="manualProxyHTTP">
|
||||
<Properties>
|
||||
<Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
|
||||
<ComponentRef name="manualProxyTypeButtonGroup"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="HTTP"/>
|
||||
<Property name="actionCommand" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="Constants.PROXY_MANUAL_TYPE_HTTP" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JRadioButton" name="manualProxySOCKS">
|
||||
<Properties>
|
||||
<Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
|
||||
<ComponentRef name="manualProxyTypeButtonGroup"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="SOCKS"/>
|
||||
<Property name="actionCommand" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="Constants.PROXY_MANUAL_TYPE_SOCKS" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="manualProxyHostNameLabel">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="tr("Host name:")" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="manualProxyPortLabel">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="tr("Port number:")" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JTextField" name="manualProxyHostName">
|
||||
</Component>
|
||||
<Component class="javax.swing.JTextField" name="manualProxyPort">
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="manualProxyUsernameLabel">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="tr("Username:")" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JTextField" name="manualProxyUsername">
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="manualProxyPasswordLabel">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="tr("Password:")" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JPasswordField" name="manualProxyPassword">
|
||||
<Properties>
|
||||
<Property name="toolTipText" type="java.lang.String" value=""/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="autoProxyUsernameLabel">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="tr("Username:")" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JTextField" name="autoProxyUsername">
|
||||
</Component>
|
||||
<Component class="javax.swing.JPasswordField" name="autoProxyPassword">
|
||||
<Properties>
|
||||
<Property name="toolTipText" type="java.lang.String" value=""/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="autoProxyPasswordLabel">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="tr("Password:")" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Container class="javax.swing.JPanel" name="jPanel3">
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
<Component id="okButton" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="cancelButton" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="okButton" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="cancelButton" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JButton" name="okButton">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="I18n.PROMPT_OK" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="okButtonActionPerformed"/>
|
||||
</Events>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="cancelButton">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="I18n.PROMPT_CANCEL" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cancelButtonActionPerformed"/>
|
||||
</Events>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
|
@ -29,6 +29,7 @@
|
||||
|
||||
package cc.arduino.view.preferences;
|
||||
|
||||
import cc.arduino.Constants;
|
||||
import processing.app.Base;
|
||||
import processing.app.BaseNoGui;
|
||||
import processing.app.I18n;
|
||||
@ -42,7 +43,7 @@ import java.awt.event.WindowEvent;
|
||||
import java.io.File;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import static processing.app.I18n._;
|
||||
import static processing.app.I18n.tr;
|
||||
|
||||
public class Preferences extends javax.swing.JDialog {
|
||||
|
||||
@ -99,92 +100,80 @@ public class Preferences extends javax.swing.JDialog {
|
||||
this.base = base;
|
||||
|
||||
this.languages = new Language[]{
|
||||
new Language(_("System Default"), "", ""),
|
||||
new Language(_("Albanian"), "shqip", "sq"),
|
||||
new Language(_("Arabic"), "العربية", "ar"),
|
||||
new Language(_("Aragonese"), "Aragonés", "an"),
|
||||
new Language(_("Belarusian"), "Беларуская мова", "be"),
|
||||
new Language(_("Bulgarian"), "български", "bg"),
|
||||
new Language(_("Catalan"), "Català", "ca"),
|
||||
new Language(_("Chinese Simplified"), "简体中文", "zh_CN"),
|
||||
new Language(_("Chinese Traditional"), "繁體中文", "zh_TW"),
|
||||
new Language(_("Croatian"), "Hrvatski", "hr_HR"),
|
||||
new Language(_("Czech (Czech Republic)"), "český (Czech Republic)", "cs_CZ"),
|
||||
new Language(_("Danish (Denmark)"), "Dansk (Denmark)", "da_DK"),
|
||||
new Language(_("Dutch"), "Nederlands", "nl"),
|
||||
new Language(_("English"), "English", "en"),
|
||||
new Language(_("English (United Kingdom)"), "English (United Kingdom)", "en_GB"),
|
||||
new Language(_("Estonian"), "Eesti", "et"),
|
||||
new Language(_("Estonian (Estonia)"), "Eesti keel", "et_EE"),
|
||||
new Language(_("Filipino"), "Pilipino", "fil"),
|
||||
new Language(_("Finnish"), "Suomi", "fi"),
|
||||
new Language(_("French"), "Français", "fr"),
|
||||
new Language(_("Canadian French"), "Canadienne-français", "fr_CA"),
|
||||
new Language(_("Galician"), "Galego", "gl"),
|
||||
new Language(_("Georgian"), "საქართველოს", "ka_GE"),
|
||||
new Language(_("German"), "Deutsch", "de_DE"),
|
||||
new Language(_("Greek"), "ελληνικά", "el_GR"),
|
||||
new Language(_("Hebrew"), "עברית", "he"),
|
||||
new Language(_("Hindi"), "हिंदी", "hi"),
|
||||
new Language(_("Hungarian"), "Magyar", "hu"),
|
||||
new Language(_("Indonesian"), "Bahasa Indonesia", "id"),
|
||||
new Language(_("Italian"), "Italiano", "it_IT"),
|
||||
new Language(_("Japanese"), "日本語", "ja_JP"),
|
||||
new Language(_("Korean"), "한국어", "ko_KR"),
|
||||
new Language(_("Latvian"), "Latviešu", "lv_LV"),
|
||||
new Language(_("Lithuaninan"), "Lietuvių Kalba", "lt_LT"),
|
||||
new Language(_("Norwegian Bokmål"), "Norsk bokmål", "nb_NO"),
|
||||
new Language(_("Persian"), "فارسی", "fa"),
|
||||
new Language(_("Polish"), "Język Polski", "pl"),
|
||||
new Language(_("Portuguese (Brazil)"), "Português (Brazil)", "pt_BR"),
|
||||
new Language(_("Portuguese (Portugal)"), "Português (Portugal)", "pt_PT"),
|
||||
new Language(_("Romanian"), "Română", "ro"),
|
||||
new Language(_("Russian"), "Русский", "ru"),
|
||||
new Language(_("Slovenian"), "Slovenščina", "sl_SI"),
|
||||
new Language(_("Spanish"), "Español", "es"),
|
||||
new Language(_("Swedish"), "Svenska", "sv"),
|
||||
new Language(_("Tamil"), "தமிழ்", "ta"),
|
||||
new Language(_("Turkish"), "Türk", "tr"),
|
||||
new Language(_("Ukrainian"), "Український", "uk"),
|
||||
new Language(_("Vietnamese"), "Tiếng Việt", "vi"),
|
||||
new Language(tr("System Default"), "", ""),
|
||||
new Language(tr("Albanian"), "shqip", "sq"),
|
||||
new Language(tr("Arabic"), "العربية", "ar"),
|
||||
new Language(tr("Aragonese"), "Aragonés", "an"),
|
||||
new Language(tr("Basque"), "Euskara", "eu"),
|
||||
new Language(tr("Belarusian"), "Беларуская мова", "be"),
|
||||
new Language(tr("Bulgarian"), "български", "bg"),
|
||||
new Language(tr("Canadian French"), "Canadienne-français", "fr_CA"),
|
||||
new Language(tr("Catalan"), "Català", "ca"),
|
||||
new Language(tr("Chinese (China)"), "简体中文", "zh_CN"),
|
||||
new Language(tr("Chinese (Taiwan) (Big5)"), "", "zh_TW.Big5"),
|
||||
new Language(tr("Chinese (Taiwan)"), "", "zh_TW"),
|
||||
new Language(tr("Croatian"), "Hrvatski", "hr_HR"),
|
||||
new Language(tr("Czech (Czech Republic)"), "český (Czech Republic)", "cs_CZ"),
|
||||
new Language(tr("Dutch"), "Nederlands", "nl"),
|
||||
new Language(tr("English"), "English", "en"),
|
||||
new Language(tr("English (United Kingdom)"), "English (United Kingdom)", "en_GB"),
|
||||
new Language(tr("Estonian"), "Eesti", "et"),
|
||||
new Language(tr("Estonian (Estonia)"), "Eesti keel", "et_EE"),
|
||||
new Language(tr("Filipino"), "Pilipino", "fil"),
|
||||
new Language(tr("Finnish"), "Suomi", "fi"),
|
||||
new Language(tr("French"), "Français", "fr"),
|
||||
new Language(tr("Galician"), "Galego", "gl"),
|
||||
new Language(tr("Galician (Spain)"), "Galego (Spain)", "gl_ES"),
|
||||
new Language(tr("Georgian"), "საქართველოს", "ka_GE"),
|
||||
new Language(tr("German"), "Deutsch", "de_DE"),
|
||||
new Language(tr("Hebrew"), "עברית", "he"),
|
||||
new Language(tr("Hindi"), "हिंदी", "hi"),
|
||||
new Language(tr("Indonesian"), "Bahasa Indonesia", "id"),
|
||||
new Language(tr("Italian"), "Italiano", "it_IT"),
|
||||
new Language(tr("Japanese"), "日本語", "ja_JP"),
|
||||
new Language(tr("Korean"), "한국어", "ko_KR"),
|
||||
new Language(tr("Latvian"), "Latviešu", "lv_LV"),
|
||||
new Language(tr("Norwegian Bokmål"), "Norsk bokmål", "nb_NO"),
|
||||
new Language(tr("Persian"), "فارسی", "fa"),
|
||||
new Language(tr("Polish"), "Język Polski", "pl"),
|
||||
new Language(tr("Portugese"), "Português", "pt"),
|
||||
new Language(tr("Portuguese (Brazil)"), "Português (Brazil)", "pt_BR"),
|
||||
new Language(tr("Portuguese (Portugal)"), "Português (Portugal)", "pt_PT"),
|
||||
new Language(tr("Romanian"), "Română", "ro"),
|
||||
new Language(tr("Russian"), "Русский", "ru"),
|
||||
new Language(tr("Slovak"), "Slovenčina", "sk"),
|
||||
new Language(tr("Slovenian"), "Slovenščina", "sl_SI"),
|
||||
new Language(tr("Spanish"), "Español", "es"),
|
||||
new Language(tr("Swedish"), "Svenska", "sv"),
|
||||
new Language(tr("Tamil"), "தமிழ்", "ta"),
|
||||
new Language(tr("Turkish"), "Türk", "tr"),
|
||||
new Language(tr("Ukrainian"), "Український", "uk"),
|
||||
new Language(tr("Vietnamese"), "Tiếng Việt", "vi"),
|
||||
};
|
||||
|
||||
this.missingLanguages = new Language[]{
|
||||
new Language(_("Afrikaans"), "Afrikaans", "af"),
|
||||
new Language(_("Armenian"), "Հայերեն", "hy"),
|
||||
new Language(_("Asturian"), "Asturianu", "ast"),
|
||||
new Language(_("Basque"), "Euskara", "eu"),
|
||||
new Language(_("Bengali (India)"), "বাংলা (India)", "bn_IN"),
|
||||
new Language(_("Bosnian"), "Bosanski", "bs"),
|
||||
new Language(_("Burmese (Myanmar)"), "ဗမာစကား", "my_MM"),
|
||||
new Language(_("Chinese (China)"), "", "zh_CN"),
|
||||
new Language(_("Chinese (Hong Kong)"), "", "zh_HK"),
|
||||
new Language(_("Chinese (Taiwan)"), "", "zh_TW"),
|
||||
new Language(_("Chinese (Taiwan) (Big5)"), "", "zh_TW.Big5"),
|
||||
new Language(_("Czech"), "český", "cs"),
|
||||
new Language(_("Danish"), "Dansk", "da"),
|
||||
new Language(_("Dutch (Netherlands)"), "Nederlands", "nl_NL"),
|
||||
new Language(_("Galician (Spain)"), "Galego (Spain)", "gl_ES"),
|
||||
new Language(_("Nepali"), "नेपाली", "ne"),
|
||||
new Language(_("N'Ko"), "ߒߞߏ", "nqo"),
|
||||
new Language(_("Marathi"), "मराठी", "mr"),
|
||||
new Language(_("Malay (Malaysia)"), "بهاس ملايو (Malaysia)", "ms_MY"),
|
||||
new Language(_("Norwegian"), "Norsk", "no"),
|
||||
new Language(_("Norwegian Nynorsk"), "Norsk Nynorsk", "nn"),
|
||||
new Language(_("Portugese"), "Português", "pt"),
|
||||
new Language(_("Persian (Iran)"), "فارسی (Iran)", "fa_IR"),
|
||||
new Language(_("Slovak"), "Slovenčina", "sk"),
|
||||
new Language(_("Swahili"), "كِسوَهِل", "sw"),
|
||||
new Language(_("Talossan"), "Talossan", "tzl"),
|
||||
new Language(_("Urdu (Pakistan)"), "اردو (Pakistan)", "ur_PK"),
|
||||
new Language(_("Western Frisian"), "Western Frisian", "fy"),
|
||||
new Language(tr("Afrikaans"), "Afrikaans", "af"),
|
||||
new Language(tr("Armenian"), "Հայերեն", "hy"),
|
||||
new Language(tr("Asturian"), "Asturianu", "ast"),
|
||||
new Language(tr("Bosnian"), "Bosanski", "bs"),
|
||||
new Language(tr("Burmese (Myanmar)"), "ဗမာစကား", "my_MM"),
|
||||
new Language(tr("Danish (Denmark)"), "Dansk (Denmark)", "da_DK"),
|
||||
new Language(tr("Dutch (Netherlands)"), "Nederlands", "nl_NL"),
|
||||
new Language(tr("Greek"), "ελληνικά", "el_GR"),
|
||||
new Language(tr("Hungarian"), "Magyar", "hu"),
|
||||
new Language(tr("Lithuaninan"), "Lietuvių Kalba", "lt_LT"),
|
||||
new Language(tr("Marathi"), "मराठी", "mr"),
|
||||
new Language(tr("Nepali"), "नेपाली", "ne"),
|
||||
new Language(tr("Persian (Iran)"), "فارسی (Iran)", "fa_IR"),
|
||||
new Language(tr("Talossan"), "Talossan", "tzl"),
|
||||
new Language(tr("Western Frisian"), "Western Frisian", "fy")
|
||||
};
|
||||
|
||||
this.warningItems = new WarningItem[]{
|
||||
new WarningItem("none", _("None")),
|
||||
new WarningItem("default", _("Default")),
|
||||
new WarningItem("more", _("More")),
|
||||
new WarningItem("all", _("All"))
|
||||
new WarningItem("none", tr("None")),
|
||||
new WarningItem("default", tr("Default")),
|
||||
new WarningItem("more", tr("More")),
|
||||
new WarningItem("all", tr("All"))
|
||||
};
|
||||
|
||||
initComponents();
|
||||
@ -203,6 +192,11 @@ public class Preferences extends javax.swing.JDialog {
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
|
||||
proxyTypeButtonGroup = new javax.swing.ButtonGroup();
|
||||
manualProxyTypeButtonGroup = new javax.swing.ButtonGroup();
|
||||
javax.swing.JPanel jPanel2 = new javax.swing.JPanel();
|
||||
javax.swing.JTabbedPane jTabbedPane1 = new javax.swing.JTabbedPane();
|
||||
javax.swing.JPanel jPanel1 = new javax.swing.JPanel();
|
||||
javax.swing.JLabel sketchbookLocationLabel = new javax.swing.JLabel();
|
||||
sketchbookLocationField = new javax.swing.JTextField();
|
||||
javax.swing.JButton browseButton = new javax.swing.JButton();
|
||||
@ -222,8 +216,6 @@ public class Preferences extends javax.swing.JDialog {
|
||||
javax.swing.JLabel morePreferencesLabel = new javax.swing.JLabel();
|
||||
preferencesFileLabel = new javax.swing.JLabel();
|
||||
javax.swing.JLabel arduinoNotRunningLabel = new javax.swing.JLabel();
|
||||
javax.swing.JButton okButton = new javax.swing.JButton();
|
||||
javax.swing.JButton cancelButton = new javax.swing.JButton();
|
||||
javax.swing.JPanel checkboxesContainer = new javax.swing.JPanel();
|
||||
displayLineNumbersBox = new javax.swing.JCheckBox();
|
||||
enableCodeFoldingBox = new javax.swing.JCheckBox();
|
||||
@ -232,13 +224,41 @@ public class Preferences extends javax.swing.JDialog {
|
||||
checkUpdatesBox = new javax.swing.JCheckBox();
|
||||
updateExtensionBox = new javax.swing.JCheckBox();
|
||||
saveVerifyUploadBox = new javax.swing.JCheckBox();
|
||||
javax.swing.JPanel jPanel4 = new javax.swing.JPanel();
|
||||
noProxy = new javax.swing.JRadioButton();
|
||||
autoProxy = new javax.swing.JRadioButton();
|
||||
manualProxy = new javax.swing.JRadioButton();
|
||||
autoProxyUsePAC = new javax.swing.JCheckBox();
|
||||
autoProxyPACURL = new javax.swing.JTextField();
|
||||
manualProxyHTTP = new javax.swing.JRadioButton();
|
||||
manualProxySOCKS = new javax.swing.JRadioButton();
|
||||
manualProxyHostNameLabel = new javax.swing.JLabel();
|
||||
manualProxyPortLabel = new javax.swing.JLabel();
|
||||
manualProxyHostName = new javax.swing.JTextField();
|
||||
manualProxyPort = new javax.swing.JTextField();
|
||||
manualProxyUsernameLabel = new javax.swing.JLabel();
|
||||
manualProxyUsername = new javax.swing.JTextField();
|
||||
manualProxyPasswordLabel = new javax.swing.JLabel();
|
||||
manualProxyPassword = new javax.swing.JPasswordField();
|
||||
autoProxyUsernameLabel = new javax.swing.JLabel();
|
||||
autoProxyUsername = new javax.swing.JTextField();
|
||||
autoProxyPassword = new javax.swing.JPasswordField();
|
||||
autoProxyPasswordLabel = new javax.swing.JLabel();
|
||||
javax.swing.JPanel jPanel3 = new javax.swing.JPanel();
|
||||
javax.swing.JButton okButton = new javax.swing.JButton();
|
||||
javax.swing.JButton cancelButton = new javax.swing.JButton();
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
||||
setTitle(_("Preferences"));
|
||||
setTitle(tr("Preferences"));
|
||||
setModal(true);
|
||||
setResizable(false);
|
||||
|
||||
sketchbookLocationLabel.setText(_("Sketchbook location:"));
|
||||
jPanel2.setLayout(new javax.swing.BoxLayout(jPanel2, javax.swing.BoxLayout.Y_AXIS));
|
||||
|
||||
jTabbedPane1.setFocusable(false);
|
||||
jTabbedPane1.setRequestFocusEnabled(false);
|
||||
|
||||
sketchbookLocationLabel.setText(tr("Sketchbook location:"));
|
||||
|
||||
sketchbookLocationField.setColumns(40);
|
||||
|
||||
@ -249,26 +269,26 @@ public class Preferences extends javax.swing.JDialog {
|
||||
}
|
||||
});
|
||||
|
||||
comboLanguageLabel.setText(_("Editor language: "));
|
||||
comboLanguageLabel.setText(tr("Editor language: "));
|
||||
|
||||
requiresRestartLabel.setText(_(" (requires restart of Arduino)"));
|
||||
requiresRestartLabel.setText(tr(" (requires restart of Arduino)"));
|
||||
|
||||
fontSizeLabel.setText(_("Editor font size: "));
|
||||
fontSizeLabel.setText(tr("Editor font size: "));
|
||||
|
||||
fontSizeField.setColumns(4);
|
||||
|
||||
showVerboseLabel.setText(_("Show verbose output during: "));
|
||||
showVerboseLabel.setText(tr("Show verbose output during: "));
|
||||
|
||||
verboseCompilationBox.setText(_("compilation "));
|
||||
verboseCompilationBox.setText(tr("compilation "));
|
||||
|
||||
verboseUploadBox.setText(_("upload"));
|
||||
verboseUploadBox.setText(tr("upload"));
|
||||
|
||||
comboWarningsLabel.setText(_("Compiler warnings: "));
|
||||
comboWarningsLabel.setText(tr("Compiler warnings: "));
|
||||
|
||||
additionalBoardsManagerLabel.setText(_("Additional Boards Manager URLs: "));
|
||||
additionalBoardsManagerLabel.setToolTipText(_("Enter a comma separated list of urls"));
|
||||
additionalBoardsManagerLabel.setText(tr("Additional Boards Manager URLs: "));
|
||||
additionalBoardsManagerLabel.setToolTipText(tr("Enter a comma separated list of urls"));
|
||||
|
||||
additionalBoardsManagerField.setToolTipText(_("Enter a comma separated list of urls"));
|
||||
additionalBoardsManagerField.setToolTipText(tr("Enter a comma separated list of urls"));
|
||||
|
||||
extendedAdditionalUrlFieldWindow.setIcon(new ImageIcon(Base.getThemeImage("newwindow.gif", this)));
|
||||
extendedAdditionalUrlFieldWindow.setMargin(new java.awt.Insets(1, 1, 1, 1));
|
||||
@ -279,7 +299,7 @@ public class Preferences extends javax.swing.JDialog {
|
||||
});
|
||||
|
||||
morePreferencesLabel.setForeground(Color.GRAY);
|
||||
morePreferencesLabel.setText(_("More preferences can be edited directly in the file"));
|
||||
morePreferencesLabel.setText(tr("More preferences can be edited directly in the file"));
|
||||
|
||||
preferencesFileLabel.setText(PreferencesData.getPreferencesFile().getAbsolutePath());
|
||||
preferencesFileLabel.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
|
||||
@ -298,7 +318,277 @@ public class Preferences extends javax.swing.JDialog {
|
||||
});
|
||||
|
||||
arduinoNotRunningLabel.setForeground(Color.GRAY);
|
||||
arduinoNotRunningLabel.setText(_("(edit only when Arduino is not running)"));
|
||||
arduinoNotRunningLabel.setText(tr("(edit only when Arduino is not running)"));
|
||||
|
||||
checkboxesContainer.setLayout(new javax.swing.BoxLayout(checkboxesContainer, javax.swing.BoxLayout.Y_AXIS));
|
||||
|
||||
displayLineNumbersBox.setText(tr("Display line numbers"));
|
||||
checkboxesContainer.add(displayLineNumbersBox);
|
||||
|
||||
enableCodeFoldingBox.setText(tr("Enable Code Folding"));
|
||||
checkboxesContainer.add(enableCodeFoldingBox);
|
||||
|
||||
verifyUploadBox.setText(tr("Verify code after upload"));
|
||||
checkboxesContainer.add(verifyUploadBox);
|
||||
|
||||
externalEditorBox.setText(tr("Use external editor"));
|
||||
checkboxesContainer.add(externalEditorBox);
|
||||
|
||||
checkUpdatesBox.setText(tr("Check for updates on startup"));
|
||||
checkboxesContainer.add(checkUpdatesBox);
|
||||
|
||||
updateExtensionBox.setText(tr("Update sketch files to new extension on save (.pde -> .ino)"));
|
||||
checkboxesContainer.add(updateExtensionBox);
|
||||
|
||||
saveVerifyUploadBox.setText(tr("Save when verifying or uploading"));
|
||||
checkboxesContainer.add(saveVerifyUploadBox);
|
||||
|
||||
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
|
||||
jPanel1.setLayout(jPanel1Layout);
|
||||
jPanel1Layout.setHorizontalGroup(
|
||||
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addComponent(sketchbookLocationField)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(browseButton))
|
||||
.addComponent(checkboxesContainer, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addComponent(comboWarningsLabel)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(comboWarnings, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addComponent(showVerboseLabel)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(verboseCompilationBox)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(verboseUploadBox))
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(comboLanguageLabel)
|
||||
.addComponent(fontSizeLabel))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(fontSizeField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addComponent(comboLanguage, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(requiresRestartLabel))))
|
||||
.addComponent(arduinoNotRunningLabel)
|
||||
.addComponent(morePreferencesLabel)
|
||||
.addComponent(preferencesFileLabel)
|
||||
.addComponent(sketchbookLocationLabel)
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addComponent(additionalBoardsManagerLabel)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(additionalBoardsManagerField, javax.swing.GroupLayout.PREFERRED_SIZE, 500, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(extendedAdditionalUrlFieldWindow)))
|
||||
.addGap(0, 0, Short.MAX_VALUE)))
|
||||
.addContainerGap())
|
||||
);
|
||||
jPanel1Layout.setVerticalGroup(
|
||||
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(sketchbookLocationLabel)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(sketchbookLocationField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(browseButton))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(comboLanguageLabel)
|
||||
.addComponent(comboLanguage, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(requiresRestartLabel))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(fontSizeLabel)
|
||||
.addComponent(fontSizeField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(showVerboseLabel)
|
||||
.addComponent(verboseCompilationBox)
|
||||
.addComponent(verboseUploadBox))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(comboWarningsLabel)
|
||||
.addComponent(comboWarnings, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(checkboxesContainer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(additionalBoardsManagerLabel)
|
||||
.addComponent(additionalBoardsManagerField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addComponent(extendedAdditionalUrlFieldWindow))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(morePreferencesLabel)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(preferencesFileLabel)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(arduinoNotRunningLabel)
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
jTabbedPane1.addTab(tr("Settings"), jPanel1);
|
||||
|
||||
proxyTypeButtonGroup.add(noProxy);
|
||||
noProxy.setText(tr("No proxy"));
|
||||
noProxy.setActionCommand(Constants.PROXY_TYPE_NONE);
|
||||
|
||||
proxyTypeButtonGroup.add(autoProxy);
|
||||
autoProxy.setText(tr("Auto-detect proxy settings"));
|
||||
autoProxy.setActionCommand(Constants.PROXY_TYPE_AUTO);
|
||||
autoProxy.addItemListener(new java.awt.event.ItemListener() {
|
||||
public void itemStateChanged(java.awt.event.ItemEvent evt) {
|
||||
autoProxyItemStateChanged(evt);
|
||||
}
|
||||
});
|
||||
|
||||
proxyTypeButtonGroup.add(manualProxy);
|
||||
manualProxy.setText(tr("Manual proxy configuration"));
|
||||
manualProxy.setActionCommand(Constants.PROXY_TYPE_MANUAL);
|
||||
manualProxy.addItemListener(new java.awt.event.ItemListener() {
|
||||
public void itemStateChanged(java.awt.event.ItemEvent evt) {
|
||||
manualProxyItemStateChanged(evt);
|
||||
}
|
||||
});
|
||||
|
||||
autoProxyUsePAC.setText(tr("Automatic proxy configuration URL:"));
|
||||
autoProxyUsePAC.addItemListener(new java.awt.event.ItemListener() {
|
||||
public void itemStateChanged(java.awt.event.ItemEvent evt) {
|
||||
autoProxyUsePACItemStateChanged(evt);
|
||||
}
|
||||
});
|
||||
|
||||
manualProxyTypeButtonGroup.add(manualProxyHTTP);
|
||||
manualProxyHTTP.setText("HTTP");
|
||||
manualProxyHTTP.setActionCommand(Constants.PROXY_MANUAL_TYPE_HTTP);
|
||||
|
||||
manualProxyTypeButtonGroup.add(manualProxySOCKS);
|
||||
manualProxySOCKS.setText("SOCKS");
|
||||
manualProxySOCKS.setActionCommand(Constants.PROXY_MANUAL_TYPE_SOCKS);
|
||||
|
||||
manualProxyHostNameLabel.setText(tr("Host name:"));
|
||||
|
||||
manualProxyPortLabel.setText(tr("Port number:"));
|
||||
|
||||
manualProxyUsernameLabel.setText(tr("Username:"));
|
||||
|
||||
manualProxyPasswordLabel.setText(tr("Password:"));
|
||||
|
||||
manualProxyPassword.setToolTipText("");
|
||||
|
||||
autoProxyUsernameLabel.setText(tr("Username:"));
|
||||
|
||||
autoProxyPassword.setToolTipText("");
|
||||
|
||||
autoProxyPasswordLabel.setText(tr("Password:"));
|
||||
|
||||
javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
|
||||
jPanel4.setLayout(jPanel4Layout);
|
||||
jPanel4Layout.setHorizontalGroup(
|
||||
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanel4Layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanel4Layout.createSequentialGroup()
|
||||
.addGap(12, 12, 12)
|
||||
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(autoProxyUsePAC)
|
||||
.addGroup(jPanel4Layout.createSequentialGroup()
|
||||
.addGap(12, 12, 12)
|
||||
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(autoProxyUsernameLabel)
|
||||
.addComponent(autoProxyPasswordLabel))))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(autoProxyPACURL)
|
||||
.addGroup(jPanel4Layout.createSequentialGroup()
|
||||
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(autoProxyUsername, javax.swing.GroupLayout.PREFERRED_SIZE, 178, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(autoProxyPassword, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGap(0, 0, Short.MAX_VALUE))))
|
||||
.addGroup(jPanel4Layout.createSequentialGroup()
|
||||
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(noProxy)
|
||||
.addComponent(autoProxy)
|
||||
.addComponent(manualProxy)
|
||||
.addGroup(jPanel4Layout.createSequentialGroup()
|
||||
.addGap(12, 12, 12)
|
||||
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanel4Layout.createSequentialGroup()
|
||||
.addComponent(manualProxyHTTP)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(manualProxySOCKS))
|
||||
.addGroup(jPanel4Layout.createSequentialGroup()
|
||||
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(manualProxyHostNameLabel)
|
||||
.addComponent(manualProxyPortLabel)
|
||||
.addComponent(manualProxyUsernameLabel)
|
||||
.addComponent(manualProxyPasswordLabel))
|
||||
.addGap(18, 18, 18)
|
||||
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(manualProxyHostName, javax.swing.GroupLayout.PREFERRED_SIZE, 541, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(manualProxyPort, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
|
||||
.addComponent(manualProxyPassword, javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(manualProxyUsername, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE)))))))
|
||||
.addGap(0, 0, Short.MAX_VALUE)))
|
||||
.addContainerGap())
|
||||
);
|
||||
jPanel4Layout.setVerticalGroup(
|
||||
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanel4Layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(noProxy)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(autoProxy)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(autoProxyUsePAC)
|
||||
.addComponent(autoProxyPACURL, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(autoProxyUsername, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(autoProxyUsernameLabel))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(autoProxyPasswordLabel)
|
||||
.addComponent(autoProxyPassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(manualProxy)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(manualProxyHTTP)
|
||||
.addComponent(manualProxySOCKS))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(manualProxyHostNameLabel)
|
||||
.addComponent(manualProxyHostName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(manualProxyPort, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(manualProxyPortLabel))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(manualProxyUsername, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(manualProxyUsernameLabel))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(manualProxyPassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(manualProxyPasswordLabel))
|
||||
.addContainerGap(163, Short.MAX_VALUE))
|
||||
);
|
||||
|
||||
jTabbedPane1.addTab(tr("Network"), jPanel4);
|
||||
|
||||
jPanel2.add(jTabbedPane1);
|
||||
|
||||
okButton.setText(I18n.PROMPT_OK);
|
||||
okButton.addActionListener(new java.awt.event.ActionListener() {
|
||||
@ -314,127 +604,42 @@ public class Preferences extends javax.swing.JDialog {
|
||||
}
|
||||
});
|
||||
|
||||
checkboxesContainer.setLayout(new javax.swing.BoxLayout(checkboxesContainer, javax.swing.BoxLayout.Y_AXIS));
|
||||
javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
|
||||
jPanel3.setLayout(jPanel3Layout);
|
||||
jPanel3Layout.setHorizontalGroup(
|
||||
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
|
||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(okButton)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(cancelButton)
|
||||
.addContainerGap())
|
||||
);
|
||||
jPanel3Layout.setVerticalGroup(
|
||||
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
|
||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(okButton)
|
||||
.addComponent(cancelButton))
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
displayLineNumbersBox.setText(_("Display line numbers"));
|
||||
checkboxesContainer.add(displayLineNumbersBox);
|
||||
|
||||
enableCodeFoldingBox.setText(_("Enable Code Folding"));
|
||||
checkboxesContainer.add(enableCodeFoldingBox);
|
||||
|
||||
verifyUploadBox.setText(_("Verify code after upload"));
|
||||
checkboxesContainer.add(verifyUploadBox);
|
||||
|
||||
externalEditorBox.setText(_("Use external editor"));
|
||||
checkboxesContainer.add(externalEditorBox);
|
||||
|
||||
checkUpdatesBox.setText(_("Check for updates on startup"));
|
||||
checkboxesContainer.add(checkUpdatesBox);
|
||||
|
||||
updateExtensionBox.setText(_("Update sketch files to new extension on save (.pde -> .ino)"));
|
||||
checkboxesContainer.add(updateExtensionBox);
|
||||
|
||||
saveVerifyUploadBox.setText(_("Save when verifying or uploading"));
|
||||
checkboxesContainer.add(saveVerifyUploadBox);
|
||||
jPanel2.add(jPanel3);
|
||||
|
||||
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)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(sketchbookLocationField)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(browseButton))
|
||||
.addComponent(checkboxesContainer, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addComponent(okButton)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(cancelButton))
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addComponent(additionalBoardsManagerLabel)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(additionalBoardsManagerField, javax.swing.GroupLayout.PREFERRED_SIZE, 500, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(extendedAdditionalUrlFieldWindow))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(sketchbookLocationLabel)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(comboWarningsLabel)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(comboWarnings, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(showVerboseLabel)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(verboseCompilationBox)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(verboseUploadBox))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(comboLanguageLabel)
|
||||
.addComponent(fontSizeLabel))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(fontSizeField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(comboLanguage, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(requiresRestartLabel))))
|
||||
.addComponent(arduinoNotRunningLabel)
|
||||
.addComponent(morePreferencesLabel)
|
||||
.addComponent(preferencesFileLabel))
|
||||
.addGap(0, 0, Short.MAX_VALUE)))
|
||||
.addContainerGap())
|
||||
.addGap(0, 691, Short.MAX_VALUE)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(sketchbookLocationLabel)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(sketchbookLocationField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(browseButton))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(comboLanguageLabel)
|
||||
.addComponent(comboLanguage, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(requiresRestartLabel))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(fontSizeLabel)
|
||||
.addComponent(fontSizeField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(showVerboseLabel)
|
||||
.addComponent(verboseCompilationBox)
|
||||
.addComponent(verboseUploadBox))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(comboWarningsLabel)
|
||||
.addComponent(comboWarnings, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(checkboxesContainer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(additionalBoardsManagerLabel)
|
||||
.addComponent(additionalBoardsManagerField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addComponent(extendedAdditionalUrlFieldWindow))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(morePreferencesLabel)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(preferencesFileLabel)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(arduinoNotRunningLabel)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(cancelButton)
|
||||
.addComponent(okButton))
|
||||
.addContainerGap())
|
||||
.addGap(0, 610, Short.MAX_VALUE)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
);
|
||||
|
||||
pack();
|
||||
@ -442,7 +647,7 @@ public class Preferences extends javax.swing.JDialog {
|
||||
|
||||
private void browseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseButtonActionPerformed
|
||||
File dflt = new File(sketchbookLocationField.getText());
|
||||
File file = Base.selectFolder(_("Select new sketchbook location"), dflt, this);
|
||||
File file = Base.selectFolder(tr("Select new sketchbook location"), dflt, this);
|
||||
if (file != null) {
|
||||
String path = file.getAbsolutePath();
|
||||
if (BaseNoGui.getPortableFolder() != null) {
|
||||
@ -481,7 +686,7 @@ public class Preferences extends javax.swing.JDialog {
|
||||
private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
|
||||
java.util.List<String> errors = validateData();
|
||||
if (!errors.isEmpty()) {
|
||||
Base.showWarning(_("Error"), errors.get(0), null);
|
||||
Base.showWarning(tr("Error"), errors.get(0), null);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -490,8 +695,29 @@ public class Preferences extends javax.swing.JDialog {
|
||||
cancelButtonActionPerformed(evt);
|
||||
}//GEN-LAST:event_okButtonActionPerformed
|
||||
|
||||
private void autoProxyItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_autoProxyItemStateChanged
|
||||
disableAllProxyFields();
|
||||
autoProxyFieldsSetEnabled(autoProxy.isSelected());
|
||||
}//GEN-LAST:event_autoProxyItemStateChanged
|
||||
|
||||
private void manualProxyItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_manualProxyItemStateChanged
|
||||
disableAllProxyFields();
|
||||
manualProxyFieldsSetEnabled(manualProxy.isSelected());
|
||||
}//GEN-LAST:event_manualProxyItemStateChanged
|
||||
|
||||
private void autoProxyUsePACItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_autoProxyUsePACItemStateChanged
|
||||
autoProxyPACFieldsSetEnabled(autoProxyUsePAC.isSelected());
|
||||
}//GEN-LAST:event_autoProxyUsePACItemStateChanged
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JTextField additionalBoardsManagerField;
|
||||
private javax.swing.JRadioButton autoProxy;
|
||||
private javax.swing.JTextField autoProxyPACURL;
|
||||
private javax.swing.JPasswordField autoProxyPassword;
|
||||
private javax.swing.JLabel autoProxyPasswordLabel;
|
||||
private javax.swing.JCheckBox autoProxyUsePAC;
|
||||
private javax.swing.JTextField autoProxyUsername;
|
||||
private javax.swing.JLabel autoProxyUsernameLabel;
|
||||
private javax.swing.JCheckBox checkUpdatesBox;
|
||||
private javax.swing.JComboBox comboLanguage;
|
||||
private javax.swing.JComboBox comboWarnings;
|
||||
@ -499,7 +725,21 @@ public class Preferences extends javax.swing.JDialog {
|
||||
private javax.swing.JCheckBox enableCodeFoldingBox;
|
||||
private javax.swing.JCheckBox externalEditorBox;
|
||||
private javax.swing.JTextField fontSizeField;
|
||||
private javax.swing.JRadioButton manualProxy;
|
||||
private javax.swing.JRadioButton manualProxyHTTP;
|
||||
private javax.swing.JTextField manualProxyHostName;
|
||||
private javax.swing.JLabel manualProxyHostNameLabel;
|
||||
private javax.swing.JPasswordField manualProxyPassword;
|
||||
private javax.swing.JLabel manualProxyPasswordLabel;
|
||||
private javax.swing.JTextField manualProxyPort;
|
||||
private javax.swing.JLabel manualProxyPortLabel;
|
||||
private javax.swing.JRadioButton manualProxySOCKS;
|
||||
private javax.swing.ButtonGroup manualProxyTypeButtonGroup;
|
||||
private javax.swing.JTextField manualProxyUsername;
|
||||
private javax.swing.JLabel manualProxyUsernameLabel;
|
||||
private javax.swing.JRadioButton noProxy;
|
||||
private javax.swing.JLabel preferencesFileLabel;
|
||||
private javax.swing.ButtonGroup proxyTypeButtonGroup;
|
||||
private javax.swing.JCheckBox saveVerifyUploadBox;
|
||||
private javax.swing.JTextField sketchbookLocationField;
|
||||
private javax.swing.JCheckBox updateExtensionBox;
|
||||
@ -511,7 +751,7 @@ public class Preferences extends javax.swing.JDialog {
|
||||
private java.util.List<String> validateData() {
|
||||
java.util.List<String> errors = new LinkedList<>();
|
||||
if (FileUtils.isSubDirectory(new File(sketchbookLocationField.getText()), new File(PreferencesData.get("runtime.ide.path")))) {
|
||||
errors.add(_("The specified sketchbook folder contains your copy of the IDE.\nPlease choose a different folder for your sketchbook."));
|
||||
errors.add(tr("The specified sketchbook folder contains your copy of the IDE.\nPlease choose a different folder for your sketchbook."));
|
||||
}
|
||||
return errors;
|
||||
}
|
||||
@ -542,7 +782,7 @@ public class Preferences extends javax.swing.JDialog {
|
||||
PreferencesData.set("editor.font", PApplet.join(pieces, ','));
|
||||
|
||||
} catch (Exception e) {
|
||||
System.err.println(I18n.format(_("ignoring invalid font size {0}"), newSizeText));
|
||||
System.err.println(I18n.format(tr("ignoring invalid font size {0}"), newSizeText));
|
||||
}
|
||||
|
||||
// put each of the settings into the table
|
||||
@ -570,7 +810,15 @@ public class Preferences extends javax.swing.JDialog {
|
||||
|
||||
PreferencesData.set("boardsmanager.additional.urls", additionalBoardsManagerField.getText().replace("\r\n", "\n").replace("\r", "\n").replace("\n", ","));
|
||||
|
||||
//editor.applyPreferences();
|
||||
PreferencesData.set(Constants.PREF_PROXY_TYPE, proxyTypeButtonGroup.getSelection().getActionCommand());
|
||||
PreferencesData.set(Constants.PREF_PROXY_PAC_URL, autoProxyUsePAC.isSelected() ? autoProxyPACURL.getText() : "");
|
||||
PreferencesData.set(Constants.PREF_PROXY_MANUAL_TYPE, manualProxyTypeButtonGroup.getSelection().getActionCommand());
|
||||
PreferencesData.set(Constants.PREF_PROXY_MANUAL_HOSTNAME, manualProxyHostName.getText());
|
||||
PreferencesData.set(Constants.PREF_PROXY_MANUAL_PORT, manualProxyPort.getText());
|
||||
PreferencesData.set(Constants.PREF_PROXY_MANUAL_USERNAME, manualProxyUsername.getText());
|
||||
PreferencesData.set(Constants.PREF_PROXY_MANUAL_PASSWORD, String.valueOf(manualProxyPassword.getPassword()));
|
||||
PreferencesData.set(Constants.PREF_PROXY_AUTO_USERNAME, autoProxyUsername.getText());
|
||||
PreferencesData.set(Constants.PREF_PROXY_AUTO_PASSWORD, String.valueOf(autoProxyPassword.getPassword()));
|
||||
}
|
||||
|
||||
private void showPrerefencesData() {
|
||||
@ -611,5 +859,63 @@ public class Preferences extends javax.swing.JDialog {
|
||||
saveVerifyUploadBox.setSelected(PreferencesData.getBoolean("editor.save_on_verify"));
|
||||
|
||||
additionalBoardsManagerField.setText(PreferencesData.get("boardsmanager.additional.urls"));
|
||||
|
||||
disableAllProxyFields();
|
||||
String proxyType = PreferencesData.get(Constants.PREF_PROXY_TYPE, Constants.PROXY_TYPE_AUTO);
|
||||
|
||||
if (Constants.PROXY_TYPE_NONE.equals(proxyType)) {
|
||||
noProxy.setSelected(true);
|
||||
} else if (Constants.PROXY_TYPE_AUTO.equals(proxyType)) {
|
||||
autoProxy.setSelected(true);
|
||||
autoProxyFieldsSetEnabled(true);
|
||||
if (!PreferencesData.get(Constants.PREF_PROXY_PAC_URL, "").isEmpty()) {
|
||||
autoProxyUsePAC.setSelected(true);
|
||||
autoProxyPACURL.setText(PreferencesData.get(Constants.PREF_PROXY_PAC_URL));
|
||||
autoProxyUsername.setText(PreferencesData.get(Constants.PREF_PROXY_AUTO_USERNAME));
|
||||
autoProxyPassword.setText(PreferencesData.get(Constants.PREF_PROXY_AUTO_PASSWORD));
|
||||
}
|
||||
} else {
|
||||
manualProxy.setSelected(true);
|
||||
manualProxyFieldsSetEnabled(true);
|
||||
manualProxyHostName.setText(PreferencesData.get(Constants.PREF_PROXY_MANUAL_HOSTNAME));
|
||||
manualProxyPort.setText(PreferencesData.get(Constants.PREF_PROXY_MANUAL_PORT));
|
||||
manualProxyUsername.setText(PreferencesData.get(Constants.PREF_PROXY_MANUAL_USERNAME));
|
||||
manualProxyPassword.setText(PreferencesData.get(Constants.PREF_PROXY_MANUAL_PASSWORD));
|
||||
}
|
||||
|
||||
String selectedManualProxyType = PreferencesData.get(Constants.PREF_PROXY_MANUAL_TYPE, Constants.PROXY_MANUAL_TYPE_HTTP);
|
||||
manualProxyHTTP.setSelected(Constants.PROXY_MANUAL_TYPE_HTTP.equals(selectedManualProxyType));
|
||||
manualProxySOCKS.setSelected(Constants.PROXY_MANUAL_TYPE_SOCKS.equals(selectedManualProxyType));
|
||||
}
|
||||
|
||||
private void manualProxyFieldsSetEnabled(boolean enabled) {
|
||||
manualProxySOCKS.setEnabled(enabled);
|
||||
manualProxyHTTP.setEnabled(enabled);
|
||||
manualProxyHostNameLabel.setEnabled(enabled);
|
||||
manualProxyHostName.setEnabled(enabled);
|
||||
manualProxyPortLabel.setEnabled(enabled);
|
||||
manualProxyPort.setEnabled(enabled);
|
||||
manualProxyUsernameLabel.setEnabled(enabled);
|
||||
manualProxyUsername.setEnabled(enabled);
|
||||
manualProxyPasswordLabel.setEnabled(enabled);
|
||||
manualProxyPassword.setEnabled(enabled);
|
||||
}
|
||||
|
||||
private void autoProxyFieldsSetEnabled(boolean enabled) {
|
||||
autoProxyUsePAC.setEnabled(enabled);
|
||||
autoProxyPACFieldsSetEnabled(enabled && autoProxyUsePAC.isSelected());
|
||||
}
|
||||
|
||||
private void autoProxyPACFieldsSetEnabled(boolean enabled) {
|
||||
autoProxyPACURL.setEnabled(enabled);
|
||||
autoProxyUsername.setEnabled(enabled);
|
||||
autoProxyUsernameLabel.setEnabled(enabled);
|
||||
autoProxyPassword.setEnabled(enabled);
|
||||
autoProxyPasswordLabel.setEnabled(enabled);
|
||||
}
|
||||
|
||||
private void disableAllProxyFields() {
|
||||
autoProxyFieldsSetEnabled(false);
|
||||
manualProxyFieldsSetEnabled(false);
|
||||
}
|
||||
}
|
||||
|
@ -1,35 +1,15 @@
|
||||
package processing.app;
|
||||
|
||||
import static processing.app.I18n._;
|
||||
import cc.arduino.packages.BoardPort;
|
||||
import processing.app.legacy.PApplet;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Container;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Toolkit;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.Box;
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.KeyStroke;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.Timer;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.text.DefaultCaret;
|
||||
|
||||
import cc.arduino.packages.BoardPort;
|
||||
import processing.app.debug.TextAreaFIFO;
|
||||
import processing.app.legacy.PApplet;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public abstract class AbstractMonitor extends JFrame implements ActionListener {
|
||||
|
||||
@ -40,7 +20,7 @@ public abstract class AbstractMonitor extends JFrame implements ActionListener {
|
||||
private Timer updateTimer;
|
||||
|
||||
private BoardPort boardPort;
|
||||
|
||||
|
||||
protected String[] serialRateStrings = {"300", "1200", "2400", "4800", "9600", "19200", "38400", "57600", "74880", "115200", "230400", "250000"};
|
||||
|
||||
public AbstractMonitor(BoardPort boardPort) {
|
||||
@ -101,14 +81,14 @@ public abstract class AbstractMonitor extends JFrame implements ActionListener {
|
||||
monitorEnabled = true;
|
||||
closed = false;
|
||||
}
|
||||
|
||||
|
||||
protected abstract void onCreateWindow(Container mainPane);
|
||||
|
||||
public void enableWindow(boolean enable) {
|
||||
onEnableWindow(enable);
|
||||
monitorEnabled = enable;
|
||||
}
|
||||
|
||||
|
||||
protected abstract void onEnableWindow(boolean enable);
|
||||
|
||||
// Puts the window in suspend state, closing the serial port
|
||||
@ -177,6 +157,9 @@ public abstract class AbstractMonitor extends JFrame implements ActionListener {
|
||||
}
|
||||
|
||||
public void setBoardPort(BoardPort boardPort) {
|
||||
if (boardPort == null) {
|
||||
return;
|
||||
}
|
||||
setTitle(boardPort.getLabel());
|
||||
this.boardPort = boardPort;
|
||||
}
|
||||
@ -190,7 +173,7 @@ public abstract class AbstractMonitor extends JFrame implements ActionListener {
|
||||
updateBuffer.setLength(0);
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
String s = consumeUpdateBuffer();
|
||||
if (s.isEmpty()) {
|
||||
|
@ -1,38 +1,28 @@
|
||||
package processing.app;
|
||||
|
||||
import static processing.app.I18n._;
|
||||
import static processing.app.I18n.tr;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Container;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.Box;
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.KeyStroke;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.text.DefaultCaret;
|
||||
|
||||
import cc.arduino.packages.BoardPort;
|
||||
import processing.app.debug.TextAreaFIFO;
|
||||
import processing.app.legacy.PApplet;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public abstract class AbstractTextMonitor extends AbstractMonitor {
|
||||
@ -76,7 +66,7 @@ public abstract class AbstractTextMonitor extends AbstractMonitor {
|
||||
upperPane.setBorder(new EmptyBorder(4, 4, 4, 4));
|
||||
|
||||
textField = new JTextField(40);
|
||||
sendButton = new JButton(_("Send"));
|
||||
sendButton = new JButton(tr("Send"));
|
||||
|
||||
upperPane.add(textField);
|
||||
upperPane.add(Box.createRigidArea(new Dimension(4, 0)));
|
||||
@ -88,16 +78,16 @@ public abstract class AbstractTextMonitor extends AbstractMonitor {
|
||||
pane.setLayout(new BoxLayout(pane, BoxLayout.X_AXIS));
|
||||
pane.setBorder(new EmptyBorder(4, 4, 4, 4));
|
||||
|
||||
autoscrollBox = new JCheckBox(_("Autoscroll"), true);
|
||||
autoscrollBox = new JCheckBox(tr("Autoscroll"), true);
|
||||
|
||||
noLineEndingAlert = new JLabel(I18n.format(_("You've pressed {0} but nothing was sent. Should you select a line ending?"), _("Send")));
|
||||
noLineEndingAlert = new JLabel(I18n.format(tr("You've pressed {0} but nothing was sent. Should you select a line ending?"), tr("Send")));
|
||||
noLineEndingAlert.setToolTipText(noLineEndingAlert.getText());
|
||||
noLineEndingAlert.setForeground(pane.getBackground());
|
||||
Dimension minimumSize = new Dimension(noLineEndingAlert.getMinimumSize());
|
||||
minimumSize.setSize(minimumSize.getWidth() / 3, minimumSize.getHeight());
|
||||
noLineEndingAlert.setMinimumSize(minimumSize);
|
||||
|
||||
lineEndings = new JComboBox(new String[]{_("No line ending"), _("Newline"), _("Carriage return"), _("Both NL & CR")});
|
||||
lineEndings = new JComboBox(new String[]{tr("No line ending"), tr("Newline"), tr("Carriage return"), tr("Both NL & CR")});
|
||||
lineEndings.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
PreferencesData.setInteger("serial.line_ending", lineEndings.getSelectedIndex());
|
||||
@ -111,7 +101,7 @@ public abstract class AbstractTextMonitor extends AbstractMonitor {
|
||||
|
||||
serialRates = new JComboBox();
|
||||
for (String rate : serialRateStrings) {
|
||||
serialRates.addItem(rate + " " + _("baud"));
|
||||
serialRates.addItem(rate + " " + tr("baud"));
|
||||
}
|
||||
|
||||
serialRates.setMaximumSize(serialRates.getMinimumSize());
|
||||
@ -157,4 +147,4 @@ public abstract class AbstractTextMonitor extends AbstractMonitor {
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,10 +22,9 @@
|
||||
|
||||
package processing.app;
|
||||
|
||||
import cc.arduino.contributions.BuiltInCoreIsNewerCheck;
|
||||
import cc.arduino.contributions.DownloadableContributionVersionComparator;
|
||||
import cc.arduino.contributions.GPGDetachedSignatureVerifier;
|
||||
import cc.arduino.contributions.VersionHelper;
|
||||
import cc.arduino.Constants;
|
||||
import cc.arduino.UpdatableBoardsLibsFakeURLsHandler;
|
||||
import cc.arduino.contributions.*;
|
||||
import cc.arduino.contributions.libraries.*;
|
||||
import cc.arduino.contributions.libraries.ui.LibraryManagerUI;
|
||||
import cc.arduino.contributions.packages.ContributedPlatform;
|
||||
@ -34,13 +33,9 @@ import cc.arduino.contributions.packages.ContributionsIndexer;
|
||||
import cc.arduino.contributions.packages.ui.ContributionManagerUI;
|
||||
import cc.arduino.files.DeleteFilesOnShutdown;
|
||||
import cc.arduino.packages.DiscoveryManager;
|
||||
import cc.arduino.utils.Progress;
|
||||
import cc.arduino.view.Event;
|
||||
import cc.arduino.view.JMenuUtils;
|
||||
import cc.arduino.view.SplashScreenHelper;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Predicates;
|
||||
import com.google.common.collect.Collections2;
|
||||
import org.apache.commons.compress.utils.IOUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import processing.app.debug.TargetBoard;
|
||||
@ -65,11 +60,14 @@ import java.awt.event.*;
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.Timer;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.logging.Handler;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static processing.app.I18n._;
|
||||
import static processing.app.I18n.tr;
|
||||
|
||||
|
||||
/**
|
||||
@ -80,12 +78,8 @@ import static processing.app.I18n._;
|
||||
*/
|
||||
public class Base {
|
||||
|
||||
public static final Predicate<UserLibrary> CONTRIBUTED = new Predicate<UserLibrary>() {
|
||||
@Override
|
||||
public boolean apply(UserLibrary library) {
|
||||
return library.getTypes() == null || library.getTypes().isEmpty() || library.getTypes().contains("Contributed");
|
||||
}
|
||||
};
|
||||
public static final Predicate<UserLibrary> CONTRIBUTED = library -> library.getTypes() == null || library.getTypes().isEmpty() || library.getTypes().contains("Contributed");
|
||||
public static final Predicate<UserLibrary> RETIRED = library -> library.getTypes() != null && library.getTypes().contains("Retired");
|
||||
|
||||
private static final int RECENT_SKETCHES_MAX_SIZE = 5;
|
||||
|
||||
@ -94,6 +88,9 @@ public class Base {
|
||||
|
||||
public static SplashScreenHelper splashScreenHelper = new SplashScreenHelper(SplashScreen.getSplashScreen());
|
||||
public static Map<String, Object> FIND_DIALOG_STATE = new HashMap<String, Object>();
|
||||
private final ContributionInstaller contributionInstaller;
|
||||
private final LibraryInstaller libraryInstaller;
|
||||
private ContributionsSelfCheck contributionsSelfCheck;
|
||||
|
||||
// set to true after the first time the menu is built.
|
||||
// so that the errors while building don't show up again.
|
||||
@ -118,10 +115,9 @@ public class Base {
|
||||
// are the same for all windows (since the board and serial port that are
|
||||
// actually used are determined by the preferences, which are shared)
|
||||
private List<JMenu> boardsCustomMenus;
|
||||
private volatile Action openBoardsManager;
|
||||
private List<JMenuItem> programmerMenus;
|
||||
|
||||
private final PdeKeywords pdeKeywords;
|
||||
private PdeKeywords pdeKeywords;
|
||||
private final List<JMenuItem> recentSketchesMenuItems;
|
||||
|
||||
static public void main(String args[]) throws Exception {
|
||||
@ -129,7 +125,7 @@ public class Base {
|
||||
System.setProperty("swing.aatext", "true");
|
||||
System.setProperty("java.net.useSystemProxies", "true");
|
||||
|
||||
splashScreenHelper.splashText(_("Loading configuration..."));
|
||||
splashScreenHelper.splashText(tr("Loading configuration..."));
|
||||
|
||||
if (OSUtils.isMacOS()) {
|
||||
ThinkDifferent.init();
|
||||
@ -213,16 +209,11 @@ public class Base {
|
||||
try {
|
||||
BaseNoGui.getPlatform().setLookAndFeel();
|
||||
} catch (Exception e) {
|
||||
String mess = e.getMessage();
|
||||
if (mess.indexOf("ch.randelshofer.quaqua.QuaquaLookAndFeel") == -1) {
|
||||
System.err.println(_("Non-fatal error while setting the Look & Feel."));
|
||||
System.err.println(_("The error message follows, however Arduino should run fine."));
|
||||
System.err.println(mess);
|
||||
}
|
||||
// ignore
|
||||
}
|
||||
|
||||
// Create a location for untitled sketches
|
||||
untitledFolder = BaseNoGui.createTempFolder("untitled");
|
||||
untitledFolder = FileUtils.createTempFolder("untitled" + new Random().nextInt(Integer.MAX_VALUE), ".tmp");
|
||||
DeleteFilesOnShutdown.add(untitledFolder);
|
||||
|
||||
INSTANCE = new Base(args);
|
||||
@ -297,9 +288,9 @@ public class Base {
|
||||
}
|
||||
}
|
||||
|
||||
splashScreenHelper.splashText(_("Initializing packages..."));
|
||||
splashScreenHelper.splashText(tr("Initializing packages..."));
|
||||
BaseNoGui.initPackages();
|
||||
splashScreenHelper.splashText(_("Preparing boards..."));
|
||||
splashScreenHelper.splashText(tr("Preparing boards..."));
|
||||
rebuildBoardsMenu();
|
||||
rebuildProgrammerMenu();
|
||||
|
||||
@ -309,6 +300,9 @@ public class Base {
|
||||
this.pdeKeywords = new PdeKeywords();
|
||||
this.pdeKeywords.reload();
|
||||
|
||||
contributionInstaller = new ContributionInstaller(BaseNoGui.indexer, BaseNoGui.getPlatform(), new GPGDetachedSignatureVerifier());
|
||||
libraryInstaller = new LibraryInstaller(BaseNoGui.librariesIndexer, BaseNoGui.getPlatform());
|
||||
|
||||
parser.parseArgumentsPhase2();
|
||||
|
||||
for (String path : parser.getFilenames()) {
|
||||
@ -331,7 +325,7 @@ public class Base {
|
||||
if (!parser.isForceSavePrefs())
|
||||
PreferencesData.setDoSave(showEditor);
|
||||
if (handleOpen(file, nextEditorLocation(), showEditor, false) == null) {
|
||||
String mess = I18n.format(_("Failed to open sketch: \"{0}\""), path);
|
||||
String mess = I18n.format(tr("Failed to open sketch: \"{0}\""), path);
|
||||
// Open failure is fatal in upload/verify mode
|
||||
if (parser.isVerifyOrUploadMode())
|
||||
showError(null, mess, 2);
|
||||
@ -347,19 +341,10 @@ public class Base {
|
||||
|
||||
if (parser.isInstallBoard()) {
|
||||
ContributionsIndexer indexer = new ContributionsIndexer(BaseNoGui.getSettingsFolder(), BaseNoGui.getPlatform(), new GPGDetachedSignatureVerifier());
|
||||
ContributionInstaller installer = new ContributionInstaller(indexer, BaseNoGui.getPlatform(), new GPGDetachedSignatureVerifier()) {
|
||||
private String lastStatus = "";
|
||||
ProgressListener progressListener = new ConsoleProgressListener();
|
||||
|
||||
@Override
|
||||
protected void onProgress(Progress progress) {
|
||||
if (!lastStatus.equals(progress.getStatus())) {
|
||||
System.out.println(progress.getStatus());
|
||||
}
|
||||
lastStatus = progress.getStatus();
|
||||
}
|
||||
};
|
||||
List<String> downloadedPackageIndexFiles = installer.updateIndex();
|
||||
installer.deleteUnknownFiles(downloadedPackageIndexFiles);
|
||||
List<String> downloadedPackageIndexFiles = contributionInstaller.updateIndex(progressListener);
|
||||
contributionInstaller.deleteUnknownFiles(downloadedPackageIndexFiles);
|
||||
indexer.parseIndex();
|
||||
indexer.syncWithFilesystem(BaseNoGui.getHardwareFolder());
|
||||
|
||||
@ -376,40 +361,30 @@ public class Base {
|
||||
}
|
||||
}
|
||||
if (selected == null) {
|
||||
System.out.println(_("Selected board is not available"));
|
||||
System.out.println(tr("Selected board is not available"));
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
ContributedPlatform installed = indexer.getInstalled(boardToInstallParts[0], boardToInstallParts[1]);
|
||||
|
||||
if (!selected.isReadOnly()) {
|
||||
installer.install(selected);
|
||||
contributionInstaller.install(selected, progressListener);
|
||||
}
|
||||
|
||||
if (installed != null && !installed.isReadOnly()) {
|
||||
installer.remove(installed);
|
||||
contributionInstaller.remove(installed);
|
||||
}
|
||||
|
||||
System.exit(0);
|
||||
|
||||
} else if (parser.isInstallLibrary()) {
|
||||
LibrariesIndexer indexer = new LibrariesIndexer(BaseNoGui.getSettingsFolder(), new ContributionsIndexer(BaseNoGui.getSettingsFolder(), BaseNoGui.getPlatform(), new GPGDetachedSignatureVerifier()));
|
||||
LibraryInstaller installer = new LibraryInstaller(indexer, BaseNoGui.getPlatform()) {
|
||||
private String lastStatus = "";
|
||||
|
||||
@Override
|
||||
protected void onProgress(Progress progress) {
|
||||
if (!lastStatus.equals(progress.getStatus())) {
|
||||
System.out.println(progress.getStatus());
|
||||
}
|
||||
lastStatus = progress.getStatus();
|
||||
}
|
||||
};
|
||||
ProgressListener progressListener = new ConsoleProgressListener();
|
||||
indexer.parseIndex();
|
||||
BaseNoGui.onBoardOrPortChange();
|
||||
indexer.setSketchbookLibrariesFolder(BaseNoGui.getSketchbookLibrariesFolder());
|
||||
indexer.setLibrariesFolders(BaseNoGui.getLibrariesPath());
|
||||
installer.updateIndex();
|
||||
libraryInstaller.updateIndex(progressListener);
|
||||
|
||||
for (String library : parser.getLibraryToInstall().split(",")) {
|
||||
String[] libraryToInstallParts = library.split(":");
|
||||
@ -425,15 +400,15 @@ public class Base {
|
||||
}
|
||||
}
|
||||
if (selected == null) {
|
||||
System.out.println(_("Selected library is not available"));
|
||||
System.out.println(tr("Selected library is not available"));
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
ContributedLibrary installed = indexer.getIndex().getInstalled(libraryToInstallParts[0]);
|
||||
if (selected.isReadOnly()) {
|
||||
installer.remove(installed);
|
||||
libraryInstaller.remove(installed, progressListener);
|
||||
} else {
|
||||
installer.install(selected, installed);
|
||||
libraryInstaller.install(selected, installed, progressListener);
|
||||
}
|
||||
}
|
||||
|
||||
@ -453,22 +428,22 @@ public class Base {
|
||||
Editor editor = editors.get(0);
|
||||
|
||||
if (parser.isUploadMode()) {
|
||||
splashScreenHelper.splashText(_("Verifying and uploading..."));
|
||||
splashScreenHelper.splashText(tr("Verifying and uploading..."));
|
||||
editor.exportHandler.run();
|
||||
} else {
|
||||
splashScreenHelper.splashText(_("Verifying..."));
|
||||
splashScreenHelper.splashText(tr("Verifying..."));
|
||||
editor.runHandler.run();
|
||||
}
|
||||
|
||||
// Error during build or upload
|
||||
int res = editor.status.mode;
|
||||
if (res == EditorStatus.ERR)
|
||||
if (editor.status.isErr()) {
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
// No errors exit gracefully
|
||||
System.exit(0);
|
||||
} else if (parser.isGuiMode()) {
|
||||
splashScreenHelper.splashText(_("Starting..."));
|
||||
splashScreenHelper.splashText(tr("Starting..."));
|
||||
|
||||
installKeyboardInputMap();
|
||||
|
||||
@ -480,12 +455,15 @@ public class Base {
|
||||
handleNew();
|
||||
}
|
||||
|
||||
new Thread(new BuiltInCoreIsNewerCheck(this)).start();
|
||||
|
||||
// Check for updates
|
||||
if (PreferencesData.getBoolean("update.check")) {
|
||||
new UpdateCheck(this);
|
||||
}
|
||||
|
||||
new Thread(new BuiltInCoreIsNewerCheck(this)).start();
|
||||
contributionsSelfCheck = new ContributionsSelfCheck(this, new UpdatableBoardsLibsFakeURLsHandler(this), BaseNoGui.indexer, contributionInstaller, BaseNoGui.librariesIndexer, libraryInstaller);
|
||||
new Timer(false).schedule(contributionsSelfCheck, Constants.BOARDS_LIBS_UPDATABLE_CHECK_START_PERIOD);
|
||||
}
|
||||
|
||||
} else if (parser.isNoOpMode()) {
|
||||
// Do nothing (intended for only changing preferences)
|
||||
@ -701,13 +679,6 @@ public class Base {
|
||||
"jul", "aug", "sep", "oct", "nov", "dec"
|
||||
};
|
||||
|
||||
/**
|
||||
* Handle creating a sketch folder, return its base .pde file
|
||||
* or null if the operation was canceled.
|
||||
*
|
||||
* @param shift whether shift is pressed, which will invert prompt setting
|
||||
* @param noPrompt disable prompt, no matter the setting
|
||||
*/
|
||||
protected File createNewUntitled() throws IOException {
|
||||
File newbieDir = null;
|
||||
String newbieName = null;
|
||||
@ -731,13 +702,13 @@ public class Base {
|
||||
if (index == 26*26) {
|
||||
// In 0166, avoid running past zz by sending people outdoors.
|
||||
if (!breakTime) {
|
||||
showWarning(_("Time for a Break"),
|
||||
_("You've reached the limit for auto naming of new sketches\n" +
|
||||
showWarning(tr("Time for a Break"),
|
||||
tr("You've reached the limit for auto naming of new sketches\n" +
|
||||
"for the day. How about going for a walk instead?"), null);
|
||||
breakTime = true;
|
||||
} else {
|
||||
showWarning(_("Sunshine"),
|
||||
_("No really, time for some fresh air for you."), null);
|
||||
showWarning(tr("Sunshine"),
|
||||
tr("No really, time for some fresh air for you."), null);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -810,20 +781,13 @@ public class Base {
|
||||
activeEditor.handleOpenInternal(file);
|
||||
activeEditor.untitled = true;
|
||||
}
|
||||
// return true;
|
||||
|
||||
} catch (IOException e) {
|
||||
activeEditor.statusError(e);
|
||||
// return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Open a sketch, replacing the sketch in the current window.
|
||||
*
|
||||
* @param path Location of the primary pde file for the sketch.
|
||||
*/
|
||||
public void handleOpenReplace(File file) {
|
||||
if (!activeEditor.checkModified()) {
|
||||
return; // sketch was modified, and user canceled
|
||||
@ -846,7 +810,7 @@ public class Base {
|
||||
*/
|
||||
public void handleOpenPrompt() throws Exception {
|
||||
// get the frontmost window frame for placing file dialog
|
||||
FileDialog fd = new FileDialog(activeEditor, _("Open an Arduino sketch..."), FileDialog.LOAD);
|
||||
FileDialog fd = new FileDialog(activeEditor, tr("Open an Arduino sketch..."), FileDialog.LOAD);
|
||||
File lastFolder = new File(PreferencesData.get("last.folder", BaseNoGui.getSketchbookFolder().getAbsolutePath()));
|
||||
if (lastFolder.exists() && lastFolder.isFile()) {
|
||||
lastFolder = lastFolder.getParentFile();
|
||||
@ -1109,7 +1073,7 @@ public class Base {
|
||||
menu.removeAll();
|
||||
|
||||
// Add the single "Open" item
|
||||
item = Editor.newJMenuItem(_("Open..."), 'O');
|
||||
item = Editor.newJMenuItem(tr("Open..."), 'O');
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try {
|
||||
@ -1148,13 +1112,24 @@ public class Base {
|
||||
|
||||
public LibraryList getIDELibs() {
|
||||
LibraryList installedLibraries = new LibraryList(BaseNoGui.librariesIndexer.getInstalledLibraries());
|
||||
List<UserLibrary> libs = new LinkedList<UserLibrary>(Collections2.filter(new LinkedList<UserLibrary>(installedLibraries), Predicates.not(CONTRIBUTED)));
|
||||
List<UserLibrary> libs = installedLibraries.stream()
|
||||
.filter(CONTRIBUTED.negate())
|
||||
.filter(RETIRED.negate())
|
||||
.collect(Collectors.toList());
|
||||
return new LibraryList(libs);
|
||||
}
|
||||
|
||||
public LibraryList getIDERetiredLibs() {
|
||||
LibraryList installedLibraries = new LibraryList(BaseNoGui.librariesIndexer.getInstalledLibraries());
|
||||
List<UserLibrary> libs = installedLibraries.stream()
|
||||
.filter(RETIRED)
|
||||
.collect(Collectors.toList());
|
||||
return new LibraryList(libs);
|
||||
}
|
||||
|
||||
public LibraryList getUserLibs() {
|
||||
LibraryList installedLibraries = new LibraryList(BaseNoGui.librariesIndexer.getInstalledLibraries());
|
||||
List<UserLibrary> libs = new LinkedList<UserLibrary>(Collections2.filter(new LinkedList<UserLibrary>(installedLibraries), CONTRIBUTED));
|
||||
List<UserLibrary> libs = installedLibraries.stream().filter(CONTRIBUTED).collect(Collectors.toList());
|
||||
return new LibraryList(libs);
|
||||
}
|
||||
|
||||
@ -1170,16 +1145,12 @@ public class Base {
|
||||
return;
|
||||
importMenu.removeAll();
|
||||
|
||||
JMenuItem menu = new JMenuItem(_("Manage Libraries..."));
|
||||
menu.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
openManageLibrariesDialog();
|
||||
}
|
||||
});
|
||||
JMenuItem menu = new JMenuItem(tr("Manage Libraries..."));
|
||||
menu.addActionListener(e -> openLibraryManager(""));
|
||||
importMenu.add(menu);
|
||||
importMenu.addSeparator();
|
||||
|
||||
JMenuItem addLibraryMenuItem = new JMenuItem(_("Add .ZIP Library..."));
|
||||
JMenuItem addLibraryMenuItem = new JMenuItem(tr("Add .ZIP Library..."));
|
||||
addLibraryMenuItem.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Base.this.handleAddLibrary();
|
||||
@ -1203,7 +1174,7 @@ public class Base {
|
||||
importMenu.addSeparator();
|
||||
}
|
||||
lastLibType = lib.getTypes().get(0);
|
||||
JMenuItem platformItem = new JMenuItem(I18n.format(_("{0} libraries"), lastLibType));
|
||||
JMenuItem platformItem = new JMenuItem(I18n.format(tr("{0} libraries"), lastLibType));
|
||||
platformItem.setEnabled(false);
|
||||
importMenu.add(platformItem);
|
||||
}
|
||||
@ -1214,7 +1185,7 @@ public class Base {
|
||||
try {
|
||||
activeEditor.getSketch().importLibrary(l);
|
||||
} catch (IOException e) {
|
||||
showWarning(_("Error"), I18n.format("Unable to list header files in {0}", l.getSrcFolder()), e);
|
||||
showWarning(tr("Error"), I18n.format("Unable to list header files in {0}", l.getSrcFolder()), e);
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -1236,47 +1207,94 @@ public class Base {
|
||||
menu.removeAll();
|
||||
|
||||
// Add examples from distribution "example" folder
|
||||
JMenuItem label = new JMenuItem(tr("Built-in Examples"));
|
||||
label.setEnabled(false);
|
||||
menu.add(label);
|
||||
boolean found = addSketches(menu, BaseNoGui.getExamplesFolder());
|
||||
if (found) menu.addSeparator();
|
||||
if (found) {
|
||||
menu.addSeparator();
|
||||
}
|
||||
|
||||
// Add examples from libraries
|
||||
LibraryList ideLibs = getIDELibs();
|
||||
ideLibs.sort();
|
||||
for (UserLibrary lib : ideLibs)
|
||||
if (!ideLibs.isEmpty()) {
|
||||
label = new JMenuItem(tr("Examples from Libraries"));
|
||||
label.setEnabled(false);
|
||||
menu.add(label);
|
||||
}
|
||||
for (UserLibrary lib : ideLibs) {
|
||||
addSketchesSubmenu(menu, lib);
|
||||
}
|
||||
|
||||
LibraryList retiredIdeLibs = getIDERetiredLibs();
|
||||
retiredIdeLibs.sort();
|
||||
if (!retiredIdeLibs.isEmpty()) {
|
||||
JMenu retired = new JMenu(tr("RETIRED"));
|
||||
menu.add(retired);
|
||||
for (UserLibrary lib : retiredIdeLibs) {
|
||||
addSketchesSubmenu(retired, lib);
|
||||
}
|
||||
}
|
||||
|
||||
LibraryList userLibs = getUserLibs();
|
||||
if (userLibs.size() > 0) {
|
||||
menu.addSeparator();
|
||||
userLibs.sort();
|
||||
for (UserLibrary lib : userLibs)
|
||||
label = new JMenuItem(tr("Examples from Custom Libraries"));
|
||||
label.setEnabled(false);
|
||||
menu.add(label);
|
||||
for (UserLibrary lib : userLibs) {
|
||||
addSketchesSubmenu(menu, lib);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static String priorPlatformFolder;
|
||||
|
||||
public void onBoardOrPortChange() {
|
||||
BaseNoGui.onBoardOrPortChange();
|
||||
|
||||
// reload keywords when package/platform changes
|
||||
TargetPlatform tp = BaseNoGui.getTargetPlatform();
|
||||
if (tp != null) {
|
||||
String platformFolder = tp.getFolder().getAbsolutePath();
|
||||
if (priorPlatformFolder == null || !priorPlatformFolder.equals(platformFolder)) {
|
||||
pdeKeywords = new PdeKeywords();
|
||||
pdeKeywords.reload();
|
||||
priorPlatformFolder = platformFolder;
|
||||
for (Editor editor : editors) {
|
||||
editor.updateKeywords(pdeKeywords);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update editors status bar
|
||||
for (Editor editor : editors) {
|
||||
editor.onBoardOrPortChange();
|
||||
}
|
||||
}
|
||||
|
||||
private void openManageLibrariesDialog() {
|
||||
public void openLibraryManager(String dropdownItem) {
|
||||
if (contributionsSelfCheck != null) {
|
||||
contributionsSelfCheck.cancel();
|
||||
}
|
||||
@SuppressWarnings("serial")
|
||||
LibraryManagerUI managerUI = new LibraryManagerUI(activeEditor, BaseNoGui.getPlatform()) {
|
||||
LibraryManagerUI managerUI = new LibraryManagerUI(activeEditor, BaseNoGui.librariesIndexer, libraryInstaller) {
|
||||
@Override
|
||||
protected void onIndexesUpdated() throws Exception {
|
||||
BaseNoGui.initPackages();
|
||||
rebuildBoardsMenu();
|
||||
rebuildProgrammerMenu();
|
||||
onBoardOrPortChange();
|
||||
setIndexer(BaseNoGui.librariesIndexer);
|
||||
updateUI();
|
||||
if (StringUtils.isNotEmpty(dropdownItem)) {
|
||||
selectDropdownItemByClassName(dropdownItem);
|
||||
}
|
||||
}
|
||||
};
|
||||
managerUI.setLocationRelativeTo(activeEditor);
|
||||
managerUI.setIndexer(BaseNoGui.librariesIndexer);
|
||||
managerUI.updateUI();
|
||||
managerUI.setVisible(true);
|
||||
// Manager dialog is modal, waits here until closed
|
||||
|
||||
@ -1286,24 +1304,28 @@ public class Base {
|
||||
rebuildExamplesMenu(Editor.examplesMenu);
|
||||
}
|
||||
|
||||
private void openInstallBoardDialog(final String filterText) throws Exception {
|
||||
// Create dialog for contribution manager
|
||||
public void openBoardsManager(final String filterText, String dropdownItem) throws Exception {
|
||||
if (contributionsSelfCheck != null) {
|
||||
contributionsSelfCheck.cancel();
|
||||
}
|
||||
@SuppressWarnings("serial")
|
||||
ContributionManagerUI managerUI = new ContributionManagerUI(activeEditor, BaseNoGui.getPlatform()) {
|
||||
ContributionManagerUI managerUI = new ContributionManagerUI(activeEditor, BaseNoGui.indexer, contributionInstaller) {
|
||||
@Override
|
||||
protected void onIndexesUpdated() throws Exception {
|
||||
BaseNoGui.initPackages();
|
||||
rebuildBoardsMenu();
|
||||
rebuildProgrammerMenu();
|
||||
setIndexer(BaseNoGui.indexer);
|
||||
updateUI();
|
||||
if (StringUtils.isNotEmpty(dropdownItem)) {
|
||||
selectDropdownItemByClassName(dropdownItem);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(filterText)) {
|
||||
setFilterText(filterText);
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
managerUI.setLocationRelativeTo(activeEditor);
|
||||
managerUI.setIndexer(BaseNoGui.indexer);
|
||||
managerUI.updateUI();
|
||||
managerUI.setVisible(true);
|
||||
// Installer dialog is modal, waits here until closed
|
||||
|
||||
@ -1318,25 +1340,26 @@ public class Base {
|
||||
boardsCustomMenus = new LinkedList<>();
|
||||
|
||||
// The first custom menu is the "Board" selection submenu
|
||||
JMenu boardMenu = new JMenu(_("Board"));
|
||||
JMenu boardMenu = new JMenu(tr("Board"));
|
||||
boardMenu.putClientProperty("removeOnWindowDeactivation", true);
|
||||
MenuScroller.setScrollerFor(boardMenu);
|
||||
|
||||
openBoardsManager = new AbstractAction(_("Boards Manager...")) {
|
||||
boardMenu.add(new JMenuItem(new AbstractAction(tr("Boards Manager...")) {
|
||||
public void actionPerformed(ActionEvent actionevent) {
|
||||
String filterText = "";
|
||||
if (actionevent instanceof cc.arduino.view.Event) {
|
||||
String dropdownItem = "";
|
||||
if (actionevent instanceof Event) {
|
||||
filterText = ((Event) actionevent).getPayload().get("filterText").toString();
|
||||
dropdownItem = ((Event) actionevent).getPayload().get("dropdownItem").toString();
|
||||
}
|
||||
try {
|
||||
openInstallBoardDialog(filterText);
|
||||
openBoardsManager(filterText, dropdownItem);
|
||||
} catch (Exception e) {
|
||||
//TODO show error
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
};
|
||||
boardMenu.add(new JMenuItem(openBoardsManager));
|
||||
}));
|
||||
boardsCustomMenus.add(boardMenu);
|
||||
|
||||
// If there are no platforms installed we are done
|
||||
@ -1354,7 +1377,7 @@ public class Base {
|
||||
}
|
||||
}
|
||||
for (String customMenuTitle : customMenusTitles) {
|
||||
JMenu customMenu = new JMenu(_(customMenuTitle));
|
||||
JMenu customMenu = new JMenu(tr(customMenuTitle));
|
||||
customMenu.putClientProperty("removeOnWindowDeactivation", true);
|
||||
boardsCustomMenus.add(customMenu);
|
||||
}
|
||||
@ -1378,7 +1401,7 @@ public class Base {
|
||||
// Add a title for each platform
|
||||
String platformLabel = targetPlatform.getPreferences().get("name");
|
||||
if (platformLabel != null && !targetPlatform.getBoards().isEmpty()) {
|
||||
JMenuItem menuLabel = new JMenuItem(_(platformLabel));
|
||||
JMenuItem menuLabel = new JMenuItem(tr(platformLabel));
|
||||
menuLabel.setEnabled(false);
|
||||
boardMenu.add(menuLabel);
|
||||
}
|
||||
@ -1441,13 +1464,13 @@ public class Base {
|
||||
PreferencesMap customMenus = targetPlatform.getCustomMenus();
|
||||
for (final String menuId : customMenus.keySet()) {
|
||||
String title = customMenus.get(menuId);
|
||||
JMenu menu = getBoardCustomMenu(_(title));
|
||||
JMenu menu = getBoardCustomMenu(tr(title));
|
||||
|
||||
if (board.hasMenu(menuId)) {
|
||||
PreferencesMap boardCustomMenu = board.getMenuLabels(menuId);
|
||||
for (String customMenuOption : boardCustomMenu.keySet()) {
|
||||
@SuppressWarnings("serial")
|
||||
Action subAction = new AbstractAction(_(boardCustomMenu.get(customMenuOption))) {
|
||||
Action subAction = new AbstractAction(tr(boardCustomMenu.get(customMenuOption))) {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
PreferencesData.set("custom_" + menuId, ((TargetBoard) getValue("board")).getId() + "_" + getValue("custom_menu_option"));
|
||||
onBoardOrPortChange();
|
||||
@ -1633,8 +1656,8 @@ public class Base {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
showWarning(_("Sketch Does Not Exist"),
|
||||
_("The selected sketch no longer exists.\n"
|
||||
showWarning(tr("Sketch Does Not Exist"),
|
||||
tr("The selected sketch no longer exists.\n"
|
||||
+ "You may need to restart Arduino to update\n"
|
||||
+ "the sketchbook menu."), null);
|
||||
}
|
||||
@ -1652,13 +1675,13 @@ public class Base {
|
||||
if (!builtOnce) {
|
||||
String complaining = I18n
|
||||
.format(
|
||||
_("The sketch \"{0}\" cannot be used.\n"
|
||||
tr("The sketch \"{0}\" cannot be used.\n"
|
||||
+ "Sketch names must contain only basic letters and numbers\n"
|
||||
+ "(ASCII-only with no spaces, "
|
||||
+ "and it cannot start with a number).\n"
|
||||
+ "To get rid of this message, remove the sketch from\n"
|
||||
+ "{1}"), name, entry.getAbsolutePath());
|
||||
showMessage(_("Ignoring sketch with bad name"), complaining);
|
||||
showMessage(tr("Ignoring sketch with bad name"), complaining);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -1697,7 +1720,7 @@ public class Base {
|
||||
try {
|
||||
activeEditor.getSketch().importLibrary(l);
|
||||
} catch (IOException e) {
|
||||
showWarning(_("Error"), I18n.format("Unable to list header files in {0}", l.getSrcFolder()), e);
|
||||
showWarning(tr("Error"), I18n.format("Unable to list header files in {0}", l.getSrcFolder()), e);
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -1778,10 +1801,6 @@ public class Base {
|
||||
return boardsCustomMenus;
|
||||
}
|
||||
|
||||
static public String getSketchbookLibrariesPath() {
|
||||
return BaseNoGui.getSketchbookLibrariesFolder().getAbsolutePath();
|
||||
}
|
||||
|
||||
public File getDefaultSketchbookFolderOrPromptForIt() {
|
||||
|
||||
File sketchbookFolder = BaseNoGui.getDefaultSketchbookFolder();
|
||||
@ -1797,8 +1816,8 @@ public class Base {
|
||||
}
|
||||
|
||||
if (!result) {
|
||||
showError(_("You forgot your sketchbook"),
|
||||
_("Arduino cannot run because it could not\n" +
|
||||
showError(tr("You forgot your sketchbook"),
|
||||
tr("Arduino cannot run because it could not\n" +
|
||||
"create a folder to store your sketchbook."), null);
|
||||
}
|
||||
|
||||
@ -1818,7 +1837,7 @@ public class Base {
|
||||
return folder;
|
||||
}
|
||||
|
||||
String prompt = _("Select (or create new) folder for sketches...");
|
||||
String prompt = tr("Select (or create new) folder for sketches...");
|
||||
folder = selectFolder(prompt, null, null);
|
||||
if (folder == null) {
|
||||
System.exit(0);
|
||||
@ -1842,8 +1861,8 @@ public class Base {
|
||||
BaseNoGui.getPlatform().openURL(url);
|
||||
|
||||
} catch (Exception e) {
|
||||
showWarning(_("Problem Opening URL"),
|
||||
I18n.format(_("Could not open the URL\n{0}"), url), e);
|
||||
showWarning(tr("Problem Opening URL"),
|
||||
I18n.format(tr("Could not open the URL\n{0}"), url), e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1867,8 +1886,8 @@ public class Base {
|
||||
BaseNoGui.getPlatform().openFolder(file);
|
||||
|
||||
} catch (Exception e) {
|
||||
showWarning(_("Problem Opening Folder"),
|
||||
I18n.format(_("Could not open the folder\n{0}"), file.getAbsolutePath()), e);
|
||||
showWarning(tr("Problem Opening Folder"),
|
||||
I18n.format(tr("Could not open the folder\n{0}"), file.getAbsolutePath()), e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1915,25 +1934,6 @@ public class Base {
|
||||
}
|
||||
|
||||
|
||||
// someone needs to be slapped
|
||||
//static KeyStroke closeWindowKeyStroke;
|
||||
|
||||
/**
|
||||
* Return true if the key event was a Ctrl-W or an ESC,
|
||||
* both indicators to close the window.
|
||||
* Use as part of a keyPressed() event handler for frames.
|
||||
*/
|
||||
/*
|
||||
static public boolean isCloseWindowEvent(KeyEvent e) {
|
||||
if (closeWindowKeyStroke == null) {
|
||||
int modifiers = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
|
||||
closeWindowKeyStroke = KeyStroke.getKeyStroke('W', modifiers);
|
||||
}
|
||||
return ((e.getKeyCode() == KeyEvent.VK_ESCAPE) ||
|
||||
KeyStroke.getKeyStrokeForEvent(e).equals(closeWindowKeyStroke));
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Registers key events for a Ctrl-W and ESC with an ActionListener
|
||||
* that will take care of disposing the window.
|
||||
@ -1967,7 +1967,7 @@ public class Base {
|
||||
if(referenceFile.exists()){
|
||||
openURL(referenceFile.getAbsolutePath());
|
||||
}else{
|
||||
showWarning(_("Problem Opening URL"), I18n.format(_("Could not open the URL\n{0}"), referenceFile), null);
|
||||
showWarning(tr("Problem Opening URL"), I18n.format(tr("Could not open the URL\n{0}"), referenceFile), null);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2043,167 +2043,6 @@ public class Base {
|
||||
}
|
||||
|
||||
|
||||
// ...................................................................
|
||||
|
||||
|
||||
// incomplete
|
||||
static public int showYesNoCancelQuestion(Editor editor, String title,
|
||||
String primary, String secondary) {
|
||||
if (!OSUtils.isMacOS()) {
|
||||
int result =
|
||||
JOptionPane.showConfirmDialog(null, primary + "\n" + secondary, title,
|
||||
JOptionPane.YES_NO_CANCEL_OPTION,
|
||||
JOptionPane.QUESTION_MESSAGE);
|
||||
return result;
|
||||
// if (result == JOptionPane.YES_OPTION) {
|
||||
//
|
||||
// } else if (result == JOptionPane.NO_OPTION) {
|
||||
// return true; // ok to continue
|
||||
//
|
||||
// } else if (result == JOptionPane.CANCEL_OPTION) {
|
||||
// return false;
|
||||
//
|
||||
// } else {
|
||||
// throw new IllegalStateException();
|
||||
// }
|
||||
|
||||
} else {
|
||||
// Pane formatting adapted from the Quaqua guide
|
||||
// http://www.randelshofer.ch/quaqua/guide/joptionpane.html
|
||||
JOptionPane pane =
|
||||
new JOptionPane("<html> " +
|
||||
"<head> <style type=\"text/css\">" +
|
||||
"b { font: 13pt \"Lucida Grande\" }" +
|
||||
"p { font: 11pt \"Lucida Grande\"; margin-top: 8px }" +
|
||||
"</style> </head>" +
|
||||
"<b>Do you want to save changes to this sketch<BR>" +
|
||||
" before closing?</b>" +
|
||||
"<p>If you don't save, your changes will be lost.",
|
||||
JOptionPane.QUESTION_MESSAGE);
|
||||
|
||||
String[] options = new String[]{
|
||||
"Save", "Cancel", "Don't Save"
|
||||
};
|
||||
pane.setOptions(options);
|
||||
|
||||
// highlight the safest option ala apple hig
|
||||
pane.setInitialValue(options[0]);
|
||||
|
||||
// on macosx, setting the destructive property places this option
|
||||
// away from the others at the lefthand side
|
||||
pane.putClientProperty("Quaqua.OptionPane.destructiveOption",
|
||||
new Integer(2));
|
||||
|
||||
JDialog dialog = pane.createDialog(editor, null);
|
||||
dialog.setVisible(true);
|
||||
|
||||
Object result = pane.getValue();
|
||||
if (result == options[0]) {
|
||||
return JOptionPane.YES_OPTION;
|
||||
} else if (result == options[1]) {
|
||||
return JOptionPane.CANCEL_OPTION;
|
||||
} else if (result == options[2]) {
|
||||
return JOptionPane.NO_OPTION;
|
||||
} else {
|
||||
return JOptionPane.CLOSED_OPTION;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//if (result == JOptionPane.YES_OPTION) {
|
||||
//
|
||||
// } else if (result == JOptionPane.NO_OPTION) {
|
||||
// return true; // ok to continue
|
||||
//
|
||||
// } else if (result == JOptionPane.CANCEL_OPTION) {
|
||||
// return false;
|
||||
//
|
||||
// } else {
|
||||
// throw new IllegalStateException();
|
||||
// }
|
||||
|
||||
static public int showYesNoQuestion(Frame editor, String title,
|
||||
String primary, String secondary) {
|
||||
if (!OSUtils.isMacOS()) {
|
||||
return JOptionPane.showConfirmDialog(editor,
|
||||
"<html><body>" +
|
||||
"<b>" + primary + "</b>" +
|
||||
"<br>" + secondary, title,
|
||||
JOptionPane.YES_NO_OPTION,
|
||||
JOptionPane.QUESTION_MESSAGE);
|
||||
} else {
|
||||
// Pane formatting adapted from the Quaqua guide
|
||||
// http://www.randelshofer.ch/quaqua/guide/joptionpane.html
|
||||
JOptionPane pane =
|
||||
new JOptionPane("<html> " +
|
||||
"<head> <style type=\"text/css\">" +
|
||||
"b { font: 13pt \"Lucida Grande\" }" +
|
||||
"p { font: 11pt \"Lucida Grande\"; margin-top: 8px }" +
|
||||
"</style> </head>" +
|
||||
"<b>" + primary + "</b>" +
|
||||
"<p>" + secondary + "</p>",
|
||||
JOptionPane.QUESTION_MESSAGE);
|
||||
|
||||
String[] options = new String[]{
|
||||
"Yes", "No"
|
||||
};
|
||||
pane.setOptions(options);
|
||||
|
||||
// highlight the safest option ala apple hig
|
||||
pane.setInitialValue(options[0]);
|
||||
|
||||
JDialog dialog = pane.createDialog(editor, null);
|
||||
dialog.setVisible(true);
|
||||
|
||||
Object result = pane.getValue();
|
||||
if (result == options[0]) {
|
||||
return JOptionPane.YES_OPTION;
|
||||
} else if (result == options[1]) {
|
||||
return JOptionPane.NO_OPTION;
|
||||
} else {
|
||||
return JOptionPane.CLOSED_OPTION;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve a path to something in the Processing folder. Eventually this
|
||||
* may refer to the Contents subfolder of Processing.app, if we bundle things
|
||||
* up as a single .app file with no additional folders.
|
||||
*/
|
||||
// static public String getContentsPath(String filename) {
|
||||
// String basePath = System.getProperty("user.dir");
|
||||
// /*
|
||||
// // do this later, when moving to .app package
|
||||
// if (PApplet.platform == PConstants.MACOSX) {
|
||||
// basePath = System.getProperty("processing.contents");
|
||||
// }
|
||||
// */
|
||||
// return basePath + File.separator + filename;
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
* Get a path for something in the Processing lib folder.
|
||||
*/
|
||||
/*
|
||||
static public String getLibContentsPath(String filename) {
|
||||
String libPath = getContentsPath("lib/" + filename);
|
||||
File libDir = new File(libPath);
|
||||
if (libDir.exists()) {
|
||||
return libPath;
|
||||
}
|
||||
// was looking into making this run from Eclipse, but still too much mess
|
||||
// libPath = getContents("build/shared/lib/" + what);
|
||||
// libDir = new File(libPath);
|
||||
// if (libDir.exists()) {
|
||||
// return libPath;
|
||||
// }
|
||||
return null;
|
||||
}
|
||||
*/
|
||||
static public File getContentFile(String name) {
|
||||
return BaseNoGui.getContentFile(name);
|
||||
}
|
||||
@ -2453,9 +2292,9 @@ public class Base {
|
||||
|
||||
public void handleAddLibrary() {
|
||||
JFileChooser fileChooser = new JFileChooser(System.getProperty("user.home"));
|
||||
fileChooser.setDialogTitle(_("Select a zip file or a folder containing the library you'd like to add"));
|
||||
fileChooser.setDialogTitle(tr("Select a zip file or a folder containing the library you'd like to add"));
|
||||
fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
|
||||
fileChooser.setFileFilter(new FileNameExtensionFilter(_("ZIP files or folders"), "zip"));
|
||||
fileChooser.setFileFilter(new FileNameExtensionFilter(tr("ZIP files or folders"), "zip"));
|
||||
|
||||
Dimension preferredSize = fileChooser.getPreferredSize();
|
||||
fileChooser.setPreferredSize(new Dimension(preferredSize.width + 200, preferredSize.height + 200));
|
||||
@ -2478,7 +2317,7 @@ public class Base {
|
||||
zipDeflater.deflate();
|
||||
File[] foldersInTmpFolder = tmpFolder.listFiles(new OnlyDirs());
|
||||
if (foldersInTmpFolder.length != 1) {
|
||||
throw new IOException(_("Zip doesn't contain a library"));
|
||||
throw new IOException(tr("Zip doesn't contain a library"));
|
||||
}
|
||||
sourceFile = foldersInTmpFolder[0];
|
||||
} catch (IOException e) {
|
||||
@ -2489,18 +2328,18 @@ public class Base {
|
||||
|
||||
File libFolder = sourceFile;
|
||||
if (FileUtils.isSubDirectory(new File(PreferencesData.get("sketchbook.path")), libFolder)) {
|
||||
activeEditor.statusError(_("A subfolder of your sketchbook is not a valid library"));
|
||||
activeEditor.statusError(tr("A subfolder of your sketchbook is not a valid library"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (FileUtils.isSubDirectory(libFolder, new File(PreferencesData.get("sketchbook.path")))) {
|
||||
activeEditor.statusError(_("You can't import a folder that contains your sketchbook"));
|
||||
activeEditor.statusError(tr("You can't import a folder that contains your sketchbook"));
|
||||
return;
|
||||
}
|
||||
|
||||
String libName = libFolder.getName();
|
||||
if (!BaseNoGui.isSanitaryName(libName)) {
|
||||
String mess = I18n.format(_("The library \"{0}\" cannot be used.\n"
|
||||
String mess = I18n.format(tr("The library \"{0}\" cannot be used.\n"
|
||||
+ "Library names must contain only basic letters and numbers.\n"
|
||||
+ "(ASCII only and no spaces, and it cannot start with a number)"),
|
||||
libName);
|
||||
@ -2515,14 +2354,14 @@ public class Base {
|
||||
headers = BaseNoGui.headerListFromIncludePath(libFolder);
|
||||
}
|
||||
if (headers.length == 0) {
|
||||
activeEditor.statusError(_("Specified folder/zip file does not contain a valid library"));
|
||||
activeEditor.statusError(tr("Specified folder/zip file does not contain a valid library"));
|
||||
return;
|
||||
}
|
||||
|
||||
// copy folder
|
||||
File destinationFolder = new File(BaseNoGui.getSketchbookLibrariesFolder(), sourceFile.getName());
|
||||
if (!destinationFolder.mkdir()) {
|
||||
activeEditor.statusError(I18n.format(_("A library named {0} already exists"), sourceFile.getName()));
|
||||
activeEditor.statusError(I18n.format(tr("A library named {0} already exists"), sourceFile.getName()));
|
||||
return;
|
||||
}
|
||||
try {
|
||||
@ -2531,7 +2370,7 @@ public class Base {
|
||||
activeEditor.statusError(e);
|
||||
return;
|
||||
}
|
||||
activeEditor.statusNotice(_("Library added to your libraries. Check \"Include library\" menu"));
|
||||
activeEditor.statusNotice(tr("Library added to your libraries. Check \"Include library\" menu"));
|
||||
} catch (IOException e) {
|
||||
// FIXME error when importing. ignoring :(
|
||||
} finally {
|
||||
@ -2553,11 +2392,7 @@ public class Base {
|
||||
}
|
||||
|
||||
public List<Editor> getEditors() {
|
||||
return new LinkedList<Editor>(editors);
|
||||
}
|
||||
|
||||
public Action getOpenBoardsManager() {
|
||||
return openBoardsManager;
|
||||
return new LinkedList<>(editors);
|
||||
}
|
||||
|
||||
public PdeKeywords getPdeKeywords() {
|
||||
@ -2567,4 +2402,5 @@ public class Base {
|
||||
public List<JMenuItem> getRecentSketchesMenuItems() {
|
||||
return recentSketchesMenuItems;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -26,9 +26,9 @@ import cc.arduino.packages.BoardPort;
|
||||
import cc.arduino.packages.MonitorFactory;
|
||||
import cc.arduino.packages.Uploader;
|
||||
import cc.arduino.packages.uploaders.SerialUploader;
|
||||
import cc.arduino.view.GoToLineNumber;
|
||||
import cc.arduino.view.StubMenuListener;
|
||||
import cc.arduino.view.findreplace.FindReplace;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.jcraft.jsch.JSchException;
|
||||
import jssc.SerialPortException;
|
||||
import org.fife.ui.rsyntaxtextarea.RSyntaxDocument;
|
||||
@ -37,11 +37,11 @@ import org.fife.ui.rsyntaxtextarea.RSyntaxUtilities;
|
||||
import org.fife.ui.rtextarea.Gutter;
|
||||
import org.fife.ui.rtextarea.RTextScrollPane;
|
||||
import processing.app.debug.RunnerException;
|
||||
import processing.app.debug.RunnerListener;
|
||||
import processing.app.forms.PasswordAuthorizationDialog;
|
||||
import processing.app.helpers.OSUtils;
|
||||
import processing.app.helpers.PreferencesMapException;
|
||||
import processing.app.legacy.PApplet;
|
||||
import processing.app.syntax.PdeKeywords;
|
||||
import processing.app.syntax.ArduinoTokenMakerFactory;
|
||||
import processing.app.syntax.SketchTextArea;
|
||||
import processing.app.tools.DiscourseFormat;
|
||||
@ -72,10 +72,11 @@ import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
import static processing.app.I18n._;
|
||||
import static processing.app.I18n.tr;
|
||||
|
||||
/**
|
||||
* Main editor panel for the Processing Development Environment.
|
||||
@ -92,21 +93,21 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
private static class ShouldSaveIfModified implements Predicate<Sketch> {
|
||||
|
||||
@Override
|
||||
public boolean apply(Sketch sketch) {
|
||||
return PreferencesData.getBoolean("editor.save_on_verify") && sketch.isModified() && !sketch.isReadOnly();
|
||||
public boolean test(Sketch sketch) {
|
||||
return PreferencesData.getBoolean("editor.save_on_verify") && sketch.isModified() && !sketch.isReadOnly(BaseNoGui.librariesIndexer.getInstalledLibraries(), BaseNoGui.getExamplesPath());
|
||||
}
|
||||
}
|
||||
|
||||
private static class ShouldSaveReadOnly implements Predicate<Sketch> {
|
||||
|
||||
@Override
|
||||
public boolean apply(Sketch sketch) {
|
||||
return sketch.isReadOnly();
|
||||
public boolean test(Sketch sketch) {
|
||||
return sketch.isReadOnly(BaseNoGui.librariesIndexer.getInstalledLibraries(), BaseNoGui.getExamplesPath());
|
||||
}
|
||||
}
|
||||
|
||||
private final static List<String> BOARD_PROTOCOLS_ORDER = Arrays.asList("serial", "network");
|
||||
private final static List<String> BOARD_PROTOCOLS_ORDER_TRANSLATIONS = Arrays.asList(_("Serial ports"), _("Network ports"));
|
||||
private final static List<String> BOARD_PROTOCOLS_ORDER_TRANSLATIONS = Arrays.asList(tr("Serial ports"), tr("Network ports"));
|
||||
|
||||
final Base base;
|
||||
|
||||
@ -250,9 +251,9 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
// For rev 0120, placing things inside a JPanel
|
||||
Container contentPain = getContentPane();
|
||||
contentPain.setLayout(new BorderLayout());
|
||||
JPanel pain = new JPanel();
|
||||
pain.setLayout(new BorderLayout());
|
||||
contentPain.add(pain, BorderLayout.CENTER);
|
||||
JPanel pane = new JPanel();
|
||||
pane.setLayout(new BorderLayout());
|
||||
contentPain.add(pane, BorderLayout.CENTER);
|
||||
|
||||
Box box = Box.createVerticalBox();
|
||||
Box upper = Box.createVerticalBox();
|
||||
@ -326,12 +327,12 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
// hopefully these are no longer needed w/ swing
|
||||
// (har har har.. that was wishful thinking)
|
||||
// listener = new EditorListener(this, textarea);
|
||||
pain.add(box);
|
||||
pane.add(box);
|
||||
|
||||
// get shift down/up events so we can show the alt version of toolbar buttons
|
||||
textarea.addKeyListener(toolbar);
|
||||
|
||||
pain.setTransferHandler(new FileDropHandler());
|
||||
pane.setTransferHandler(new FileDropHandler());
|
||||
|
||||
// System.out.println("t1");
|
||||
|
||||
@ -416,14 +417,14 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
}
|
||||
|
||||
if (successful == 0) {
|
||||
statusError(_("No files were added to the sketch."));
|
||||
statusError(tr("No files were added to the sketch."));
|
||||
|
||||
} else if (successful == 1) {
|
||||
statusNotice(_("One file added to the sketch."));
|
||||
statusNotice(tr("One file added to the sketch."));
|
||||
|
||||
} else {
|
||||
statusNotice(
|
||||
I18n.format(_("{0} files added to the sketch."), successful));
|
||||
I18n.format(tr("{0} files added to the sketch."), successful));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -550,7 +551,7 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
|
||||
menubar.add(buildEditMenu());
|
||||
|
||||
final JMenu sketchMenu = new JMenu(_("Sketch"));
|
||||
final JMenu sketchMenu = new JMenu(tr("Sketch"));
|
||||
sketchMenu.setMnemonic(KeyEvent.VK_S);
|
||||
sketchMenu.addMenuListener(new StubMenuListener() {
|
||||
|
||||
@ -594,10 +595,10 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
|
||||
private JMenu buildFileMenu() {
|
||||
JMenuItem item;
|
||||
fileMenu = new JMenu(_("File"));
|
||||
fileMenu = new JMenu(tr("File"));
|
||||
fileMenu.setMnemonic(KeyEvent.VK_F);
|
||||
|
||||
item = newJMenuItem(_("New"), 'N');
|
||||
item = newJMenuItem(tr("New"), 'N');
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try {
|
||||
@ -609,7 +610,7 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
});
|
||||
fileMenu.add(item);
|
||||
|
||||
item = Editor.newJMenuItem(_("Open..."), 'O');
|
||||
item = Editor.newJMenuItem(tr("Open..."), 'O');
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try {
|
||||
@ -622,7 +623,7 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
fileMenu.add(item);
|
||||
|
||||
base.rebuildRecentSketchesMenuItems();
|
||||
recentSketchesMenu = new JMenu(_("Open Recent"));
|
||||
recentSketchesMenu = new JMenu(tr("Open Recent"));
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -632,20 +633,20 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
fileMenu.add(recentSketchesMenu);
|
||||
|
||||
if (sketchbookMenu == null) {
|
||||
sketchbookMenu = new JMenu(_("Sketchbook"));
|
||||
sketchbookMenu = new JMenu(tr("Sketchbook"));
|
||||
MenuScroller.setScrollerFor(sketchbookMenu);
|
||||
base.rebuildSketchbookMenu(sketchbookMenu);
|
||||
}
|
||||
fileMenu.add(sketchbookMenu);
|
||||
|
||||
if (examplesMenu == null) {
|
||||
examplesMenu = new JMenu(_("Examples"));
|
||||
examplesMenu = new JMenu(tr("Examples"));
|
||||
MenuScroller.setScrollerFor(examplesMenu);
|
||||
base.rebuildExamplesMenu(examplesMenu);
|
||||
}
|
||||
fileMenu.add(examplesMenu);
|
||||
|
||||
item = Editor.newJMenuItem(_("Close"), 'W');
|
||||
item = Editor.newJMenuItem(tr("Close"), 'W');
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
base.handleClose(Editor.this);
|
||||
@ -653,7 +654,7 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
});
|
||||
fileMenu.add(item);
|
||||
|
||||
saveMenuItem = newJMenuItem(_("Save"), 'S');
|
||||
saveMenuItem = newJMenuItem(tr("Save"), 'S');
|
||||
saveMenuItem.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
handleSave(false);
|
||||
@ -661,7 +662,7 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
});
|
||||
fileMenu.add(saveMenuItem);
|
||||
|
||||
saveAsMenuItem = newJMenuItemShift(_("Save As..."), 'S');
|
||||
saveAsMenuItem = newJMenuItemShift(tr("Save As..."), 'S');
|
||||
saveAsMenuItem.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
handleSaveAs();
|
||||
@ -671,7 +672,7 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
|
||||
fileMenu.addSeparator();
|
||||
|
||||
item = newJMenuItemShift(_("Page Setup"), 'P');
|
||||
item = newJMenuItemShift(tr("Page Setup"), 'P');
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
handlePageSetup();
|
||||
@ -679,7 +680,7 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
});
|
||||
fileMenu.add(item);
|
||||
|
||||
item = newJMenuItem(_("Print"), 'P');
|
||||
item = newJMenuItem(tr("Print"), 'P');
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
handlePrint();
|
||||
@ -691,7 +692,7 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
if (!OSUtils.isMacOS()) {
|
||||
fileMenu.addSeparator();
|
||||
|
||||
item = newJMenuItem(_("Preferences"), ',');
|
||||
item = newJMenuItem(tr("Preferences"), ',');
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
base.handlePrefs();
|
||||
@ -701,7 +702,7 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
|
||||
fileMenu.addSeparator();
|
||||
|
||||
item = newJMenuItem(_("Quit"), 'Q');
|
||||
item = newJMenuItem(tr("Quit"), 'Q');
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
base.handleQuit();
|
||||
@ -722,7 +723,7 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
private void buildSketchMenu(JMenu sketchMenu) {
|
||||
sketchMenu.removeAll();
|
||||
|
||||
JMenuItem item = newJMenuItem(_("Verify / Compile"), 'R');
|
||||
JMenuItem item = newJMenuItem(tr("Verify/Compile"), 'R');
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
handleRun(false, Editor.this.presentHandler, Editor.this.runHandler);
|
||||
@ -730,7 +731,7 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
});
|
||||
sketchMenu.add(item);
|
||||
|
||||
item = newJMenuItem(_("Upload"), 'U');
|
||||
item = newJMenuItem(tr("Upload"), 'U');
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
handleExport(false);
|
||||
@ -738,7 +739,7 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
});
|
||||
sketchMenu.add(item);
|
||||
|
||||
item = newJMenuItemShift(_("Upload Using Programmer"), 'U');
|
||||
item = newJMenuItemShift(tr("Upload Using Programmer"), 'U');
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
handleExport(true);
|
||||
@ -747,9 +748,13 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
sketchMenu.add(item);
|
||||
|
||||
|
||||
item = newJMenuItemAlt(_("Export compiled Binary"), 'S');
|
||||
item = newJMenuItemAlt(tr("Export compiled Binary"), 'S');
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (new ShouldSaveReadOnly().test(sketch) && !handleSave(true)) {
|
||||
System.out.println(tr("Export canceled, changes must first be saved."));
|
||||
return;
|
||||
}
|
||||
handleRun(false, new ShouldSaveReadOnly(), Editor.this.presentAndSaveHandler, Editor.this.runAndSaveHandler);
|
||||
}
|
||||
});
|
||||
@ -765,7 +770,7 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
|
||||
sketchMenu.addSeparator();
|
||||
|
||||
item = newJMenuItem(_("Show Sketch Folder"), 'K');
|
||||
item = newJMenuItem(tr("Show Sketch Folder"), 'K');
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Base.openFolder(sketch.getFolder());
|
||||
@ -775,13 +780,13 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
item.setEnabled(Base.openFolderAvailable());
|
||||
|
||||
if (importMenu == null) {
|
||||
importMenu = new JMenu(_("Include Library"));
|
||||
importMenu = new JMenu(tr("Include Library"));
|
||||
MenuScroller.setScrollerFor(importMenu);
|
||||
base.rebuildImportMenu(importMenu);
|
||||
}
|
||||
sketchMenu.add(importMenu);
|
||||
|
||||
item = new JMenuItem(_("Add File..."));
|
||||
item = new JMenuItem(tr("Add File..."));
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
sketch.handleAddFile();
|
||||
@ -792,16 +797,16 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
|
||||
|
||||
private JMenu buildToolsMenu() {
|
||||
toolsMenu = new JMenu(_("Tools"));
|
||||
toolsMenu = new JMenu(tr("Tools"));
|
||||
toolsMenu.setMnemonic(KeyEvent.VK_T);
|
||||
|
||||
addInternalTools(toolsMenu);
|
||||
|
||||
JMenuItem item = newJMenuItemShift(_("Serial Monitor"), 'M');
|
||||
JMenuItem item = newJMenuItemShift(tr("Serial Monitor"), 'M');
|
||||
item.addActionListener(e -> handleSerial());
|
||||
toolsMenu.add(item);
|
||||
|
||||
item = newJMenuItemShift(_("Serial Plotter"), 'L');
|
||||
item = newJMenuItemShift(tr("Serial Plotter"), 'L');
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
handlePlotter();
|
||||
@ -823,17 +828,17 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
base.getBoardsCustomMenus().stream().forEach(toolsMenu::add);
|
||||
|
||||
if (portMenu == null)
|
||||
portMenu = new JMenu(_("Port"));
|
||||
portMenu = new JMenu(tr("Port"));
|
||||
populatePortMenu();
|
||||
toolsMenu.add(portMenu);
|
||||
toolsMenu.addSeparator();
|
||||
|
||||
base.rebuildProgrammerMenu();
|
||||
programmersMenu = new JMenu(_("Programmer"));
|
||||
programmersMenu = new JMenu(tr("Programmer"));
|
||||
base.getProgrammerMenus().stream().forEach(programmersMenu::add);
|
||||
toolsMenu.add(programmersMenu);
|
||||
|
||||
item = new JMenuItem(_("Burn Bootloader"));
|
||||
item = new JMenuItem(tr("Burn Bootloader"));
|
||||
item.addActionListener(e -> handleBurnBootloader());
|
||||
toolsMenu.add(item);
|
||||
|
||||
@ -1057,6 +1062,15 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
return textArea;
|
||||
}
|
||||
|
||||
public void updateKeywords(PdeKeywords keywords) {
|
||||
// update GUI for "Find In Reference"
|
||||
textarea.setKeywords(keywords);
|
||||
// update document for syntax highlighting
|
||||
RSyntaxDocument document = (RSyntaxDocument) textarea.getDocument();
|
||||
document.setTokenMakerFactory(new ArduinoTokenMakerFactory(keywords));
|
||||
document.setSyntaxStyle(RSyntaxDocument.SYNTAX_STYLE_CPLUSPLUS);
|
||||
}
|
||||
|
||||
private JMenuItem createToolMenuItem(String className) {
|
||||
try {
|
||||
Class<?> toolClass = Class.forName(className);
|
||||
@ -1116,11 +1130,11 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
|
||||
private void selectSerialPort(String name) {
|
||||
if(portMenu == null) {
|
||||
System.out.println(_("serialMenu is null"));
|
||||
System.out.println(tr("serialMenu is null"));
|
||||
return;
|
||||
}
|
||||
if (name == null) {
|
||||
System.out.println(_("name is null"));
|
||||
System.out.println(tr("name is null"));
|
||||
return;
|
||||
}
|
||||
JCheckBoxMenuItem selection = null;
|
||||
@ -1192,7 +1206,7 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
} else {
|
||||
lastProtocolTranslated = port.getProtocol();
|
||||
}
|
||||
JMenuItem lastProtocolMenuItem = new JMenuItem(_(lastProtocolTranslated));
|
||||
JMenuItem lastProtocolMenuItem = new JMenuItem(tr(lastProtocolTranslated));
|
||||
lastProtocolMenuItem.setEnabled(false);
|
||||
portMenu.add(lastProtocolMenuItem);
|
||||
}
|
||||
@ -1211,7 +1225,7 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
private JMenu buildHelpMenu() {
|
||||
// To deal with a Mac OS X 10.5 bug, add an extra space after the name
|
||||
// so that the OS doesn't try to insert its slow help menu.
|
||||
JMenu menu = new JMenu(_("Help"));
|
||||
JMenu menu = new JMenu(tr("Help"));
|
||||
menu.setMnemonic(KeyEvent.VK_H);
|
||||
JMenuItem item;
|
||||
|
||||
@ -1251,7 +1265,7 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
menu.add(item);
|
||||
*/
|
||||
|
||||
item = new JMenuItem(_("Getting Started"));
|
||||
item = new JMenuItem(tr("Getting Started"));
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Base.showArduinoGettingStarted();
|
||||
@ -1259,7 +1273,7 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
});
|
||||
menu.add(item);
|
||||
|
||||
item = new JMenuItem(_("Environment"));
|
||||
item = new JMenuItem(tr("Environment"));
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Base.showEnvironment();
|
||||
@ -1267,7 +1281,7 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
});
|
||||
menu.add(item);
|
||||
|
||||
item = new JMenuItem(_("Troubleshooting"));
|
||||
item = new JMenuItem(tr("Troubleshooting"));
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Base.showTroubleshooting();
|
||||
@ -1275,7 +1289,7 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
});
|
||||
menu.add(item);
|
||||
|
||||
item = new JMenuItem(_("Reference"));
|
||||
item = new JMenuItem(tr("Reference"));
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Base.showReference();
|
||||
@ -1285,18 +1299,18 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
|
||||
menu.addSeparator();
|
||||
|
||||
item = new JMenuItem(_("Galileo Help"));
|
||||
item = new JMenuItem(tr("Galileo Help"));
|
||||
item.setEnabled(false);
|
||||
menu.add(item);
|
||||
|
||||
item = new JMenuItem(_("Getting Started"));
|
||||
item = new JMenuItem(tr("Getting Started"));
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Base.showReference("reference/Galileo_help_files", "ArduinoIDE_guide_galileo");
|
||||
}
|
||||
});
|
||||
menu.add(item);
|
||||
item = new JMenuItem(_("Troubleshooting"));
|
||||
item = new JMenuItem(tr("Troubleshooting"));
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Base.showReference("reference/Galileo_help_files", "Guide_Troubleshooting_Galileo");
|
||||
@ -1306,18 +1320,18 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
|
||||
menu.addSeparator();
|
||||
|
||||
item = new JMenuItem(_("Edison Help"));
|
||||
item = new JMenuItem(tr("Edison Help"));
|
||||
item.setEnabled(false);
|
||||
menu.add(item);
|
||||
|
||||
item = new JMenuItem(_("Getting Started"));
|
||||
item = new JMenuItem(tr("Getting Started"));
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Base.showReference("reference/Edison_help_files", "ArduinoIDE_guide_edison");
|
||||
}
|
||||
});
|
||||
menu.add(item);
|
||||
item = new JMenuItem(_("Troubleshooting"));
|
||||
item = new JMenuItem(tr("Troubleshooting"));
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Base.showReference("reference/Edison_help_files", "Guide_Troubleshooting_Edison");
|
||||
@ -1327,18 +1341,11 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
|
||||
menu.addSeparator();
|
||||
|
||||
item = newJMenuItemShift(_("Find in Reference"), 'F');
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
// if (textarea.isSelectionActive()) {
|
||||
// handleFindReference();
|
||||
// }
|
||||
handleFindReference();
|
||||
}
|
||||
});
|
||||
item = newJMenuItemShift(tr("Find in Reference"), 'F');
|
||||
item.addActionListener(this::handleFindReference);
|
||||
menu.add(item);
|
||||
|
||||
item = new JMenuItem(_("Frequently Asked Questions"));
|
||||
item = new JMenuItem(tr("Frequently Asked Questions"));
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Base.showFAQ();
|
||||
@ -1346,10 +1353,10 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
});
|
||||
menu.add(item);
|
||||
|
||||
item = new JMenuItem(_("Visit Arduino.cc"));
|
||||
item = new JMenuItem(tr("Visit Arduino.cc"));
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Base.openURL(_("http://www.arduino.cc/"));
|
||||
Base.openURL(tr("http://www.arduino.cc/"));
|
||||
}
|
||||
});
|
||||
menu.add(item);
|
||||
@ -1357,7 +1364,7 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
// macosx already has its own about menu
|
||||
if (!OSUtils.isMacOS()) {
|
||||
menu.addSeparator();
|
||||
item = new JMenuItem(_("About Arduino"));
|
||||
item = new JMenuItem(tr("About Arduino"));
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
base.handleAbout();
|
||||
@ -1371,19 +1378,19 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
|
||||
|
||||
private JMenu buildEditMenu() {
|
||||
JMenu menu = new JMenu(_("Edit"));
|
||||
JMenu menu = new JMenu(tr("Edit"));
|
||||
menu.setName("menuEdit");
|
||||
menu.setMnemonic(KeyEvent.VK_E);
|
||||
|
||||
undoItem = newJMenuItem(_("Undo"), 'Z');
|
||||
undoItem = newJMenuItem(tr("Undo"), 'Z');
|
||||
undoItem.setName("menuEditUndo");
|
||||
undoItem.addActionListener(undoAction = new UndoAction());
|
||||
menu.add(undoItem);
|
||||
|
||||
if (!OSUtils.isMacOS()) {
|
||||
redoItem = newJMenuItem(_("Redo"), 'Y');
|
||||
redoItem = newJMenuItem(tr("Redo"), 'Y');
|
||||
} else {
|
||||
redoItem = newJMenuItemShift(_("Redo"), 'Z');
|
||||
redoItem = newJMenuItemShift(tr("Redo"), 'Z');
|
||||
}
|
||||
redoItem.setName("menuEditRedo");
|
||||
redoItem.addActionListener(redoAction = new RedoAction());
|
||||
@ -1393,7 +1400,7 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
|
||||
// TODO "cut" and "copy" should really only be enabled
|
||||
// if some text is currently selected
|
||||
JMenuItem cutItem = newJMenuItem(_("Cut"), 'X');
|
||||
JMenuItem cutItem = newJMenuItem(tr("Cut"), 'X');
|
||||
cutItem.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
handleCut();
|
||||
@ -1401,7 +1408,7 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
});
|
||||
menu.add(cutItem);
|
||||
|
||||
JMenuItem copyItem = newJMenuItem(_("Copy"), 'C');
|
||||
JMenuItem copyItem = newJMenuItem(tr("Copy"), 'C');
|
||||
copyItem.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
textarea.copy();
|
||||
@ -1409,7 +1416,7 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
});
|
||||
menu.add(copyItem);
|
||||
|
||||
JMenuItem copyForumItem = newJMenuItemShift(_("Copy for Forum"), 'C');
|
||||
JMenuItem copyForumItem = newJMenuItemShift(tr("Copy for Forum"), 'C');
|
||||
copyForumItem.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
// SwingUtilities.invokeLater(new Runnable() {
|
||||
@ -1421,7 +1428,7 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
});
|
||||
menu.add(copyForumItem);
|
||||
|
||||
JMenuItem copyHTMLItem = newJMenuItemAlt(_("Copy as HTML"), 'C');
|
||||
JMenuItem copyHTMLItem = newJMenuItemAlt(tr("Copy as HTML"), 'C');
|
||||
copyHTMLItem.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
// SwingUtilities.invokeLater(new Runnable() {
|
||||
@ -1433,7 +1440,7 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
});
|
||||
menu.add(copyHTMLItem);
|
||||
|
||||
JMenuItem pasteItem = newJMenuItem(_("Paste"), 'V');
|
||||
JMenuItem pasteItem = newJMenuItem(tr("Paste"), 'V');
|
||||
pasteItem.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
textarea.paste();
|
||||
@ -1442,7 +1449,7 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
});
|
||||
menu.add(pasteItem);
|
||||
|
||||
JMenuItem selectAllItem = newJMenuItem(_("Select All"), 'A');
|
||||
JMenuItem selectAllItem = newJMenuItem(tr("Select All"), 'A');
|
||||
selectAllItem.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
textarea.selectAll();
|
||||
@ -1450,9 +1457,17 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
});
|
||||
menu.add(selectAllItem);
|
||||
|
||||
JMenuItem gotoLine = newJMenuItem(tr("Go to line..."), 'L');
|
||||
gotoLine.addActionListener(e -> {
|
||||
GoToLineNumber goToLineNumber = new GoToLineNumber(Editor.this);
|
||||
goToLineNumber.setLocationRelativeTo(Editor.this);
|
||||
goToLineNumber.setVisible(true);
|
||||
});
|
||||
menu.add(gotoLine);
|
||||
|
||||
menu.addSeparator();
|
||||
|
||||
JMenuItem commentItem = newJMenuItem(_("Comment/Uncomment"), '/');
|
||||
JMenuItem commentItem = newJMenuItem(tr("Comment/Uncomment"), '/');
|
||||
commentItem.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
handleCommentUncomment();
|
||||
@ -1460,7 +1475,7 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
});
|
||||
menu.add(commentItem);
|
||||
|
||||
JMenuItem increaseIndentItem = new JMenuItem(_("Increase Indent"));
|
||||
JMenuItem increaseIndentItem = new JMenuItem(tr("Increase Indent"));
|
||||
increaseIndentItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0));
|
||||
increaseIndentItem.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
@ -1469,7 +1484,7 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
});
|
||||
menu.add(increaseIndentItem);
|
||||
|
||||
JMenuItem decreseIndentItem = new JMenuItem(_("Decrease Indent"));
|
||||
JMenuItem decreseIndentItem = new JMenuItem(tr("Decrease Indent"));
|
||||
decreseIndentItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, InputEvent.SHIFT_MASK));
|
||||
decreseIndentItem.setName("menuDecreaseIndent");
|
||||
decreseIndentItem.addActionListener(new ActionListener() {
|
||||
@ -1481,7 +1496,7 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
|
||||
menu.addSeparator();
|
||||
|
||||
JMenuItem findItem = newJMenuItem(_("Find..."), 'F');
|
||||
JMenuItem findItem = newJMenuItem(tr("Find..."), 'F');
|
||||
findItem.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (find == null) {
|
||||
@ -1496,7 +1511,7 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
});
|
||||
menu.add(findItem);
|
||||
|
||||
JMenuItem findNextItem = newJMenuItem(_("Find Next"), 'G');
|
||||
JMenuItem findNextItem = newJMenuItem(tr("Find Next"), 'G');
|
||||
findNextItem.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (find != null) {
|
||||
@ -1506,7 +1521,7 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
});
|
||||
menu.add(findNextItem);
|
||||
|
||||
JMenuItem findPreviousItem = newJMenuItemShift(_("Find Previous"), 'G');
|
||||
JMenuItem findPreviousItem = newJMenuItemShift(tr("Find Previous"), 'G');
|
||||
findPreviousItem.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (find != null) {
|
||||
@ -1517,7 +1532,7 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
menu.add(findPreviousItem);
|
||||
|
||||
if (OSUtils.isMacOS()) {
|
||||
JMenuItem useSelectionForFindItem = newJMenuItem(_("Use Selection For Find"), 'E');
|
||||
JMenuItem useSelectionForFindItem = newJMenuItem(tr("Use Selection For Find"), 'E');
|
||||
useSelectionForFindItem.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (find == null) {
|
||||
@ -1598,7 +1613,7 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
} else {
|
||||
this.setEnabled(false);
|
||||
undoItem.setEnabled(false);
|
||||
undoItem.setText(_("Undo"));
|
||||
undoItem.setText(tr("Undo"));
|
||||
putValue(Action.NAME, "Undo");
|
||||
}
|
||||
}
|
||||
@ -1631,7 +1646,7 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
} else {
|
||||
this.setEnabled(false);
|
||||
redoItem.setEnabled(false);
|
||||
redoItem.setText(_("Redo"));
|
||||
redoItem.setText(tr("Redo"));
|
||||
putValue(Action.NAME, "Redo");
|
||||
}
|
||||
}
|
||||
@ -1920,16 +1935,20 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
return text;
|
||||
}
|
||||
|
||||
private void handleFindReference() {
|
||||
String text = getCurrentKeyword();
|
||||
private void handleFindReference(ActionEvent e) {
|
||||
String text = getCurrentKeyword();
|
||||
|
||||
String referenceFile = base.getPdeKeywords().getReference(text);
|
||||
if (referenceFile == null) {
|
||||
statusNotice(I18n.format(_("No reference available for \"{0}\""), text));
|
||||
} else {
|
||||
Base.showReference("Reference/" + referenceFile);
|
||||
}
|
||||
}
|
||||
String referenceFile = base.getPdeKeywords().getReference(text);
|
||||
if (referenceFile == null) {
|
||||
statusNotice(I18n.format(tr("No reference available for \"{0}\""), text));
|
||||
} else {
|
||||
if (referenceFile.startsWith("Serial_")) {
|
||||
Base.showReference("Serial/" + referenceFile.substring("Serial_".length()));
|
||||
} else {
|
||||
Base.showReference("Reference/" + referenceFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
||||
@ -1947,11 +1966,11 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
|
||||
private void handleRun(final boolean verbose, Predicate<Sketch> shouldSavePredicate, Runnable verboseHandler, Runnable nonVerboseHandler) {
|
||||
internalCloseRunner();
|
||||
if (shouldSavePredicate.apply(sketch)) {
|
||||
if (shouldSavePredicate.test(sketch)) {
|
||||
handleSave(true);
|
||||
}
|
||||
toolbar.activateRun();
|
||||
status.progress(_("Compiling sketch..."));
|
||||
status.progress(tr("Compiling sketch..."));
|
||||
|
||||
// do this to advance/clear the terminal window / dos prompt / etc
|
||||
for (int i = 0; i < 10; i++) System.out.println();
|
||||
@ -1990,10 +2009,10 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
textarea.removeAllLineHighlights();
|
||||
sketch.prepare();
|
||||
sketch.build(verbose, saveHex);
|
||||
statusNotice(_("Done compiling."));
|
||||
statusNotice(tr("Done compiling."));
|
||||
} catch (PreferencesMapException e) {
|
||||
statusError(I18n.format(
|
||||
_("Error while compiling: missing '{0}' configuration parameter"),
|
||||
tr("Error while compiling: missing '{0}' configuration parameter"),
|
||||
e.getMessage()));
|
||||
} catch (Exception e) {
|
||||
status.unprogress();
|
||||
@ -2053,11 +2072,11 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
|
||||
toFront();
|
||||
|
||||
String prompt = I18n.format(_("Save changes to \"{0}\"? "), sketch.getName());
|
||||
String prompt = I18n.format(tr("Save changes to \"{0}\"? "), sketch.getName());
|
||||
|
||||
if (!OSUtils.isMacOS()) {
|
||||
int result =
|
||||
JOptionPane.showConfirmDialog(this, prompt, _("Close"),
|
||||
JOptionPane.showConfirmDialog(this, prompt, tr("Close"),
|
||||
JOptionPane.YES_NO_CANCEL_OPTION,
|
||||
JOptionPane.QUESTION_MESSAGE);
|
||||
|
||||
@ -2082,10 +2101,8 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
// suck--workarounds for the Mac and Apple's snobby attitude about it!
|
||||
// I think it's nifty that they treat their developers like dirt.
|
||||
|
||||
// Pane formatting adapted from the quaqua guide
|
||||
// http://www.randelshofer.ch/quaqua/guide/joptionpane.html
|
||||
JOptionPane pane =
|
||||
new JOptionPane(_("<html> " +
|
||||
new JOptionPane(tr("<html> " +
|
||||
"<head> <style type=\"text/css\">"+
|
||||
"b { font: 13pt \"Lucida Grande\" }"+
|
||||
"p { font: 11pt \"Lucida Grande\"; margin-top: 8px }"+
|
||||
@ -2096,18 +2113,13 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
JOptionPane.QUESTION_MESSAGE);
|
||||
|
||||
String[] options = new String[] {
|
||||
_("Save"), _("Cancel"), _("Don't Save")
|
||||
tr("Save"), tr("Cancel"), tr("Don't Save")
|
||||
};
|
||||
pane.setOptions(options);
|
||||
|
||||
// highlight the safest option ala apple hig
|
||||
pane.setInitialValue(options[0]);
|
||||
|
||||
// on macosx, setting the destructive property places this option
|
||||
// away from the others at the lefthand side
|
||||
pane.putClientProperty("Quaqua.OptionPane.destructiveOption",
|
||||
2);
|
||||
|
||||
JDialog dialog = pane.createDialog(this, null);
|
||||
dialog.setVisible(true);
|
||||
|
||||
@ -2154,8 +2166,8 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
{
|
||||
if (!fileName.endsWith(".ino") && !fileName.endsWith(".pde")) {
|
||||
|
||||
Base.showWarning(_("Bad file selected"),
|
||||
_("Arduino can only open its own sketches\n" +
|
||||
Base.showWarning(tr("Bad file selected"),
|
||||
tr("Arduino can only open its own sketches\n" +
|
||||
"and other files ending in .ino or .pde"), null);
|
||||
return false;
|
||||
|
||||
@ -2163,8 +2175,8 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
String properParent =
|
||||
fileName.substring(0, fileName.length() - 4);
|
||||
|
||||
Object[] options = { _("OK"), _("Cancel") };
|
||||
String prompt = I18n.format(_("The file \"{0}\" needs to be inside\n" +
|
||||
Object[] options = { tr("OK"), tr("Cancel") };
|
||||
String prompt = I18n.format(tr("The file \"{0}\" needs to be inside\n" +
|
||||
"a sketch folder named \"{1}\".\n" +
|
||||
"Create this folder, move the file, and continue?"),
|
||||
fileName,
|
||||
@ -2172,7 +2184,7 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
|
||||
int result = JOptionPane.showOptionDialog(this,
|
||||
prompt,
|
||||
_("Moving"),
|
||||
tr("Moving"),
|
||||
JOptionPane.YES_NO_OPTION,
|
||||
JOptionPane.QUESTION_MESSAGE,
|
||||
null,
|
||||
@ -2183,9 +2195,9 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
// create properly named folder
|
||||
File properFolder = new File(sketchFile.getParent(), properParent);
|
||||
if (properFolder.exists()) {
|
||||
Base.showWarning(_("Error"),
|
||||
Base.showWarning(tr("Error"),
|
||||
I18n.format(
|
||||
_("A folder named \"{0}\" already exists. " +
|
||||
tr("A folder named \"{0}\" already exists. " +
|
||||
"Can't open sketch."),
|
||||
properParent
|
||||
),
|
||||
@ -2194,8 +2206,8 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
}
|
||||
if (!properFolder.mkdirs()) {
|
||||
//throw new IOException("Couldn't create sketch folder");
|
||||
Base.showWarning(_("Error"),
|
||||
_("Could not create the sketch folder."), null);
|
||||
Base.showWarning(tr("Error"),
|
||||
tr("Could not create the sketch folder."), null);
|
||||
return false;
|
||||
}
|
||||
// copy the sketch inside
|
||||
@ -2203,7 +2215,7 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
try {
|
||||
Base.copyFile(sketchFile, properPdeFile);
|
||||
} catch (IOException e) {
|
||||
Base.showWarning(_("Error"), _("Could not copy to a proper location."), e);
|
||||
Base.showWarning(tr("Error"), tr("Could not copy to a proper location."), e);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -2222,7 +2234,7 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
try {
|
||||
sketch = new Sketch(this, file);
|
||||
} catch (IOException e) {
|
||||
Base.showWarning(_("Error"), _("Could not create the sketch."), e);
|
||||
Base.showWarning(tr("Error"), tr("Could not create the sketch."), e);
|
||||
return false;
|
||||
}
|
||||
header.rebuild();
|
||||
@ -2245,9 +2257,9 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
return;
|
||||
}
|
||||
if (sketch.getName().equals(sketch.getCurrentCode().getPrettyName())) {
|
||||
setTitle(I18n.format(_("{0} | Arduino {1}"), sketch.getName(), BaseNoGui.VERSION_NAME_LONG));
|
||||
setTitle(I18n.format(tr("{0} | Arduino {1}"), sketch.getName(), BaseNoGui.VERSION_NAME_LONG));
|
||||
} else {
|
||||
setTitle(I18n.format(_("{0} - {1} | Arduino {2}"), sketch.getName(), sketch.getCurrentCode().getFileName(), BaseNoGui.VERSION_NAME_LONG));
|
||||
setTitle(I18n.format(tr("{0} - {1} | Arduino {2}"), sketch.getName(), sketch.getCurrentCode().getFileName(), BaseNoGui.VERSION_NAME_LONG));
|
||||
}
|
||||
}
|
||||
|
||||
@ -2286,14 +2298,14 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
|
||||
private boolean handleSave2() {
|
||||
toolbar.activateSave();
|
||||
statusNotice(_("Saving..."));
|
||||
statusNotice(tr("Saving..."));
|
||||
boolean saved = false;
|
||||
try {
|
||||
boolean wasReadOnly = sketch.isReadOnly();
|
||||
boolean wasReadOnly = sketch.isReadOnly(BaseNoGui.librariesIndexer.getInstalledLibraries(), BaseNoGui.getExamplesPath());
|
||||
String previousMainFilePath = sketch.getMainFilePath();
|
||||
saved = sketch.save();
|
||||
if (saved) {
|
||||
statusNotice(_("Done Saving."));
|
||||
statusNotice(tr("Done Saving."));
|
||||
if (wasReadOnly) {
|
||||
base.removeRecentSketchPath(previousMainFilePath);
|
||||
}
|
||||
@ -2332,18 +2344,18 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
|
||||
//SwingUtilities.invokeLater(new Runnable() {
|
||||
//public void run() {
|
||||
statusNotice(_("Saving..."));
|
||||
statusNotice(tr("Saving..."));
|
||||
try {
|
||||
if (sketch.saveAs()) {
|
||||
base.storeRecentSketches(sketch);
|
||||
base.rebuildRecentSketchesMenuItems();
|
||||
statusNotice(_("Done Saving."));
|
||||
statusNotice(tr("Done Saving."));
|
||||
// Disabling this for 0125, instead rebuild the menu inside
|
||||
// the Save As method of the Sketch object, since that's the
|
||||
// only one who knows whether something was renamed.
|
||||
//sketchbook.rebuildMenusAsync();
|
||||
} else {
|
||||
statusNotice(_("Save Canceled."));
|
||||
statusNotice(tr("Save Canceled."));
|
||||
return false;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
@ -2369,7 +2381,7 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
String result = (String)
|
||||
JOptionPane.showInputDialog(this,
|
||||
I18n.format(
|
||||
_("Serial port {0} not found.\n" +
|
||||
tr("Serial port {0} not found.\n" +
|
||||
"Retry the upload with another serial port?"),
|
||||
PreferencesData.get("serial.port")
|
||||
),
|
||||
@ -2402,13 +2414,13 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
*/
|
||||
synchronized public void handleExport(final boolean usingProgrammer) {
|
||||
if (PreferencesData.getBoolean("editor.save_on_verify")) {
|
||||
if (sketch.isModified() && !sketch.isReadOnly()) {
|
||||
if (sketch.isModified() && !sketch.isReadOnly(BaseNoGui.librariesIndexer.getInstalledLibraries(), BaseNoGui.getExamplesPath())) {
|
||||
handleSave(true);
|
||||
}
|
||||
}
|
||||
toolbar.activateExport();
|
||||
console.clear();
|
||||
status.progress(_("Uploading to I/O Board..."));
|
||||
status.progress(tr("Uploading to I/O Board..."));
|
||||
|
||||
new Thread(usingProgrammer ? exportAppHandler : exportHandler).start();
|
||||
}
|
||||
@ -2430,15 +2442,15 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
|
||||
boolean success = sketch.exportApplet(false);
|
||||
if (success) {
|
||||
statusNotice(_("Done uploading."));
|
||||
statusNotice(tr("Done uploading."));
|
||||
}
|
||||
} catch (SerialNotFoundException e) {
|
||||
if (portMenu.getItemCount() == 0) statusError(e);
|
||||
else if (serialPrompt()) run();
|
||||
else statusNotice(_("Upload canceled."));
|
||||
else statusNotice(tr("Upload canceled."));
|
||||
} catch (PreferencesMapException e) {
|
||||
statusError(I18n.format(
|
||||
_("Error while uploading: missing '{0}' configuration parameter"),
|
||||
tr("Error while uploading: missing '{0}' configuration parameter"),
|
||||
e.getMessage()));
|
||||
} catch (RunnerException e) {
|
||||
//statusError("Error during upload.");
|
||||
@ -2525,15 +2537,15 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
|
||||
boolean success = sketch.exportApplet(true);
|
||||
if (success) {
|
||||
statusNotice(_("Done uploading."));
|
||||
statusNotice(tr("Done uploading."));
|
||||
}
|
||||
} catch (SerialNotFoundException e) {
|
||||
if (portMenu.getItemCount() == 0) statusError(e);
|
||||
else if (serialPrompt()) run();
|
||||
else statusNotice(_("Upload canceled."));
|
||||
else statusNotice(tr("Upload canceled."));
|
||||
} catch (PreferencesMapException e) {
|
||||
statusError(I18n.format(
|
||||
_("Error while uploading: missing '{0}' configuration parameter"),
|
||||
tr("Error while uploading: missing '{0}' configuration parameter"),
|
||||
e.getMessage()));
|
||||
} catch (RunnerException e) {
|
||||
//statusError("Error during upload.");
|
||||
@ -2612,12 +2624,12 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
boolean success = false;
|
||||
do {
|
||||
if (serialMonitor.requiresAuthorization() && !PreferencesData.has(serialMonitor.getAuthorizationKey())) {
|
||||
PasswordAuthorizationDialog dialog = new PasswordAuthorizationDialog(this, _("Type board password to access its console"));
|
||||
PasswordAuthorizationDialog dialog = new PasswordAuthorizationDialog(this, tr("Type board password to access its console"));
|
||||
dialog.setLocationRelativeTo(this);
|
||||
dialog.setVisible(true);
|
||||
|
||||
if (dialog.isCancelled()) {
|
||||
statusNotice(_("Unable to open serial monitor"));
|
||||
statusNotice(tr("Unable to open serial monitor"));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -2629,9 +2641,9 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
serialMonitor.setVisible(true);
|
||||
success = true;
|
||||
} catch (ConnectException e) {
|
||||
statusError(_("Unable to connect: is the sketch using the bridge?"));
|
||||
statusError(tr("Unable to connect: is the sketch using the bridge?"));
|
||||
} catch (JSchException e) {
|
||||
statusError(_("Unable to connect: wrong password?"));
|
||||
statusError(tr("Unable to connect: wrong password?"));
|
||||
} catch (SerialException e) {
|
||||
String errorMessage = e.getMessage();
|
||||
if (e.getCause() != null && e.getCause() instanceof SerialPortException) {
|
||||
@ -2708,12 +2720,12 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
boolean success = false;
|
||||
do {
|
||||
if (serialPlotter.requiresAuthorization() && !PreferencesData.has(serialPlotter.getAuthorizationKey())) {
|
||||
PasswordAuthorizationDialog dialog = new PasswordAuthorizationDialog(this, _("Type board password to access its console"));
|
||||
PasswordAuthorizationDialog dialog = new PasswordAuthorizationDialog(this, tr("Type board password to access its console"));
|
||||
dialog.setLocationRelativeTo(this);
|
||||
dialog.setVisible(true);
|
||||
|
||||
if (dialog.isCancelled()) {
|
||||
statusNotice(_("Unable to open serial plotter"));
|
||||
statusNotice(tr("Unable to open serial plotter"));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -2725,9 +2737,9 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
serialPlotter.setVisible(true);
|
||||
success = true;
|
||||
} catch (ConnectException e) {
|
||||
statusError(_("Unable to connect: is the sketch using the bridge?"));
|
||||
statusError(tr("Unable to connect: is the sketch using the bridge?"));
|
||||
} catch (JSchException e) {
|
||||
statusError(_("Unable to connect: wrong password?"));
|
||||
statusError(tr("Unable to connect: wrong password?"));
|
||||
} catch (SerialException e) {
|
||||
String errorMessage = e.getMessage();
|
||||
if (e.getCause() != null && e.getCause() instanceof SerialPortException) {
|
||||
@ -2748,25 +2760,25 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
|
||||
private void handleBurnBootloader() {
|
||||
console.clear();
|
||||
statusNotice(_("Burning bootloader to I/O Board (this may take a minute)..."));
|
||||
statusNotice(tr("Burning bootloader to I/O Board (this may take a minute)..."));
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
Uploader uploader = new SerialUploader();
|
||||
if (uploader.burnBootloader()) {
|
||||
statusNotice(_("Done burning bootloader."));
|
||||
statusNotice(tr("Done burning bootloader."));
|
||||
} else {
|
||||
statusError(_("Error while burning bootloader."));
|
||||
statusError(tr("Error while burning bootloader."));
|
||||
// error message will already be visible
|
||||
}
|
||||
} catch (PreferencesMapException e) {
|
||||
statusError(I18n.format(
|
||||
_("Error while burning bootloader: missing '{0}' configuration parameter"),
|
||||
tr("Error while burning bootloader: missing '{0}' configuration parameter"),
|
||||
e.getMessage()));
|
||||
} catch (RunnerException e) {
|
||||
statusError(e.getMessage());
|
||||
} catch (Exception e) {
|
||||
statusError(_("Error while burning bootloader."));
|
||||
statusError(tr("Error while burning bootloader."));
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@ -2790,7 +2802,7 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
* Handler for File → Print.
|
||||
*/
|
||||
private void handlePrint() {
|
||||
statusNotice(_("Printing..."));
|
||||
statusNotice(tr("Printing..."));
|
||||
//printerJob = null;
|
||||
PrinterJob printerJob = PrinterJob.getPrinterJob();
|
||||
if (pageFormat != null) {
|
||||
@ -2805,14 +2817,14 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
if (printerJob.printDialog()) {
|
||||
try {
|
||||
printerJob.print();
|
||||
statusNotice(_("Done printing."));
|
||||
statusNotice(tr("Done printing."));
|
||||
|
||||
} catch (PrinterException pe) {
|
||||
statusError(_("Error while printing."));
|
||||
statusError(tr("Error while printing."));
|
||||
pe.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
statusNotice(_("Printing canceled."));
|
||||
statusNotice(tr("Printing canceled."));
|
||||
}
|
||||
//printerJob = null; // clear this out?
|
||||
}
|
||||
@ -2861,7 +2873,7 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
}
|
||||
}
|
||||
if (line < 0 || line >= textarea.getLineCount()) {
|
||||
System.err.println(I18n.format(_("Bad error line: {0}"), line));
|
||||
System.err.println(I18n.format(tr("Bad error line: {0}"), line));
|
||||
} else {
|
||||
try {
|
||||
textarea.addLineHighlight(line, new Color(1, 0, 0, 0.2f));
|
||||
@ -2934,7 +2946,7 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
|
||||
menu.add(item);
|
||||
|
||||
item = newJMenuItem(_("Comment/Uncomment"), '/');
|
||||
item = newJMenuItem(tr("Comment/Uncomment"), '/');
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
handleCommentUncomment();
|
||||
@ -2942,7 +2954,7 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
});
|
||||
menu.add(item);
|
||||
|
||||
item = newJMenuItem(_("Increase Indent"), ']');
|
||||
item = newJMenuItem(tr("Increase Indent"), ']');
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
handleIndentOutdent(true);
|
||||
@ -2950,7 +2962,7 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
});
|
||||
menu.add(item);
|
||||
|
||||
item = newJMenuItem(_("Decrease Indent"), '[');
|
||||
item = newJMenuItem(tr("Decrease Indent"), '[');
|
||||
item.setName("menuDecreaseIndent");
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
@ -2959,7 +2971,7 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
});
|
||||
menu.add(item);
|
||||
|
||||
item = new JMenuItem(_("Copy for Forum"));
|
||||
item = new JMenuItem(tr("Copy for Forum"));
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
handleDiscourseCopy();
|
||||
@ -2967,7 +2979,7 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
});
|
||||
menu.add(item);
|
||||
|
||||
item = new JMenuItem(_("Copy as HTML"));
|
||||
item = new JMenuItem(tr("Copy as HTML"));
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
handleHTMLCopy();
|
||||
@ -2975,15 +2987,11 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
});
|
||||
menu.add(item);
|
||||
|
||||
final JMenuItem referenceItem = new JMenuItem(_("Find in Reference"));
|
||||
referenceItem.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
handleFindReference();
|
||||
}
|
||||
});
|
||||
final JMenuItem referenceItem = new JMenuItem(tr("Find in Reference"));
|
||||
referenceItem.addActionListener(this::handleFindReference);
|
||||
menu.add(referenceItem);
|
||||
|
||||
final JMenuItem openURLItem = new JMenuItem(_("Open URL"));
|
||||
final JMenuItem openURLItem = new JMenuItem(tr("Open URL"));
|
||||
openURLItem.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Base.openURL(e.getActionCommand());
|
||||
@ -3019,4 +3027,15 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
|
||||
}
|
||||
|
||||
public void goToLine(int line) {
|
||||
if (line <= 0) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
textarea.setCaretPosition(textarea.getLineStartOffset(line - 1));
|
||||
} catch (BadLocationException e) {
|
||||
//ignore
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -24,10 +24,11 @@
|
||||
package processing.app;
|
||||
import processing.app.helpers.OSUtils;
|
||||
import processing.app.tools.MenuScroller;
|
||||
import static processing.app.I18n._;
|
||||
import static processing.app.I18n.tr;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
@ -293,7 +294,7 @@ public class EditorHeader extends JComponent {
|
||||
*/
|
||||
|
||||
//item = new JMenuItem("New Tab");
|
||||
item = Editor.newJMenuItemShift(_("New Tab"), 'N');
|
||||
item = Editor.newJMenuItemShift(tr("New Tab"), 'N');
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
editor.getSketch().handleNewCode();
|
||||
@ -301,7 +302,7 @@ public class EditorHeader extends JComponent {
|
||||
});
|
||||
menu.add(item);
|
||||
|
||||
item = new JMenuItem(_("Rename"));
|
||||
item = new JMenuItem(tr("Rename"));
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
editor.getSketch().handleRenameCode();
|
||||
@ -315,10 +316,14 @@ public class EditorHeader extends JComponent {
|
||||
});
|
||||
menu.add(item);
|
||||
|
||||
item = new JMenuItem(_("Delete"));
|
||||
item = new JMenuItem(tr("Delete"));
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
editor.getSketch().handleDeleteCode();
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
try {
|
||||
editor.getSketch().handleDeleteCode();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
menu.add(item);
|
||||
@ -327,7 +332,7 @@ public class EditorHeader extends JComponent {
|
||||
|
||||
// KeyEvent.VK_LEFT and VK_RIGHT will make Windows beep
|
||||
|
||||
item = new JMenuItem(_("Previous Tab"));
|
||||
item = new JMenuItem(tr("Previous Tab"));
|
||||
KeyStroke ctrlAltLeft = KeyStroke
|
||||
.getKeyStroke(KeyEvent.VK_LEFT, Editor.SHORTCUT_ALT_KEY_MASK);
|
||||
item.setAccelerator(ctrlAltLeft);
|
||||
@ -339,7 +344,7 @@ public class EditorHeader extends JComponent {
|
||||
});
|
||||
menu.add(item);
|
||||
|
||||
item = new JMenuItem(_("Next Tab"));
|
||||
item = new JMenuItem(tr("Next Tab"));
|
||||
KeyStroke ctrlAltRight = KeyStroke
|
||||
.getKeyStroke(KeyEvent.VK_RIGHT, Editor.SHORTCUT_ALT_KEY_MASK);
|
||||
item.setAccelerator(ctrlAltRight);
|
||||
|
@ -23,150 +23,121 @@
|
||||
|
||||
package processing.app;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import processing.app.helpers.OSUtils;
|
||||
|
||||
import java.awt.datatransfer.*;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.datatransfer.Clipboard;
|
||||
import java.awt.datatransfer.StringSelection;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
import static processing.app.I18n._;
|
||||
import static processing.app.I18n.tr;
|
||||
|
||||
|
||||
/**
|
||||
* Panel just below the editing area that contains status messages.
|
||||
*/
|
||||
public class EditorStatus extends JPanel /*implements ActionListener*/ {
|
||||
static Color bgcolor[];
|
||||
static Color fgcolor[];
|
||||
public class EditorStatus extends JPanel {
|
||||
|
||||
static final int NOTICE = 0;
|
||||
static final int ERR = 1;
|
||||
//static final int PROMPT = 2;
|
||||
//static final int EDIT = 3;
|
||||
static final int EDIT = 2;
|
||||
static final int PROGRESS = 5;
|
||||
private static final int NOTICE = 0;
|
||||
private static final int ERR = 1;
|
||||
private static final int EDIT = 2;
|
||||
private static final int PROGRESS = 5;
|
||||
private static final String NO_MESSAGE = "";
|
||||
|
||||
static final int YES = 1;
|
||||
static final int NO = 2;
|
||||
static final int CANCEL = 3;
|
||||
static final int OK = 4;
|
||||
private static final Color[] BGCOLOR;
|
||||
private static final Color[] FGCOLOR;
|
||||
|
||||
static final String NO_MESSAGE = "";
|
||||
static {
|
||||
BGCOLOR = new Color[6];
|
||||
BGCOLOR[0] = Theme.getColor("status.notice.bgcolor");
|
||||
BGCOLOR[1] = Theme.getColor("status.error.bgcolor");
|
||||
BGCOLOR[2] = Theme.getColor("status.edit.bgcolor");
|
||||
BGCOLOR[3] = null;
|
||||
BGCOLOR[4] = null;
|
||||
BGCOLOR[5] = Theme.getColor("status.notice.bgcolor");
|
||||
|
||||
Editor editor;
|
||||
FGCOLOR = new Color[6];
|
||||
FGCOLOR[0] = Theme.getColor("status.notice.fgcolor");
|
||||
FGCOLOR[1] = Theme.getColor("status.error.fgcolor");
|
||||
FGCOLOR[2] = Theme.getColor("status.edit.fgcolor");
|
||||
FGCOLOR[3] = null;
|
||||
FGCOLOR[4] = null;
|
||||
FGCOLOR[5] = Theme.getColor("status.notice.fgcolor");
|
||||
}
|
||||
|
||||
int mode;
|
||||
String message;
|
||||
private final Editor editor;
|
||||
private final Font font;
|
||||
|
||||
Font font;
|
||||
FontMetrics metrics;
|
||||
int ascent;
|
||||
private int mode;
|
||||
private String message;
|
||||
|
||||
Image offscreen;
|
||||
int sizeW, sizeH;
|
||||
int imageW, imageH;
|
||||
private Image offscreen;
|
||||
private int sizeW;
|
||||
private int sizeH;
|
||||
private int imageW;
|
||||
private int imageH;
|
||||
|
||||
//JButton yesButton;
|
||||
//JButton noButton;
|
||||
JButton cancelButton;
|
||||
JButton okButton;
|
||||
JTextField editField;
|
||||
JProgressBar progressBar;
|
||||
JButton copyErrorButton;
|
||||
|
||||
//Thread promptThread;
|
||||
int response;
|
||||
|
||||
boolean initialized = false;
|
||||
private JButton cancelButton;
|
||||
private JButton okButton;
|
||||
private JTextField editField;
|
||||
private JProgressBar progressBar;
|
||||
private JButton copyErrorButton;
|
||||
|
||||
public EditorStatus(Editor editor) {
|
||||
this.editor = editor;
|
||||
empty();
|
||||
|
||||
if (bgcolor == null) {
|
||||
bgcolor = new Color[6];
|
||||
bgcolor[0] = Theme.getColor("status.notice.bgcolor");
|
||||
bgcolor[1] = Theme.getColor("status.error.bgcolor");
|
||||
bgcolor[2] = Theme.getColor("status.edit.bgcolor");
|
||||
bgcolor[3] = null;
|
||||
bgcolor[4] = null;
|
||||
bgcolor[5] = Theme.getColor("status.notice.bgcolor");
|
||||
|
||||
fgcolor = new Color[6];
|
||||
fgcolor[0] = Theme.getColor("status.notice.fgcolor");
|
||||
fgcolor[1] = Theme.getColor("status.error.fgcolor");
|
||||
fgcolor[2] = Theme.getColor("status.edit.fgcolor");
|
||||
fgcolor[3] = null;
|
||||
fgcolor[4] = null;
|
||||
fgcolor[5] = Theme.getColor("status.notice.fgcolor");
|
||||
}
|
||||
this.message = NO_MESSAGE;
|
||||
this.mode = NOTICE;
|
||||
this.font = Theme.getFont("status.font");
|
||||
initialize();
|
||||
}
|
||||
|
||||
|
||||
public void empty() {
|
||||
mode = NOTICE;
|
||||
message = NO_MESSAGE;
|
||||
//update();
|
||||
public void clearState() {
|
||||
changeState(NOTICE);
|
||||
repaint();
|
||||
}
|
||||
|
||||
private void changeState(int newMode) {
|
||||
if (mode == newMode) {
|
||||
return;
|
||||
}
|
||||
|
||||
mode = newMode;
|
||||
|
||||
if (cancelButton.isVisible()) {
|
||||
cancelButton.doClick();
|
||||
}
|
||||
cancelButton.setVisible(false);
|
||||
okButton.setVisible(false);
|
||||
editField.setVisible(false);
|
||||
progressBar.setVisible(false);
|
||||
copyErrorButton.setVisible(false);
|
||||
message = NO_MESSAGE;
|
||||
}
|
||||
|
||||
public void notice(String message) {
|
||||
mode = NOTICE;
|
||||
changeState(NOTICE);
|
||||
this.message = message;
|
||||
if (copyErrorButton != null)
|
||||
if (copyErrorButton != null) {
|
||||
copyErrorButton.setVisible(false);
|
||||
//update();
|
||||
}
|
||||
repaint();
|
||||
}
|
||||
|
||||
public void unnotice(String unmessage) {
|
||||
if (message.equals(unmessage)) empty();
|
||||
}
|
||||
|
||||
|
||||
public void error(String message) {
|
||||
mode = ERR;
|
||||
changeState(ERR);
|
||||
this.message = message;
|
||||
if (copyErrorButton != null)
|
||||
if (copyErrorButton != null) {
|
||||
copyErrorButton.setVisible(true);
|
||||
}
|
||||
repaint();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
public void prompt(String message) {
|
||||
mode = PROMPT;
|
||||
this.message = message;
|
||||
|
||||
response = 0;
|
||||
yesButton.setVisible(true);
|
||||
noButton.setVisible(true);
|
||||
cancelButton.setVisible(true);
|
||||
yesButton.requestFocus();
|
||||
|
||||
repaint();
|
||||
}
|
||||
|
||||
|
||||
// prompt has been handled, re-hide the buttons
|
||||
public void unprompt() {
|
||||
yesButton.setVisible(false);
|
||||
noButton.setVisible(false);
|
||||
cancelButton.setVisible(false);
|
||||
empty();
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
public void edit(String message, String dflt) {
|
||||
mode = EDIT;
|
||||
changeState(EDIT);
|
||||
this.message = message;
|
||||
|
||||
response = 0;
|
||||
okButton.setVisible(true);
|
||||
cancelButton.setVisible(true);
|
||||
editField.setVisible(true);
|
||||
@ -177,16 +148,16 @@ public class EditorStatus extends JPanel /*implements ActionListener*/ {
|
||||
repaint();
|
||||
}
|
||||
|
||||
public void unedit() {
|
||||
private void unedit() {
|
||||
okButton.setVisible(false);
|
||||
cancelButton.setVisible(false);
|
||||
editField.setVisible(false);
|
||||
empty();
|
||||
clearState();
|
||||
repaint();
|
||||
}
|
||||
|
||||
public void progress(String message)
|
||||
{
|
||||
mode = PROGRESS;
|
||||
public void progress(String message) {
|
||||
changeState(PROGRESS);
|
||||
this.message = message;
|
||||
progressBar.setIndeterminate(false);
|
||||
progressBar.setVisible(true);
|
||||
@ -195,72 +166,30 @@ public class EditorStatus extends JPanel /*implements ActionListener*/ {
|
||||
repaint();
|
||||
}
|
||||
|
||||
|
||||
public void progressIndeterminate(String message)
|
||||
{
|
||||
mode = PROGRESS;
|
||||
public void progressNotice(String message) {
|
||||
this.message = message;
|
||||
progressBar.setIndeterminate(true);
|
||||
progressBar.setValue(50);
|
||||
progressBar.setVisible(true);
|
||||
copyErrorButton.setVisible(false);
|
||||
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||
repaint();
|
||||
}
|
||||
|
||||
|
||||
public void progressNotice(String message) {
|
||||
//mode = NOTICE;
|
||||
this.message = message;
|
||||
//update();
|
||||
repaint();
|
||||
}
|
||||
|
||||
|
||||
public void unprogress()
|
||||
{
|
||||
public void unprogress() {
|
||||
if (PreferencesData.getBoolean("editor.beep.compile")) {
|
||||
Toolkit.getDefaultToolkit().beep();
|
||||
}
|
||||
if (progressBar == null) return;
|
||||
if (progressBar == null) {
|
||||
return;
|
||||
}
|
||||
progressBar.setVisible(false);
|
||||
progressBar.setValue(0);
|
||||
setCursor(null);
|
||||
//empty();
|
||||
}
|
||||
|
||||
|
||||
public void progressUpdate(int value)
|
||||
{
|
||||
|
||||
public void progressUpdate(int value) {
|
||||
if (progressBar == null) return;
|
||||
progressBar.setValue(value);
|
||||
repaint();
|
||||
}
|
||||
|
||||
/*
|
||||
public void update() {
|
||||
Graphics g = this.getGraphics();
|
||||
try {
|
||||
setBackground(bgcolor[mode]);
|
||||
} catch (NullPointerException e) { } // if not ready yet
|
||||
if (g != null) paint(g);
|
||||
}
|
||||
|
||||
public void update(Graphics g) {
|
||||
paint(g);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
public void paintComponent(Graphics screen) {
|
||||
//if (screen == null) return;
|
||||
if (!initialized) {
|
||||
setup();
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
//System.out.println("status.paintComponent");
|
||||
|
||||
Dimension size = getSize();
|
||||
if ((size.width != sizeW) || (size.height != sizeH)) {
|
||||
// component has been resized
|
||||
@ -286,231 +215,174 @@ public class EditorStatus extends JPanel /*implements ActionListener*/ {
|
||||
offscreen = createImage(imageW, imageH);
|
||||
}
|
||||
|
||||
Graphics g = offscreen.getGraphics();
|
||||
if (font == null) {
|
||||
font = Theme.getFont("status.font");
|
||||
//new Font("SansSerif", Font.PLAIN, 12));
|
||||
g.setFont(font);
|
||||
metrics = g.getFontMetrics();
|
||||
ascent = metrics.getAscent();
|
||||
}
|
||||
Graphics graphics = offscreen.getGraphics();
|
||||
graphics.setColor(BGCOLOR[mode]);
|
||||
graphics.fillRect(0, 0, imageW, imageH);
|
||||
graphics.setColor(FGCOLOR[mode]);
|
||||
|
||||
//setBackground(bgcolor[mode]); // does nothing
|
||||
|
||||
g.setColor(bgcolor[mode]);
|
||||
g.fillRect(0, 0, imageW, imageH);
|
||||
|
||||
g.setColor(fgcolor[mode]);
|
||||
g.setFont(font); // needs to be set each time on osx
|
||||
g.drawString(message, Preferences.GUI_SMALL, (sizeH + ascent) / 2);
|
||||
graphics.setFont(font); // needs to be set each time on osx
|
||||
int ascent = graphics.getFontMetrics().getAscent();
|
||||
assert message != null;
|
||||
graphics.drawString(message, Preferences.GUI_SMALL, (sizeH + ascent) / 2);
|
||||
|
||||
screen.drawImage(offscreen, 0, 0, null);
|
||||
}
|
||||
|
||||
private void initialize() {
|
||||
cancelButton = new JButton(I18n.PROMPT_CANCEL);
|
||||
okButton = new JButton(I18n.PROMPT_OK);
|
||||
|
||||
protected void setup() {
|
||||
if (okButton == null) {
|
||||
cancelButton = new JButton(I18n.PROMPT_CANCEL);
|
||||
okButton = new JButton(I18n.PROMPT_OK);
|
||||
|
||||
cancelButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (mode == EDIT) {
|
||||
unedit();
|
||||
//editor.toolbar.clear();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
okButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
// answering to rename/new code question
|
||||
if (mode == EDIT) { // this if() isn't (shouldn't be?) necessary
|
||||
String answer = editField.getText();
|
||||
editor.getSketch().nameCode(answer);
|
||||
unedit();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// !@#(* aqua ui #($*(( that turtle-neck wearing #(** (#$@)(
|
||||
// os9 seems to work if bg of component is set, but x still a bastard
|
||||
if (OSUtils.isMacOS()) {
|
||||
//yesButton.setBackground(bgcolor[EDIT]);
|
||||
//noButton.setBackground(bgcolor[EDIT]);
|
||||
cancelButton.setBackground(bgcolor[EDIT]);
|
||||
okButton.setBackground(bgcolor[EDIT]);
|
||||
cancelButton.addActionListener(e -> {
|
||||
if (mode == EDIT) {
|
||||
unedit();
|
||||
}
|
||||
setLayout(null);
|
||||
});
|
||||
|
||||
/*
|
||||
yesButton.addActionListener(this);
|
||||
noButton.addActionListener(this);
|
||||
cancelButton.addActionListener(this);
|
||||
okButton.addActionListener(this);
|
||||
*/
|
||||
|
||||
//add(yesButton);
|
||||
//add(noButton);
|
||||
add(cancelButton);
|
||||
add(okButton);
|
||||
|
||||
//yesButton.setVisible(false);
|
||||
//noButton.setVisible(false);
|
||||
cancelButton.setVisible(false);
|
||||
okButton.setVisible(false);
|
||||
|
||||
editField = new JTextField();
|
||||
// disabling, was not in use
|
||||
//editField.addActionListener(this);
|
||||
|
||||
//if (Base.platform != Base.MACOSX) {
|
||||
editField.addKeyListener(new KeyAdapter() {
|
||||
|
||||
// Grab ESC with keyPressed, because it's not making it to keyTyped
|
||||
public void keyPressed(KeyEvent event) {
|
||||
if (event.getKeyChar() == KeyEvent.VK_ESCAPE) {
|
||||
unedit();
|
||||
//editor.toolbar.clear();
|
||||
event.consume();
|
||||
}
|
||||
}
|
||||
|
||||
// use keyTyped to catch when the feller is actually
|
||||
// added to the text field. with keyTyped, as opposed to
|
||||
// keyPressed, the keyCode will be zero, even if it's
|
||||
// enter or backspace or whatever, so the keychar should
|
||||
// be used instead. grr.
|
||||
public void keyTyped(KeyEvent event) {
|
||||
//System.out.println("got event " + event);
|
||||
int c = event.getKeyChar();
|
||||
|
||||
if (c == KeyEvent.VK_ENTER) { // accept the input
|
||||
String answer = editField.getText();
|
||||
editor.getSketch().nameCode(answer);
|
||||
unedit();
|
||||
event.consume();
|
||||
|
||||
// easier to test the affirmative case than the negative
|
||||
} else if ((c == KeyEvent.VK_BACK_SPACE) ||
|
||||
(c == KeyEvent.VK_DELETE) ||
|
||||
(c == KeyEvent.VK_RIGHT) ||
|
||||
(c == KeyEvent.VK_LEFT) ||
|
||||
(c == KeyEvent.VK_UP) ||
|
||||
(c == KeyEvent.VK_DOWN) ||
|
||||
(c == KeyEvent.VK_HOME) ||
|
||||
(c == KeyEvent.VK_END) ||
|
||||
(c == KeyEvent.VK_SHIFT)) {
|
||||
// these events are ignored
|
||||
|
||||
/*
|
||||
} else if (c == KeyEvent.VK_ESCAPE) {
|
||||
unedit();
|
||||
editor.toolbar.clear();
|
||||
event.consume();
|
||||
*/
|
||||
|
||||
} else if (c == KeyEvent.VK_SPACE) {
|
||||
String t = editField.getText();
|
||||
int start = editField.getSelectionStart();
|
||||
int end = editField.getSelectionEnd();
|
||||
editField.setText(t.substring(0, start) + "_" +
|
||||
t.substring(end));
|
||||
editField.setCaretPosition(start+1);
|
||||
event.consume();
|
||||
|
||||
} else if ((c == '_') || (c == '.') || // allow .pde and .java
|
||||
((c >= 'A') && (c <= 'Z')) ||
|
||||
((c >= 'a') && (c <= 'z'))) {
|
||||
// these are ok, allow them through
|
||||
|
||||
} else if ((c >= '0') && (c <= '9')) {
|
||||
// getCaretPosition == 0 means that it's the first char
|
||||
// and the field is empty.
|
||||
// getSelectionStart means that it *will be* the first
|
||||
// char, because the selection is about to be replaced
|
||||
// with whatever is typed.
|
||||
if ((editField.getCaretPosition() == 0) ||
|
||||
(editField.getSelectionStart() == 0)) {
|
||||
// number not allowed as first digit
|
||||
//System.out.println("bad number bad");
|
||||
event.consume();
|
||||
}
|
||||
} else {
|
||||
event.consume();
|
||||
//System.out.println("code is " + code + " char = " + c);
|
||||
}
|
||||
//System.out.println("code is " + code + " char = " + c);
|
||||
}
|
||||
});
|
||||
add(editField);
|
||||
editField.setVisible(false);
|
||||
|
||||
progressBar = new JProgressBar(JScrollBar.HORIZONTAL);
|
||||
progressBar.setIndeterminate(false);
|
||||
if (OSUtils.isMacOS()) {
|
||||
//progressBar.setBackground(bgcolor[PROGRESS]);
|
||||
//progressBar.putClientProperty("JProgressBar.style", "circular");
|
||||
okButton.addActionListener(e -> {
|
||||
// answering to rename/new code question
|
||||
if (mode == EDIT) { // this if() isn't (shouldn't be?) necessary
|
||||
String answer = editField.getText();
|
||||
editor.getSketch().nameCode(answer);
|
||||
unedit();
|
||||
}
|
||||
progressBar.setValue(0);
|
||||
progressBar.setBorderPainted(true);
|
||||
//progressBar.setStringPainted(true);
|
||||
add(progressBar);
|
||||
progressBar.setVisible(false);
|
||||
|
||||
copyErrorButton = new JButton(_("Copy error messages"));
|
||||
add(copyErrorButton);
|
||||
copyErrorButton.setVisible(false);
|
||||
copyErrorButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
String message = "";
|
||||
message += _("Arduino: ") + BaseNoGui.VERSION_NAME_LONG + " (" + System.getProperty("os.name") + "), ";
|
||||
message += _("Board: ") + "\"" + BaseNoGui.getBoardPreferences().get("name") + "\"\n\n";
|
||||
message += editor.console.getText();
|
||||
if ((PreferencesData.getBoolean("build.verbose")) == false) {
|
||||
message += "\n\n";
|
||||
message += " " + _("This report would have more information with") + "\n";
|
||||
message += " \"" + _("Show verbose output during compilation") + "\"\n";
|
||||
message += " " + _("enabled in File > Preferences.") + "\n";
|
||||
}
|
||||
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
|
||||
StringSelection data = new StringSelection(message);
|
||||
clipboard.setContents(data, null);
|
||||
Clipboard unixclipboard = Toolkit.getDefaultToolkit().getSystemSelection();
|
||||
if (unixclipboard != null) unixclipboard.setContents(data, null);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
if (OSUtils.isMacOS()) {
|
||||
cancelButton.setBackground(BGCOLOR[EDIT]);
|
||||
okButton.setBackground(BGCOLOR[EDIT]);
|
||||
}
|
||||
setLayout(null);
|
||||
|
||||
add(cancelButton);
|
||||
add(okButton);
|
||||
|
||||
cancelButton.setVisible(false);
|
||||
okButton.setVisible(false);
|
||||
|
||||
editField = new JTextField();
|
||||
|
||||
editField.addKeyListener(new KeyAdapter() {
|
||||
|
||||
// Grab ESC with keyPressed, because it's not making it to keyTyped
|
||||
public void keyPressed(KeyEvent event) {
|
||||
if (event.getKeyChar() == KeyEvent.VK_ESCAPE) {
|
||||
unedit();
|
||||
event.consume();
|
||||
}
|
||||
}
|
||||
|
||||
// use keyTyped to catch when the feller is actually
|
||||
// added to the text field. with keyTyped, as opposed to
|
||||
// keyPressed, the keyCode will be zero, even if it's
|
||||
// enter or backspace or whatever, so the keychar should
|
||||
// be used instead. grr.
|
||||
public void keyTyped(KeyEvent event) {
|
||||
int c = event.getKeyChar();
|
||||
|
||||
if (c == KeyEvent.VK_ENTER) { // accept the input
|
||||
String answer = editField.getText();
|
||||
editor.getSketch().nameCode(answer);
|
||||
unedit();
|
||||
event.consume();
|
||||
|
||||
// easier to test the affirmative case than the negative
|
||||
} else if ((c == KeyEvent.VK_BACK_SPACE) ||
|
||||
(c == KeyEvent.VK_DELETE) ||
|
||||
(c == KeyEvent.VK_RIGHT) ||
|
||||
(c == KeyEvent.VK_LEFT) ||
|
||||
(c == KeyEvent.VK_UP) ||
|
||||
(c == KeyEvent.VK_DOWN) ||
|
||||
(c == KeyEvent.VK_HOME) ||
|
||||
(c == KeyEvent.VK_END) ||
|
||||
(c == KeyEvent.VK_SHIFT)) {
|
||||
// these events are ignored
|
||||
|
||||
} else if (c == KeyEvent.VK_SPACE) {
|
||||
String t = editField.getText();
|
||||
int start = editField.getSelectionStart();
|
||||
int end = editField.getSelectionEnd();
|
||||
editField.setText(t.substring(0, start) + "_" +
|
||||
t.substring(end));
|
||||
editField.setCaretPosition(start + 1);
|
||||
event.consume();
|
||||
|
||||
|
||||
} else if ((c == '_') || (c == '.') || ((c >= 'A') && (c <= 'Z')) || ((c >= 'a') && (c <= 'z'))) { // allow .pde and .java
|
||||
// these are ok, allow them through
|
||||
|
||||
} else if ((c >= '0') && (c <= '9')) {
|
||||
// getCaretPosition == 0 means that it's the first char
|
||||
// and the field is empty.
|
||||
// getSelectionStart means that it *will be* the first
|
||||
// char, because the selection is about to be replaced
|
||||
// with whatever is typed.
|
||||
if ((editField.getCaretPosition() == 0) ||
|
||||
(editField.getSelectionStart() == 0)) {
|
||||
// number not allowed as first digit
|
||||
event.consume();
|
||||
}
|
||||
} else {
|
||||
event.consume();
|
||||
}
|
||||
}
|
||||
});
|
||||
add(editField);
|
||||
editField.setVisible(false);
|
||||
|
||||
progressBar = new JProgressBar(JScrollBar.HORIZONTAL);
|
||||
progressBar.setIndeterminate(false);
|
||||
progressBar.setValue(0);
|
||||
progressBar.setBorderPainted(true);
|
||||
add(progressBar);
|
||||
progressBar.setVisible(false);
|
||||
|
||||
copyErrorButton = new JButton(tr("Copy error messages"));
|
||||
add(copyErrorButton);
|
||||
copyErrorButton.setVisible(false);
|
||||
copyErrorButton.addActionListener(e -> {
|
||||
String message1 = "";
|
||||
message1 += tr("Arduino: ") + BaseNoGui.VERSION_NAME_LONG + " (" + System.getProperty("os.name") + "), ";
|
||||
message1 += tr("Board: ") + "\"" + BaseNoGui.getBoardPreferences().get("name") + "\"\n\n";
|
||||
message1 += editor.console.getText();
|
||||
if (!(PreferencesData.getBoolean("build.verbose"))) {
|
||||
message1 += "\n\n";
|
||||
message1 += " " + tr("This report would have more information with") + "\n";
|
||||
message1 += " \"" + tr("Show verbose output during compilation") + "\"\n";
|
||||
message1 += " " + tr("enabled in File > Preferences.") + "\n";
|
||||
}
|
||||
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
|
||||
StringSelection data = new StringSelection(message1);
|
||||
clipboard.setContents(data, null);
|
||||
Clipboard unixclipboard = Toolkit.getDefaultToolkit().getSystemSelection();
|
||||
if (unixclipboard != null) {
|
||||
unixclipboard.setContents(data, null);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
protected void setButtonBounds() {
|
||||
private void setButtonBounds() {
|
||||
int top = (sizeH - Preferences.BUTTON_HEIGHT) / 2;
|
||||
int eachButton = Preferences.GUI_SMALL + Preferences.BUTTON_WIDTH;
|
||||
|
||||
int cancelLeft = sizeW - eachButton;
|
||||
int noLeft = cancelLeft - eachButton;
|
||||
int yesLeft = noLeft - eachButton;
|
||||
int cancelLeft = sizeW - eachButton;
|
||||
int noLeft = cancelLeft - eachButton;
|
||||
int yesLeft = noLeft - eachButton;
|
||||
|
||||
//yesButton.setLocation(yesLeft, top);
|
||||
//noButton.setLocation(noLeft, top);
|
||||
cancelButton.setLocation(cancelLeft, top);
|
||||
okButton.setLocation(noLeft, top);
|
||||
progressBar.setLocation(noLeft, top);
|
||||
|
||||
//yesButton.setSize(Preferences.BUTTON_WIDTH, Preferences.BUTTON_HEIGHT);
|
||||
//noButton.setSize(Preferences.BUTTON_WIDTH, Preferences.BUTTON_HEIGHT);
|
||||
cancelButton.setSize(Preferences.BUTTON_WIDTH, Preferences.BUTTON_HEIGHT);
|
||||
okButton.setSize(Preferences.BUTTON_WIDTH, Preferences.BUTTON_HEIGHT);
|
||||
progressBar.setSize(2*Preferences.BUTTON_WIDTH, Preferences.BUTTON_HEIGHT);
|
||||
progressBar.setSize(2 * Preferences.BUTTON_WIDTH, Preferences.BUTTON_HEIGHT);
|
||||
|
||||
// edit field height is awkward, and very different between mac and pc,
|
||||
// so use at least the preferred height for now.
|
||||
int editWidth = 2*Preferences.BUTTON_WIDTH;
|
||||
int editWidth = 2 * Preferences.BUTTON_WIDTH;
|
||||
int editHeight = editField.getPreferredSize().height;
|
||||
int editTop = (1 + sizeH - editHeight) / 2; // add 1 for ceil
|
||||
editField.setBounds(yesLeft - Preferences.BUTTON_WIDTH, editTop,
|
||||
editWidth, editHeight);
|
||||
editField.setBounds(yesLeft - Preferences.BUTTON_WIDTH, editTop, editWidth, editHeight);
|
||||
progressBar.setBounds(noLeft, editTop, editWidth, editHeight);
|
||||
|
||||
Dimension copyErrorButtonSize = copyErrorButton.getPreferredSize();
|
||||
@ -518,7 +390,6 @@ public class EditorStatus extends JPanel /*implements ActionListener*/ {
|
||||
copyErrorButton.setSize(copyErrorButtonSize.width, Preferences.BUTTON_HEIGHT);
|
||||
}
|
||||
|
||||
|
||||
public Dimension getPreferredSize() {
|
||||
return getMinimumSize();
|
||||
}
|
||||
@ -531,23 +402,8 @@ public class EditorStatus extends JPanel /*implements ActionListener*/ {
|
||||
return new Dimension(3000, Preferences.GRID_SIZE);
|
||||
}
|
||||
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (e.getSource() == cancelButton) {
|
||||
if (mode == EDIT) unedit();
|
||||
//editor.toolbar.clear();
|
||||
|
||||
} else if (e.getSource() == okButton) {
|
||||
// answering to rename/new code question
|
||||
if (mode == EDIT) { // this if() isn't (shouldn't be?) necessary
|
||||
String answer = editField.getText();
|
||||
editor.getSketch().nameCode(answer);
|
||||
unedit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isInitialized() {
|
||||
return initialized;
|
||||
public boolean isErr() {
|
||||
return mode == ERR;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ import java.awt.event.KeyEvent;
|
||||
import java.awt.event.KeyListener;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
import static processing.app.I18n._;
|
||||
import static processing.app.I18n.tr;
|
||||
|
||||
|
||||
/**
|
||||
@ -42,14 +42,14 @@ public class EditorToolbar extends JComponent implements MouseInputListener, Key
|
||||
* Rollover titles for each button.
|
||||
*/
|
||||
private static final String[] title = {
|
||||
_("Verify"), _("Upload"), _("New"), _("Open"), _("Save"), _("Serial Monitor")
|
||||
tr("Verify"), tr("Upload"), tr("New"), tr("Open"), tr("Save"), tr("Serial Monitor")
|
||||
};
|
||||
|
||||
/**
|
||||
* Titles for each button when the shift key is pressed.
|
||||
*/
|
||||
private static final String[] titleShift = {
|
||||
_("Verify"), _("Upload Using Programmer"), _("New"), _("Open"), _("Save As..."), _("Serial Monitor")
|
||||
tr("Verify"), tr("Upload Using Programmer"), tr("New"), tr("Open"), tr("Save As..."), tr("Serial Monitor")
|
||||
};
|
||||
|
||||
private static final int BUTTON_COUNT = title.length;
|
||||
|
@ -19,7 +19,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import static processing.app.I18n._;
|
||||
import static processing.app.I18n.tr;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class NetworkMonitor extends AbstractTextMonitor implements MessageConsumer {
|
||||
@ -110,7 +110,7 @@ public class NetworkMonitor extends AbstractTextMonitor implements MessageConsum
|
||||
// ignore
|
||||
}
|
||||
if (channel.isConnected()) {
|
||||
NetworkMonitor.this.message(_("connected!") + '\n');
|
||||
NetworkMonitor.this.message(tr("connected!") + '\n');
|
||||
}
|
||||
}
|
||||
|
||||
@ -129,7 +129,7 @@ public class NetworkMonitor extends AbstractTextMonitor implements MessageConsum
|
||||
}
|
||||
}
|
||||
if (connectionAttempts < MAX_CONNECTION_ATTEMPTS) {
|
||||
s = "\n" + _("Unable to connect: retrying") + " (" + connectionAttempts + ")... ";
|
||||
s = "\n" + tr("Unable to connect: retrying") + " (" + connectionAttempts + ")... ";
|
||||
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
@ -144,7 +144,7 @@ public class NetworkMonitor extends AbstractTextMonitor implements MessageConsum
|
||||
}
|
||||
});
|
||||
} else {
|
||||
s = "\n" + _("Unable to connect: is the sketch using the bridge?");
|
||||
s = "\n" + tr("Unable to connect: is the sketch using the bridge?");
|
||||
}
|
||||
}
|
||||
super.message(s);
|
||||
|
@ -20,7 +20,7 @@
|
||||
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
package processing.app.debug;
|
||||
package processing.app;
|
||||
|
||||
|
||||
public interface RunnerListener {
|
||||
@ -30,4 +30,4 @@ public interface RunnerListener {
|
||||
public void statusError(Exception exception);
|
||||
|
||||
public void statusNotice(String message);
|
||||
}
|
||||
}
|
@ -25,7 +25,7 @@ import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import static processing.app.I18n._;
|
||||
import static processing.app.I18n.tr;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class SerialMonitor extends AbstractTextMonitor {
|
||||
@ -37,7 +37,7 @@ public class SerialMonitor extends AbstractTextMonitor {
|
||||
super(port);
|
||||
|
||||
serialRate = PreferencesData.getInteger("serial.debug_rate");
|
||||
serialRates.setSelectedItem(serialRate + " " + _("baud"));
|
||||
serialRates.setSelectedItem(serialRate + " " + tr("baud"));
|
||||
onSerialRateChange(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
String wholeString = (String) serialRates.getSelectedItem();
|
||||
|
@ -19,26 +19,24 @@
|
||||
package processing.app;
|
||||
|
||||
import cc.arduino.packages.BoardPort;
|
||||
import processing.app.helpers.CircularBuffer;
|
||||
import processing.app.helpers.Ticks;
|
||||
import processing.app.legacy.PApplet;
|
||||
|
||||
import processing.app.debug.MessageConsumer;
|
||||
import processing.app.helpers.*;
|
||||
import static processing.app.I18n._;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.awt.geom.*;
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.*;
|
||||
import javax.swing.event.*;
|
||||
import javax.swing.text.*;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
|
||||
import static processing.app.I18n.tr;
|
||||
|
||||
public class SerialPlotter extends AbstractMonitor {
|
||||
private StringBuffer messageBuffer;
|
||||
private CircularBuffer buffer;
|
||||
private GraphPanel graphPanel;
|
||||
private JComboBox serialRates;
|
||||
|
||||
private final StringBuffer messageBuffer;
|
||||
private CircularBuffer buffer;
|
||||
private JComboBox<String> serialRates;
|
||||
private Serial serial;
|
||||
private int serialRate;
|
||||
|
||||
@ -46,30 +44,30 @@ public class SerialPlotter extends AbstractMonitor {
|
||||
private double minY, maxY, rangeY;
|
||||
private Rectangle bounds;
|
||||
private int xOffset;
|
||||
private Font font;
|
||||
private Color graphColor;
|
||||
|
||||
private final Font font;
|
||||
private final Color graphColor;
|
||||
|
||||
public GraphPanel() {
|
||||
font = Theme.getFont("console.font");
|
||||
graphColor = Theme.getColor("header.bgcolor");
|
||||
xOffset = 20;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void paintComponent(Graphics g1) {
|
||||
Graphics2D g = (Graphics2D)g1;
|
||||
Graphics2D g = (Graphics2D) g1;
|
||||
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
g.setFont(font);
|
||||
super.paintComponent(g);
|
||||
|
||||
|
||||
bounds = g.getClipBounds();
|
||||
setBackground(Color.WHITE);
|
||||
if(buffer.isEmpty()) {
|
||||
if (buffer.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
minY = buffer.min();
|
||||
maxY = buffer.max();
|
||||
|
||||
minY = buffer.min() / 2;
|
||||
maxY = buffer.max() * 2;
|
||||
Ticks ticks = new Ticks(minY, maxY, 3);
|
||||
minY = Math.min(minY, ticks.getTick(0));
|
||||
maxY = Math.max(maxY, ticks.getTick(ticks.getTickCount() - 1));
|
||||
@ -80,45 +78,45 @@ public class SerialPlotter extends AbstractMonitor {
|
||||
|
||||
g.setStroke(new BasicStroke(1.0f));
|
||||
FontMetrics fm = g.getFontMetrics();
|
||||
for(int i = 0; i < ticks.getTickCount(); ++i) {
|
||||
for (int i = 0; i < ticks.getTickCount(); ++i) {
|
||||
double tick = ticks.getTick(i);
|
||||
Rectangle2D fRect = fm.getStringBounds(String.valueOf(tick), g);
|
||||
xOffset = Math.max(xOffset, (int)fRect.getWidth() + 15);
|
||||
xOffset = Math.max(xOffset, (int) fRect.getWidth() + 15);
|
||||
|
||||
// draw tick
|
||||
g.drawLine(xOffset - 5, (int)transformY(tick), xOffset + 2, (int)transformY(tick));
|
||||
g.drawLine(xOffset - 5, (int) transformY(tick), xOffset + 2, (int) transformY(tick));
|
||||
// draw tick label
|
||||
g.drawString(String.valueOf(tick), xOffset - (int)fRect.getWidth() - 10, transformY(tick) - (float)fRect.getHeight() * 0.5f + fm.getAscent());
|
||||
g.drawString(String.valueOf(tick), xOffset - (int) fRect.getWidth() - 10, transformY(tick) - (float) fRect.getHeight() * 0.5f + fm.getAscent());
|
||||
}
|
||||
|
||||
g.drawLine(bounds.x + xOffset, bounds.y + 5, bounds.x + xOffset, bounds.y + bounds.height - 10);
|
||||
|
||||
g.setTransform(AffineTransform.getTranslateInstance(xOffset, 0));
|
||||
float xstep = (float)(bounds.width - xOffset) / (float)buffer.capacity();
|
||||
|
||||
|
||||
g.setTransform(AffineTransform.getTranslateInstance(xOffset, 0));
|
||||
float xstep = (float) (bounds.width - xOffset) / (float) buffer.capacity();
|
||||
|
||||
g.setColor(graphColor);
|
||||
g.setStroke(new BasicStroke(0.75f));
|
||||
|
||||
for(int i = 0; i < buffer.size() - 1; ++i) {
|
||||
|
||||
for (int i = 0; i < buffer.size() - 1; ++i) {
|
||||
g.drawLine(
|
||||
(int)(i * xstep), (int)transformY(buffer.get(i)),
|
||||
(int)((i + 1) * xstep), (int)transformY(buffer.get(i + 1))
|
||||
(int) (i * xstep), (int) transformY(buffer.get(i)),
|
||||
(int) ((i + 1) * xstep), (int) transformY(buffer.get(i + 1))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Dimension getMinimumSize() {
|
||||
return new Dimension(200, 100);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Dimension getPreferredSize() {
|
||||
return new Dimension(500, 250);
|
||||
}
|
||||
|
||||
|
||||
private float transformY(double rawY) {
|
||||
return (float)(5 + (bounds.height - 10) * (1.0 - (rawY - minY) / rangeY));
|
||||
return (float) (5 + (bounds.height - 10) * (1.0 - (rawY - minY) / rangeY));
|
||||
}
|
||||
}
|
||||
|
||||
@ -126,94 +124,81 @@ public class SerialPlotter extends AbstractMonitor {
|
||||
super(port);
|
||||
|
||||
serialRate = PreferencesData.getInteger("serial.debug_rate");
|
||||
serialRates.setSelectedItem(serialRate + " " + _("baud"));
|
||||
onSerialRateChange(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
String wholeString = (String) serialRates.getSelectedItem();
|
||||
String rateString = wholeString.substring(0, wholeString.indexOf(' '));
|
||||
serialRate = Integer.parseInt(rateString);
|
||||
PreferencesData.set("serial.debug_rate", rateString);
|
||||
try {
|
||||
close();
|
||||
Thread.sleep(100); // Wait for serial port to properly close
|
||||
open();
|
||||
} catch (InterruptedException e) {
|
||||
// noop
|
||||
} catch (Exception e) {
|
||||
System.err.println(e);
|
||||
}
|
||||
serialRates.setSelectedItem(serialRate + " " + tr("baud"));
|
||||
onSerialRateChange(event -> {
|
||||
String wholeString = (String) serialRates.getSelectedItem();
|
||||
String rateString = wholeString.substring(0, wholeString.indexOf(' '));
|
||||
serialRate = Integer.parseInt(rateString);
|
||||
PreferencesData.set("serial.debug_rate", rateString);
|
||||
try {
|
||||
close();
|
||||
Thread.sleep(100); // Wait for serial port to properly close
|
||||
open();
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
}
|
||||
});
|
||||
|
||||
messageBuffer = new StringBuffer();
|
||||
}
|
||||
|
||||
|
||||
protected void onCreateWindow(Container mainPane) {
|
||||
mainPane.setLayout(new BorderLayout());
|
||||
|
||||
Font consoleFont = Theme.getFont("console.font");
|
||||
Font editorFont = PreferencesData.getFont("editor.font");
|
||||
Font font = new Font(consoleFont.getName(), consoleFont.getStyle(), editorFont.getSize());
|
||||
|
||||
|
||||
buffer = new CircularBuffer(500);
|
||||
graphPanel = new GraphPanel();
|
||||
|
||||
GraphPanel graphPanel = new GraphPanel();
|
||||
|
||||
mainPane.add(graphPanel, BorderLayout.CENTER);
|
||||
|
||||
|
||||
JPanel pane = new JPanel();
|
||||
pane.setLayout(new BoxLayout(pane, BoxLayout.X_AXIS));
|
||||
pane.setBorder(new EmptyBorder(4, 4, 4, 4));
|
||||
|
||||
serialRates = new JComboBox();
|
||||
for (int i = 0; i < serialRateStrings.length; i++)
|
||||
serialRates.addItem(serialRateStrings[i] + " " + _("baud"));
|
||||
|
||||
|
||||
serialRates = new JComboBox<>();
|
||||
for (String serialRateString : serialRateStrings) serialRates.addItem(serialRateString + " " + tr("baud"));
|
||||
|
||||
serialRates.setMaximumSize(serialRates.getMinimumSize());
|
||||
|
||||
pane.add(Box.createRigidArea(new Dimension(8, 0)));
|
||||
pane.add(serialRates);
|
||||
|
||||
|
||||
mainPane.add(pane, BorderLayout.SOUTH);
|
||||
}
|
||||
|
||||
protected void onEnableWindow(boolean enable)
|
||||
{
|
||||
serialRates.setEnabled(enable);
|
||||
|
||||
protected void onEnableWindow(boolean enable) {
|
||||
serialRates.setEnabled(enable);
|
||||
}
|
||||
|
||||
public void onSerialRateChange(ActionListener listener) {
|
||||
|
||||
private void onSerialRateChange(ActionListener listener) {
|
||||
serialRates.addActionListener(listener);
|
||||
}
|
||||
|
||||
|
||||
public void message(final String s) {
|
||||
messageBuffer.append(s);
|
||||
while(true) {
|
||||
while (true) {
|
||||
int linebreak = messageBuffer.indexOf("\n");
|
||||
if(linebreak == -1) {
|
||||
if (linebreak == -1) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
String line = messageBuffer.substring(0, linebreak);
|
||||
line = line.trim();
|
||||
messageBuffer.delete(0, linebreak + 1);
|
||||
|
||||
|
||||
try {
|
||||
double value = Double.valueOf(line);
|
||||
buffer.add(value);
|
||||
} catch(NumberFormatException e) {
|
||||
continue; // ignore lines that can't be cast to a number
|
||||
} catch (NumberFormatException e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
SerialPlotter.this.repaint();
|
||||
}});
|
||||
SwingUtilities.invokeLater(SerialPlotter.this::repaint);
|
||||
}
|
||||
|
||||
|
||||
public void open() throws Exception {
|
||||
super.open();
|
||||
|
||||
|
||||
if (serial != null) return;
|
||||
|
||||
serial = new Serial(getBoardPort().getAddress(), serialRate) {
|
||||
|
@ -23,32 +23,40 @@
|
||||
|
||||
package processing.app;
|
||||
|
||||
import cc.arduino.Compiler;
|
||||
import cc.arduino.CompilerProgressListener;
|
||||
import cc.arduino.UploaderUtils;
|
||||
import cc.arduino.files.DeleteFilesOnShutdown;
|
||||
import cc.arduino.packages.Uploader;
|
||||
import processing.app.debug.Compiler;
|
||||
import processing.app.debug.Compiler.ProgressListener;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import processing.app.debug.RunnerException;
|
||||
import processing.app.forms.PasswordAuthorizationDialog;
|
||||
import processing.app.helpers.FileUtils;
|
||||
import processing.app.helpers.OSUtils;
|
||||
import processing.app.helpers.PreferencesMapException;
|
||||
import processing.app.packages.LibraryList;
|
||||
import processing.app.packages.UserLibrary;
|
||||
import static processing.app.I18n._;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.io.File;
|
||||
import java.io.FilenameFilter;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static processing.app.I18n.tr;
|
||||
|
||||
|
||||
/**
|
||||
* Stores information about files in the current sketch
|
||||
*/
|
||||
public class Sketch {
|
||||
static private File tempBuildFolder;
|
||||
|
||||
private final Editor editor;
|
||||
|
||||
/** true if any of the files have been modified. */
|
||||
@ -58,7 +66,7 @@ public class Sketch {
|
||||
private int currentIndex;
|
||||
|
||||
private final SketchData data;
|
||||
|
||||
|
||||
/**
|
||||
* path is location of the main .pde file, because this is also
|
||||
* simplest to use when opening the file from the finder/explorer.
|
||||
@ -66,26 +74,6 @@ public class Sketch {
|
||||
public Sketch(Editor _editor, File file) throws IOException {
|
||||
editor = _editor;
|
||||
data = new SketchData(file);
|
||||
|
||||
// lib/build must exist when the application is started
|
||||
// it is added to the CLASSPATH by default, but if it doesn't
|
||||
// exist when the application is started, then java will remove
|
||||
// the entry from the CLASSPATH, causing Runner to fail.
|
||||
//
|
||||
/*
|
||||
tempBuildFolder = new File(TEMP_BUILD_PATH);
|
||||
if (!tempBuildFolder.exists()) {
|
||||
tempBuildFolder.mkdirs();
|
||||
Base.showError("Required folder missing",
|
||||
"A required folder was missing from \n" +
|
||||
"from your installation of Processing.\n" +
|
||||
"It has now been replaced, please restart \n" +
|
||||
"the application to complete the repair.", null);
|
||||
}
|
||||
*/
|
||||
tempBuildFolder = BaseNoGui.getBuildFolder();
|
||||
//Base.addBuildFolderToClassPath();
|
||||
|
||||
load();
|
||||
}
|
||||
|
||||
@ -129,21 +117,22 @@ public class Sketch {
|
||||
* Handler for the New Code menu option.
|
||||
*/
|
||||
public void handleNewCode() {
|
||||
editor.status.clearState();
|
||||
// make sure the user didn't hide the sketch folder
|
||||
ensureExistence();
|
||||
|
||||
// if read-only, give an error
|
||||
if (isReadOnly()) {
|
||||
if (isReadOnly(BaseNoGui.librariesIndexer.getInstalledLibraries(), BaseNoGui.getExamplesPath())) {
|
||||
// if the files are read-only, need to first do a "save as".
|
||||
Base.showMessage(_("Sketch is Read-Only"),
|
||||
_("Some files are marked \"read-only\", so you'll\n" +
|
||||
Base.showMessage(tr("Sketch is Read-Only"),
|
||||
tr("Some files are marked \"read-only\", so you'll\n" +
|
||||
"need to re-save the sketch in another location,\n" +
|
||||
"and try again."));
|
||||
return;
|
||||
}
|
||||
|
||||
renamingCode = false;
|
||||
editor.status.edit(_("Name for new file:"), "");
|
||||
editor.status.edit(tr("Name for new file:"), "");
|
||||
}
|
||||
|
||||
|
||||
@ -151,21 +140,22 @@ public class Sketch {
|
||||
* Handler for the Rename Code menu option.
|
||||
*/
|
||||
public void handleRenameCode() {
|
||||
editor.status.clearState();
|
||||
// make sure the user didn't hide the sketch folder
|
||||
ensureExistence();
|
||||
|
||||
if (currentIndex == 0 && editor.untitled) {
|
||||
Base.showMessage(_("Sketch is Untitled"),
|
||||
_("How about saving the sketch first \n" +
|
||||
Base.showMessage(tr("Sketch is Untitled"),
|
||||
tr("How about saving the sketch first \n" +
|
||||
"before trying to rename it?"));
|
||||
return;
|
||||
}
|
||||
|
||||
// if read-only, give an error
|
||||
if (isReadOnly()) {
|
||||
if (isReadOnly(BaseNoGui.librariesIndexer.getInstalledLibraries(), BaseNoGui.getExamplesPath())) {
|
||||
// if the files are read-only, need to first do a "save as".
|
||||
Base.showMessage(_("Sketch is Read-Only"),
|
||||
_("Some files are marked \"read-only\", so you'll\n" +
|
||||
Base.showMessage(tr("Sketch is Read-Only"),
|
||||
tr("Some files are marked \"read-only\", so you'll\n" +
|
||||
"need to re-save the sketch in another location,\n" +
|
||||
"and try again."));
|
||||
return;
|
||||
@ -216,16 +206,16 @@ public class Sketch {
|
||||
|
||||
int dot = newName.indexOf('.');
|
||||
if (dot == 0) {
|
||||
Base.showWarning(_("Problem with rename"),
|
||||
_("The name cannot start with a period."), null);
|
||||
Base.showWarning(tr("Problem with rename"),
|
||||
tr("The name cannot start with a period."), null);
|
||||
return;
|
||||
}
|
||||
|
||||
String newExtension = newName.substring(dot+1).toLowerCase();
|
||||
if (!validExtension(newExtension)) {
|
||||
Base.showWarning(_("Problem with rename"),
|
||||
Base.showWarning(tr("Problem with rename"),
|
||||
I18n.format(
|
||||
_("\".{0}\" is not a valid extension."), newExtension
|
||||
tr("\".{0}\" is not a valid extension."), newExtension
|
||||
), null);
|
||||
return;
|
||||
}
|
||||
@ -234,8 +224,8 @@ public class Sketch {
|
||||
if (!isDefaultExtension(newExtension)) {
|
||||
if (renamingCode) { // If creating a new tab, don't show this error
|
||||
if (current.getCode() == data.getCode(0)) { // If this is the main tab, disallow
|
||||
Base.showWarning(_("Problem with rename"),
|
||||
_("The main file can't use an extension.\n" +
|
||||
Base.showWarning(tr("Problem with rename"),
|
||||
tr("The main file can't use an extension.\n" +
|
||||
"(It may be time for your to graduate to a\n" +
|
||||
"\"real\" programming environment)"), null);
|
||||
return;
|
||||
@ -257,9 +247,9 @@ public class Sketch {
|
||||
// might cause problems: http://dev.processing.org/bugs/show_bug.cgi?id=543
|
||||
for (SketchCode c : data.getCodes()) {
|
||||
if (newName.equalsIgnoreCase(c.getFileName()) && OSUtils.isWindows()) {
|
||||
Base.showMessage(_("Nope"),
|
||||
Base.showMessage(tr("Error"),
|
||||
I18n.format(
|
||||
_("A file named \"{0}\" already exists in \"{1}\""),
|
||||
tr("A file named \"{0}\" already exists in \"{1}\""),
|
||||
c.getFileName(),
|
||||
data.getFolder().getAbsolutePath()
|
||||
));
|
||||
@ -271,8 +261,8 @@ public class Sketch {
|
||||
// because the sketch is concatenated into a file with that name as part
|
||||
// of the build process.
|
||||
if (newName.equals(getName() + ".cpp")) {
|
||||
Base.showMessage(_("Nope"),
|
||||
_("You can't have a .cpp file with the same name as the sketch."));
|
||||
Base.showMessage(tr("Error"),
|
||||
tr("You can't have a .cpp file with the same name as the sketch."));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -280,8 +270,8 @@ public class Sketch {
|
||||
for (SketchCode code : data.getCodes()) {
|
||||
if (sanitaryName.equalsIgnoreCase(code.getPrettyName()) &&
|
||||
code.isExtension("cpp")) {
|
||||
Base.showMessage(_("Nope"),
|
||||
I18n.format(_("You can't rename the sketch to \"{0}\"\n"
|
||||
Base.showMessage(tr("Error"),
|
||||
I18n.format(tr("You can't rename the sketch to \"{0}\"\n"
|
||||
+ "because the sketch already has a .cpp file with that name."),
|
||||
sanitaryName));
|
||||
return;
|
||||
@ -292,7 +282,7 @@ public class Sketch {
|
||||
|
||||
File newFile = new File(data.getFolder(), newName);
|
||||
// if (newFile.exists()) { // yay! users will try anything
|
||||
// Base.showMessage("Nope",
|
||||
// Base.showMessage("Error",
|
||||
// "A file named \"" + newFile + "\" already exists\n" +
|
||||
// "in \"" + folder.getAbsolutePath() + "\"");
|
||||
// return;
|
||||
@ -314,9 +304,9 @@ public class Sketch {
|
||||
String folderName = newName.substring(0, newName.indexOf('.'));
|
||||
File newFolder = new File(data.getFolder().getParentFile(), folderName);
|
||||
if (newFolder.exists()) {
|
||||
Base.showWarning(_("Cannot Rename"),
|
||||
Base.showWarning(tr("Cannot Rename"),
|
||||
I18n.format(
|
||||
_("Sorry, a sketch (or folder) named " +
|
||||
tr("Sorry, a sketch (or folder) named " +
|
||||
"\"{0}\" already exists."),
|
||||
newName
|
||||
), null);
|
||||
@ -334,15 +324,15 @@ public class Sketch {
|
||||
// save this new SketchCode
|
||||
current.getCode().save();
|
||||
} catch (Exception e) {
|
||||
Base.showWarning(_("Error"), _("Could not rename the sketch. (0)"), e);
|
||||
Base.showWarning(tr("Error"), tr("Could not rename the sketch. (0)"), e);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!current.getCode().renameTo(newFile)) {
|
||||
Base.showWarning(_("Error"),
|
||||
Base.showWarning(tr("Error"),
|
||||
I18n.format(
|
||||
_("Could not rename \"{0}\" to \"{1}\""),
|
||||
tr("Could not rename \"{0}\" to \"{1}\""),
|
||||
current.getCode().getFileName(),
|
||||
newFile.getName()
|
||||
), null);
|
||||
@ -355,14 +345,14 @@ public class Sketch {
|
||||
code.save();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Base.showWarning(_("Error"), _("Could not rename the sketch. (1)"), e);
|
||||
Base.showWarning(tr("Error"), tr("Could not rename the sketch. (1)"), e);
|
||||
return;
|
||||
}
|
||||
|
||||
// now rename the sketch folder and re-open
|
||||
boolean success = data.getFolder().renameTo(newFolder);
|
||||
if (!success) {
|
||||
Base.showWarning(_("Error"), _("Could not rename the sketch. (2)"), null);
|
||||
Base.showWarning(tr("Error"), tr("Could not rename the sketch. (2)"), null);
|
||||
return;
|
||||
}
|
||||
// if successful, set base properties for the sketch
|
||||
@ -384,9 +374,9 @@ public class Sketch {
|
||||
|
||||
} else { // else if something besides code[0]
|
||||
if (!current.getCode().renameTo(newFile)) {
|
||||
Base.showWarning(_("Error"),
|
||||
Base.showWarning(tr("Error"),
|
||||
I18n.format(
|
||||
_("Could not rename \"{0}\" to \"{1}\""),
|
||||
tr("Could not rename \"{0}\" to \"{1}\""),
|
||||
current.getCode().getFileName(),
|
||||
newFile.getName()
|
||||
), null);
|
||||
@ -398,10 +388,10 @@ public class Sketch {
|
||||
try {
|
||||
if (!newFile.createNewFile()) {
|
||||
// Already checking for IOException, so make our own.
|
||||
throw new IOException(_("createNewFile() returned false"));
|
||||
throw new IOException(tr("createNewFile() returned false"));
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Base.showWarning(_("Error"),
|
||||
Base.showWarning(tr("Error"),
|
||||
I18n.format(
|
||||
"Could not create the file \"{0}\" in \"{1}\"",
|
||||
newFile,
|
||||
@ -427,28 +417,29 @@ public class Sketch {
|
||||
/**
|
||||
* Remove a piece of code from the sketch and from the disk.
|
||||
*/
|
||||
public void handleDeleteCode() {
|
||||
public void handleDeleteCode() throws IOException {
|
||||
editor.status.clearState();
|
||||
// make sure the user didn't hide the sketch folder
|
||||
ensureExistence();
|
||||
|
||||
// if read-only, give an error
|
||||
if (isReadOnly()) {
|
||||
if (isReadOnly(BaseNoGui.librariesIndexer.getInstalledLibraries(), BaseNoGui.getExamplesPath())) {
|
||||
// if the files are read-only, need to first do a "save as".
|
||||
Base.showMessage(_("Sketch is Read-Only"),
|
||||
_("Some files are marked \"read-only\", so you'll\n" +
|
||||
Base.showMessage(tr("Sketch is Read-Only"),
|
||||
tr("Some files are marked \"read-only\", so you'll\n" +
|
||||
"need to re-save the sketch in another location,\n" +
|
||||
"and try again."));
|
||||
return;
|
||||
}
|
||||
|
||||
// confirm deletion with user, yes/no
|
||||
Object[] options = { _("OK"), _("Cancel") };
|
||||
Object[] options = { tr("OK"), tr("Cancel") };
|
||||
String prompt = (currentIndex == 0) ?
|
||||
_("Are you sure you want to delete this sketch?") :
|
||||
I18n.format(_("Are you sure you want to delete \"{0}\"?"), current.getCode().getFileNameWithExtensionIfNotIno());
|
||||
tr("Are you sure you want to delete this sketch?") :
|
||||
I18n.format(tr("Are you sure you want to delete \"{0}\"?"), current.getCode().getFileNameWithExtensionIfNotIno());
|
||||
int result = JOptionPane.showOptionDialog(editor,
|
||||
prompt,
|
||||
_("Delete"),
|
||||
tr("Delete"),
|
||||
JOptionPane.YES_NO_OPTION,
|
||||
JOptionPane.QUESTION_MESSAGE,
|
||||
null,
|
||||
@ -472,9 +463,9 @@ public class Sketch {
|
||||
|
||||
} else {
|
||||
// delete the file
|
||||
if (!current.getCode().deleteFile(tempBuildFolder)) {
|
||||
Base.showMessage(_("Couldn't do it"),
|
||||
I18n.format(_("Could not delete \"{0}\"."), current.getCode().getFileName()));
|
||||
if (!current.getCode().deleteFile(BaseNoGui.getBuildFolder(data))) {
|
||||
Base.showMessage(tr("Couldn't do it"),
|
||||
I18n.format(tr("Could not delete \"{0}\"."), current.getCode().getFileName()));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -534,6 +525,7 @@ public class Sketch {
|
||||
// http://developer.apple.com/qa/qa2001/qa1146.html
|
||||
Object modifiedParam = modified ? Boolean.TRUE : Boolean.FALSE;
|
||||
editor.getRootPane().putClientProperty("windowModified", modifiedParam);
|
||||
editor.getRootPane().putClientProperty("Window.documentModified", modifiedParam);
|
||||
}
|
||||
}
|
||||
|
||||
@ -558,49 +550,47 @@ public class Sketch {
|
||||
// don't do anything if not actually modified
|
||||
//if (!modified) return false;
|
||||
|
||||
if (isReadOnly()) {
|
||||
// if the files are read-only, need to first do a "save as".
|
||||
Base.showMessage(_("Sketch is read-only"),
|
||||
_("Some files are marked \"read-only\", so you'll\n" +
|
||||
"need to re-save this sketch to another location."));
|
||||
// if the user cancels, give up on the save()
|
||||
if (!saveAs()) return false;
|
||||
} else {
|
||||
// rename .pde files to .ino
|
||||
File mainFile = new File(getMainFilePath());
|
||||
File mainFolder = mainFile.getParentFile();
|
||||
File[] pdeFiles = mainFolder.listFiles((dir, name) -> {
|
||||
return name.toLowerCase().endsWith(".pde");
|
||||
});
|
||||
if (isReadOnly(BaseNoGui.librariesIndexer.getInstalledLibraries(), BaseNoGui.getExamplesPath())) {
|
||||
Base.showMessage(tr("Sketch is read-only"),
|
||||
tr("Some files are marked \"read-only\", so you'll\n" +
|
||||
"need to re-save this sketch to another location."));
|
||||
return saveAs();
|
||||
}
|
||||
|
||||
if (pdeFiles != null && pdeFiles.length > 0) {
|
||||
if (PreferencesData.get("editor.update_extension") == null) {
|
||||
Object[] options = { _("OK"), _("Cancel") };
|
||||
int result = JOptionPane.showOptionDialog(editor,
|
||||
_("In Arduino 1.0, the default file extension has changed\n" +
|
||||
"from .pde to .ino. New sketches (including those created\n" +
|
||||
"by \"Save-As\") will use the new extension. The extension\n" +
|
||||
"of existing sketches will be updated on save, but you can\n" +
|
||||
"disable this in the Preferences dialog.\n" +
|
||||
"\n" +
|
||||
"Save sketch and update its extension?"),
|
||||
_(".pde -> .ino"),
|
||||
JOptionPane.OK_CANCEL_OPTION,
|
||||
JOptionPane.QUESTION_MESSAGE,
|
||||
null,
|
||||
options,
|
||||
options[0]);
|
||||
// rename .pde files to .ino
|
||||
File mainFile = new File(getMainFilePath());
|
||||
File mainFolder = mainFile.getParentFile();
|
||||
File[] pdeFiles = mainFolder.listFiles((dir, name) -> {
|
||||
return name.toLowerCase().endsWith(".pde");
|
||||
});
|
||||
|
||||
if (result != JOptionPane.OK_OPTION) return false; // save cancelled
|
||||
if (pdeFiles != null && pdeFiles.length > 0) {
|
||||
if (PreferencesData.get("editor.update_extension") == null) {
|
||||
Object[] options = {tr("OK"), tr("Cancel")};
|
||||
int result = JOptionPane.showOptionDialog(editor,
|
||||
tr("In Arduino 1.0, the default file extension has changed\n" +
|
||||
"from .pde to .ino. New sketches (including those created\n" +
|
||||
"by \"Save-As\") will use the new extension. The extension\n" +
|
||||
"of existing sketches will be updated on save, but you can\n" +
|
||||
"disable this in the Preferences dialog.\n" +
|
||||
"\n" +
|
||||
"Save sketch and update its extension?"),
|
||||
tr(".pde -> .ino"),
|
||||
JOptionPane.OK_CANCEL_OPTION,
|
||||
JOptionPane.QUESTION_MESSAGE,
|
||||
null,
|
||||
options,
|
||||
options[0]);
|
||||
|
||||
PreferencesData.setBoolean("editor.update_extension", true);
|
||||
}
|
||||
if (result != JOptionPane.OK_OPTION) return false; // save cancelled
|
||||
|
||||
if (PreferencesData.getBoolean("editor.update_extension")) {
|
||||
// Do rename of all .pde files to new .ino extension
|
||||
for (File pdeFile : pdeFiles)
|
||||
renameCodeToInoExtension(pdeFile);
|
||||
}
|
||||
PreferencesData.setBoolean("editor.update_extension", true);
|
||||
}
|
||||
|
||||
if (PreferencesData.getBoolean("editor.update_extension")) {
|
||||
// Do rename of all .pde files to new .ino extension
|
||||
for (File pdeFile : pdeFiles)
|
||||
renameCodeToInoExtension(pdeFile);
|
||||
}
|
||||
}
|
||||
|
||||
@ -636,8 +626,8 @@ public class Sketch {
|
||||
*/
|
||||
protected boolean saveAs() throws IOException {
|
||||
// get new name for folder
|
||||
FileDialog fd = new FileDialog(editor, _("Save sketch folder as..."), FileDialog.SAVE);
|
||||
if (isReadOnly() || isUntitled()) {
|
||||
FileDialog fd = new FileDialog(editor, tr("Save sketch folder as..."), FileDialog.SAVE);
|
||||
if (isReadOnly(BaseNoGui.librariesIndexer.getInstalledLibraries(), BaseNoGui.getExamplesPath()) || isUntitled()) {
|
||||
// default to the sketchbook folder
|
||||
fd.setDirectory(BaseNoGui.getSketchbookFolder().getAbsolutePath());
|
||||
} else {
|
||||
@ -664,9 +654,9 @@ public class Sketch {
|
||||
// resaved (with the same name) to another location/folder.
|
||||
for (SketchCode code : data.getCodes()) {
|
||||
if (newName.equalsIgnoreCase(code.getPrettyName()) && code.isExtension("cpp")) {
|
||||
Base.showMessage(_("Nope"),
|
||||
Base.showMessage(tr("Error"),
|
||||
I18n.format(
|
||||
_("You can't save the sketch as \"{0}\"\n" +
|
||||
tr("You can't save the sketch as \"{0}\"\n" +
|
||||
"because the sketch already has a .cpp file with that name."),
|
||||
newName
|
||||
));
|
||||
@ -687,8 +677,8 @@ public class Sketch {
|
||||
String oldPath = data.getFolder().getCanonicalPath() + File.separator;
|
||||
|
||||
if (newPath.indexOf(oldPath) == 0) {
|
||||
Base.showWarning(_("How very Borges of you"),
|
||||
_("You cannot save the sketch into a folder\n" +
|
||||
Base.showWarning(tr("How very Borges of you"),
|
||||
tr("You cannot save the sketch into a folder\n" +
|
||||
"inside itself. This would go on forever."), null);
|
||||
return false;
|
||||
}
|
||||
@ -772,17 +762,17 @@ public class Sketch {
|
||||
ensureExistence();
|
||||
|
||||
// if read-only, give an error
|
||||
if (isReadOnly()) {
|
||||
if (isReadOnly(BaseNoGui.librariesIndexer.getInstalledLibraries(), BaseNoGui.getExamplesPath())) {
|
||||
// if the files are read-only, need to first do a "save as".
|
||||
Base.showMessage(_("Sketch is Read-Only"),
|
||||
_("Some files are marked \"read-only\", so you'll\n" +
|
||||
Base.showMessage(tr("Sketch is Read-Only"),
|
||||
tr("Some files are marked \"read-only\", so you'll\n" +
|
||||
"need to re-save the sketch in another location,\n" +
|
||||
"and try again."));
|
||||
return;
|
||||
}
|
||||
|
||||
// get a dialog, select a file to add to the sketch
|
||||
FileDialog fd = new FileDialog(editor, _("Select an image or other data file to copy to your sketch"), FileDialog.LOAD);
|
||||
FileDialog fd = new FileDialog(editor, tr("Select an image or other data file to copy to your sketch"), FileDialog.LOAD);
|
||||
fd.setVisible(true);
|
||||
|
||||
String directory = fd.getDirectory();
|
||||
@ -797,7 +787,7 @@ public class Sketch {
|
||||
boolean result = addFile(sourceFile);
|
||||
|
||||
if (result) {
|
||||
editor.statusNotice(_("One file added to the sketch."));
|
||||
editor.statusNotice(tr("One file added to the sketch."));
|
||||
PreferencesData.set("last.folder", sourceFile.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
@ -848,11 +838,11 @@ public class Sketch {
|
||||
|
||||
// check whether this file already exists
|
||||
if (destFile.exists()) {
|
||||
Object[] options = { _("OK"), _("Cancel") };
|
||||
String prompt = I18n.format(_("Replace the existing version of {0}?"), filename);
|
||||
Object[] options = { tr("OK"), tr("Cancel") };
|
||||
String prompt = I18n.format(tr("Replace the existing version of {0}?"), filename);
|
||||
int result = JOptionPane.showOptionDialog(editor,
|
||||
prompt,
|
||||
_("Replace"),
|
||||
tr("Replace"),
|
||||
JOptionPane.YES_NO_OPTION,
|
||||
JOptionPane.QUESTION_MESSAGE,
|
||||
null,
|
||||
@ -871,8 +861,8 @@ public class Sketch {
|
||||
if (replacement) {
|
||||
boolean muchSuccess = destFile.delete();
|
||||
if (!muchSuccess) {
|
||||
Base.showWarning(_("Error adding file"),
|
||||
I18n.format(_("Could not delete the existing ''{0}'' file."), filename),
|
||||
Base.showWarning(tr("Error adding file"),
|
||||
I18n.format(tr("Could not delete the existing ''{0}'' file."), filename),
|
||||
null);
|
||||
return false;
|
||||
}
|
||||
@ -880,8 +870,8 @@ public class Sketch {
|
||||
|
||||
// make sure they aren't the same file
|
||||
if ((codeExtension == null) && sourceFile.equals(destFile)) {
|
||||
Base.showWarning(_("You can't fool me"),
|
||||
_("This file has already been copied to the\n" +
|
||||
Base.showWarning(tr("You can't fool me"),
|
||||
tr("This file has already been copied to the\n" +
|
||||
"location from which where you're trying to add it.\n" +
|
||||
"I ain't not doin nuthin'."), null);
|
||||
return false;
|
||||
@ -894,8 +884,8 @@ public class Sketch {
|
||||
Base.copyFile(sourceFile, destFile);
|
||||
|
||||
} catch (IOException e) {
|
||||
Base.showWarning(_("Error adding file"),
|
||||
I18n.format(_("Could not add ''{0}'' to the sketch."), filename),
|
||||
Base.showWarning(tr("Error adding file"),
|
||||
I18n.format(tr("Could not add ''{0}'' to the sketch."), filename),
|
||||
e);
|
||||
return false;
|
||||
}
|
||||
@ -999,7 +989,15 @@ public class Sketch {
|
||||
current = (SketchCodeDocument) data.getCode(which).getMetadata();
|
||||
currentIndex = which;
|
||||
|
||||
editor.setCode(current);
|
||||
if (SwingUtilities.isEventDispatchThread()) {
|
||||
editor.setCode(current);
|
||||
} else {
|
||||
try {
|
||||
SwingUtilities.invokeAndWait(() -> editor.setCode(current));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
editor.header.rebuild();
|
||||
}
|
||||
@ -1082,8 +1080,8 @@ public class Sketch {
|
||||
* @return null if compilation failed, main class name if not
|
||||
* @throws RunnerException
|
||||
*/
|
||||
public String build(boolean verbose, boolean save) throws RunnerException, PreferencesMapException {
|
||||
return build(tempBuildFolder.getAbsolutePath(), verbose, save);
|
||||
public String build(boolean verbose, boolean save) throws RunnerException, PreferencesMapException, IOException {
|
||||
return build(BaseNoGui.getBuildFolder(data).getAbsolutePath(), verbose, save);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1095,19 +1093,36 @@ public class Sketch {
|
||||
*
|
||||
* @return null if compilation failed, main class name if not
|
||||
*/
|
||||
private String build(String buildPath, boolean verbose, boolean save) throws RunnerException, PreferencesMapException {
|
||||
private String build(String buildPath, boolean verbose, boolean save) throws RunnerException, PreferencesMapException, IOException {
|
||||
// run the preprocessor
|
||||
editor.status.progressUpdate(20);
|
||||
|
||||
ensureExistence();
|
||||
|
||||
ProgressListener pl = editor.status::progressUpdate;
|
||||
|
||||
return Compiler.build(data, buildPath, tempBuildFolder, pl, verbose, save);
|
||||
|
||||
CompilerProgressListener progressListener = editor.status::progressUpdate;
|
||||
|
||||
String pathToSketch = data.getMainFilePath();
|
||||
if (isModified()) {
|
||||
pathToSketch = saveSketchInTempFolder();
|
||||
}
|
||||
|
||||
return new Compiler(pathToSketch, data, buildPath).build(progressListener, save);
|
||||
}
|
||||
|
||||
private String saveSketchInTempFolder() throws IOException {
|
||||
File tempFolder = FileUtils.createTempFolder("arduino_", DigestUtils.md5Hex(data.getMainFilePath()));
|
||||
DeleteFilesOnShutdown.add(tempFolder);
|
||||
FileUtils.copy(getFolder(), tempFolder);
|
||||
|
||||
for (SketchCode sc : Stream.of(data.getCodes()).filter(SketchCode::isModified).collect(Collectors.toList())) {
|
||||
Files.write(Paths.get(tempFolder.getAbsolutePath(), sc.getFileName()), sc.getProgram().getBytes());
|
||||
}
|
||||
|
||||
return Paths.get(tempFolder.getAbsolutePath(), data.getPrimaryFile().getName()).toString();
|
||||
}
|
||||
|
||||
protected boolean exportApplet(boolean usingProgrammer) throws Exception {
|
||||
return exportApplet(tempBuildFolder.getAbsolutePath(), usingProgrammer);
|
||||
return exportApplet(BaseNoGui.getBuildFolder(data).getAbsolutePath(), usingProgrammer);
|
||||
}
|
||||
|
||||
|
||||
@ -1120,7 +1135,7 @@ public class Sketch {
|
||||
prepare();
|
||||
|
||||
// build the sketch
|
||||
editor.status.progressNotice(_("Compiling sketch..."));
|
||||
editor.status.progressNotice(tr("Compiling sketch..."));
|
||||
String foundName = build(appletPath, false, false);
|
||||
// (already reported) error during export, exit this function
|
||||
if (foundName == null) return false;
|
||||
@ -1134,7 +1149,7 @@ public class Sketch {
|
||||
// return false;
|
||||
// }
|
||||
|
||||
editor.status.progressNotice(_("Uploading..."));
|
||||
editor.status.progressNotice(tr("Uploading..."));
|
||||
boolean success = upload(appletPath, foundName, usingProgrammer);
|
||||
editor.status.progressUpdate(100);
|
||||
return success;
|
||||
@ -1142,17 +1157,17 @@ public class Sketch {
|
||||
|
||||
private boolean upload(String buildPath, String suggestedClassName, boolean usingProgrammer) throws Exception {
|
||||
|
||||
Uploader uploader = Compiler.getUploaderByPreferences(false);
|
||||
Uploader uploader = new UploaderUtils().getUploaderByPreferences(false);
|
||||
|
||||
boolean success = false;
|
||||
do {
|
||||
if (uploader.requiresAuthorization() && !PreferencesData.has(uploader.getAuthorizationKey())) {
|
||||
PasswordAuthorizationDialog dialog = new PasswordAuthorizationDialog(editor, _("Type board password to upload a new sketch"));
|
||||
PasswordAuthorizationDialog dialog = new PasswordAuthorizationDialog(editor, tr("Type board password to upload a new sketch"));
|
||||
dialog.setLocationRelativeTo(editor);
|
||||
dialog.setVisible(true);
|
||||
|
||||
if (dialog.isCancelled()) {
|
||||
editor.statusNotice(_("Upload cancelled"));
|
||||
editor.statusNotice(tr("Upload cancelled"));
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1161,7 +1176,7 @@ public class Sketch {
|
||||
|
||||
List<String> warningsAccumulator = new LinkedList<>();
|
||||
try {
|
||||
success = Compiler.upload(data, uploader, buildPath, suggestedClassName, usingProgrammer, false, warningsAccumulator);
|
||||
success = new UploaderUtils().upload(data, uploader, buildPath, suggestedClassName, usingProgrammer, false, warningsAccumulator);
|
||||
} finally {
|
||||
if (uploader.requiresAuthorization() && !success) {
|
||||
PreferencesData.remove(uploader.getAuthorizationKey());
|
||||
@ -1169,7 +1184,7 @@ public class Sketch {
|
||||
}
|
||||
|
||||
for (String warning : warningsAccumulator) {
|
||||
System.out.print(_("Warning"));
|
||||
System.out.print(tr("Warning"));
|
||||
System.out.print(": ");
|
||||
System.out.println(warning);
|
||||
}
|
||||
@ -1188,8 +1203,8 @@ public class Sketch {
|
||||
private void ensureExistence() {
|
||||
if (data.getFolder().exists()) return;
|
||||
|
||||
Base.showWarning(_("Sketch Disappeared"),
|
||||
_("The sketch folder has disappeared.\n " +
|
||||
Base.showWarning(tr("Sketch Disappeared"),
|
||||
tr("The sketch folder has disappeared.\n " +
|
||||
"Will attempt to re-save in the same location,\n" +
|
||||
"but anything besides the code will be lost."), null);
|
||||
try {
|
||||
@ -1202,8 +1217,8 @@ public class Sketch {
|
||||
calcModified();
|
||||
|
||||
} catch (Exception e) {
|
||||
Base.showWarning(_("Could not re-save sketch"),
|
||||
_("Could not properly re-save the sketch. " +
|
||||
Base.showWarning(tr("Could not re-save sketch"),
|
||||
tr("Could not properly re-save the sketch. " +
|
||||
"You may be in trouble at this point,\n" +
|
||||
"and it might be time to copy and paste " +
|
||||
"your code to another text editor."), e);
|
||||
@ -1216,24 +1231,24 @@ public class Sketch {
|
||||
* examples directory, or when sketches are loaded from read-only
|
||||
* volumes or folders without appropriate permissions.
|
||||
*/
|
||||
public boolean isReadOnly() {
|
||||
public boolean isReadOnly(LibraryList libraries, String examplesPath) {
|
||||
String apath = data.getFolder().getAbsolutePath();
|
||||
for (File folder : BaseNoGui.getLibrariesPath()) {
|
||||
if (apath.startsWith(folder.getAbsolutePath()))
|
||||
return true;
|
||||
}
|
||||
if (apath.startsWith(BaseNoGui.getExamplesPath()) ||
|
||||
apath.startsWith(Base.getSketchbookLibrariesPath())) {
|
||||
|
||||
Optional<UserLibrary> libraryThatIncludesSketch = libraries.stream().filter(lib -> apath.startsWith(lib.getInstalledFolder().getAbsolutePath())).findFirst();
|
||||
if (libraryThatIncludesSketch.isPresent() && !libraryThatIncludesSketch.get().onGoingDevelopment()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// canWrite() doesn't work on directories
|
||||
// } else if (!folder.canWrite()) {
|
||||
return sketchIsSystemExample(apath, examplesPath) || sketchFilesAreReadOnly();
|
||||
}
|
||||
|
||||
// check to see if each modified code file can be written to
|
||||
private boolean sketchIsSystemExample(String apath, String examplesPath) {
|
||||
return apath.startsWith(examplesPath);
|
||||
}
|
||||
|
||||
private boolean sketchFilesAreReadOnly() {
|
||||
for (SketchCode code : data.getCodes()) {
|
||||
if (code.isModified() && code.fileReadOnly() && code.fileExists()) {
|
||||
// System.err.println("found a read-only file " + code[i].file);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -1385,7 +1400,7 @@ public class Sketch {
|
||||
|
||||
if (!newName.equals(origName)) {
|
||||
String msg =
|
||||
_("The sketch name had to be modified. Sketch names can only consist\n" +
|
||||
tr("The sketch name had to be modified. Sketch names can only consist\n" +
|
||||
"of ASCII characters and numbers (but cannot start with a number).\n" +
|
||||
"They should also be less than 64 characters long.");
|
||||
System.out.println(msg);
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
// adapted from https://community.oracle.com/thread/1479784
|
||||
|
||||
package processing.app.debug;
|
||||
package processing.app;
|
||||
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.SwingUtilities;
|
@ -33,7 +33,7 @@ import java.util.HashMap;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Map;
|
||||
|
||||
import static processing.app.I18n._;
|
||||
import static processing.app.I18n.tr;
|
||||
|
||||
/**
|
||||
* Storage class for theme settings. This was separated from the Preferences
|
||||
@ -55,7 +55,7 @@ public class Theme {
|
||||
try {
|
||||
table.load(new File(BaseNoGui.getContentFile("lib"), "theme/theme.txt"));
|
||||
} catch (Exception te) {
|
||||
Base.showError(null, _("Could not read color theme settings.\n" +
|
||||
Base.showError(null, tr("Could not read color theme settings.\n" +
|
||||
"You'll need to reinstall Arduino."), te);
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ import java.net.URL;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Random;
|
||||
|
||||
import static processing.app.I18n._;
|
||||
import static processing.app.I18n.tr;
|
||||
|
||||
|
||||
/**
|
||||
@ -51,7 +51,7 @@ import static processing.app.I18n._;
|
||||
*/
|
||||
public class UpdateCheck implements Runnable {
|
||||
Base base;
|
||||
String downloadURL = _("http://www.arduino.cc/latest.txt");
|
||||
String downloadURL = tr("http://www.arduino.cc/latest.txt");
|
||||
|
||||
static final long ONE_DAY = 24 * 60 * 60 * 1000;
|
||||
|
||||
@ -101,22 +101,22 @@ public class UpdateCheck implements Runnable {
|
||||
PreferencesData.set("update.last", String.valueOf(now));
|
||||
|
||||
String prompt =
|
||||
_("A new version of Arduino is available,\n" +
|
||||
tr("A new version of Arduino is available,\n" +
|
||||
"would you like to visit the Arduino download page?");
|
||||
|
||||
if (base.activeEditor != null) {
|
||||
if (latest > BaseNoGui.REVISION) {
|
||||
Object[] options = { _("Yes"), _("No") };
|
||||
Object[] options = { tr("Yes"), tr("No") };
|
||||
int result = JOptionPane.showOptionDialog(base.activeEditor,
|
||||
prompt,
|
||||
_("Update"),
|
||||
tr("Update"),
|
||||
JOptionPane.YES_NO_OPTION,
|
||||
JOptionPane.QUESTION_MESSAGE,
|
||||
null,
|
||||
options,
|
||||
options[0]);
|
||||
if (result == JOptionPane.YES_OPTION) {
|
||||
Base.openURL(_("http://www.arduino.cc/en/Main/Software"));
|
||||
Base.openURL(tr("http://www.arduino.cc/en/Main/Software"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,233 +0,0 @@
|
||||
/*
|
||||
* ====================================================================
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package processing.app.debug;
|
||||
|
||||
import org.apache.commons.httpclient.ConnectTimeoutException;
|
||||
import org.apache.commons.httpclient.HttpClientError;
|
||||
import org.apache.commons.httpclient.params.HttpConnectionParams;
|
||||
import org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import javax.net.SocketFactory;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.SSLSocket;
|
||||
import javax.net.ssl.TrustManager;
|
||||
import java.io.IOException;
|
||||
import java.net.*;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* EasySSLProtocolSocketFactory can be used to creats SSL {@link Socket}s
|
||||
* that accept self-signed certificates.
|
||||
* </p>
|
||||
* <p>
|
||||
* This socket factory SHOULD NOT be used for productive systems
|
||||
* due to security reasons, unless it is a concious decision and
|
||||
* you are perfectly aware of security implications of accepting
|
||||
* self-signed certificates
|
||||
* </p>
|
||||
* <p/>
|
||||
* <p>
|
||||
* Example of using custom protocol socket factory for a specific host:
|
||||
* <pre>
|
||||
* Protocol easyhttps = new Protocol("https", new EasySSLProtocolSocketFactory(), 443);
|
||||
*
|
||||
* URI uri = new URI("https://localhost/", true);
|
||||
* // use relative url only
|
||||
* GetMethod httpget = new GetMethod(uri.getPathQuery());
|
||||
* HostConfiguration hc = new HostConfiguration();
|
||||
* hc.setHost(uri.getHost(), uri.getPort(), easyhttps);
|
||||
* HttpClient client = new HttpClient();
|
||||
* client.executeMethod(hc, httpget);
|
||||
* </pre>
|
||||
* </p>
|
||||
* <p>
|
||||
* Example of using custom protocol socket factory per default instead of the standard one:
|
||||
* <pre>
|
||||
* Protocol easyhttps = new Protocol("https", new EasySSLProtocolSocketFactory(), 443);
|
||||
* Protocol.registerProtocol("https", easyhttps);
|
||||
*
|
||||
* HttpClient client = new HttpClient();
|
||||
* GetMethod httpget = new GetMethod("https://localhost/");
|
||||
* client.executeMethod(httpget);
|
||||
* </pre>
|
||||
* </p>
|
||||
*
|
||||
* @author <a href="mailto:oleg -at- ural.ru">Oleg Kalnichevski</a>
|
||||
* <p/>
|
||||
* <p>
|
||||
* DISCLAIMER: HttpClient developers DO NOT actively support this component.
|
||||
* The component is provided as a reference material, which may be inappropriate
|
||||
* for use without additional customization.
|
||||
* </p>
|
||||
*/
|
||||
|
||||
public class EasySSLProtocolSocketFactory implements SecureProtocolSocketFactory {
|
||||
|
||||
/**
|
||||
* Log object for this class.
|
||||
*/
|
||||
private static final Log LOG = LogFactory.getLog(EasySSLProtocolSocketFactory.class);
|
||||
public static final String[] SSL_PROTOCOLS = {"SSLv3", "TLSv1"};
|
||||
public static final String[] SSL_CYPHER_SUITES = {"TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA", "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA", "TLS_RSA_WITH_AES_128_CBC_SHA", "TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA", "TLS_ECDH_RSA_WITH_AES_128_CBC_SHA", "TLS_DHE_RSA_WITH_AES_128_CBC_SHA", "TLS_DHE_DSS_WITH_AES_128_CBC_SHA", "TLS_ECDHE_ECDSA_WITH_RC4_128_SHA", "TLS_ECDHE_RSA_WITH_RC4_128_SHA", "SSL_RSA_WITH_RC4_128_SHA", "TLS_ECDH_ECDSA_WITH_RC4_128_SHA", "TLS_ECDH_RSA_WITH_RC4_128_SHA", "TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA", "TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA", "SSL_RSA_WITH_3DES_EDE_CBC_SHA", "TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA", "TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA", "SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA", "SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA", "SSL_RSA_WITH_RC4_128_MD5", "TLS_EMPTY_RENEGOTIATION_INFO_SCSV"};
|
||||
|
||||
private SSLContext sslcontext = null;
|
||||
|
||||
/**
|
||||
* Constructor for EasySSLProtocolSocketFactory.
|
||||
*/
|
||||
public EasySSLProtocolSocketFactory() {
|
||||
super();
|
||||
}
|
||||
|
||||
private static SSLContext createEasySSLContext() {
|
||||
try {
|
||||
SSLContext context = SSLContext.getInstance("SSL");
|
||||
context.init(
|
||||
null,
|
||||
new TrustManager[]{new EasyX509TrustManager(null)},
|
||||
null);
|
||||
return context;
|
||||
} catch (Exception e) {
|
||||
LOG.error(e.getMessage(), e);
|
||||
throw new HttpClientError(e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
private SSLContext getSSLContext() {
|
||||
if (this.sslcontext == null) {
|
||||
this.sslcontext = createEasySSLContext();
|
||||
}
|
||||
return this.sslcontext;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SecureProtocolSocketFactory#createSocket(java.lang.String, int, java.net.InetAddress, int)
|
||||
*/
|
||||
public Socket createSocket(
|
||||
String host,
|
||||
int port,
|
||||
InetAddress clientHost,
|
||||
int clientPort)
|
||||
throws IOException, UnknownHostException {
|
||||
|
||||
Socket socket = getSSLContext().getSocketFactory().createSocket(
|
||||
host,
|
||||
port,
|
||||
clientHost,
|
||||
clientPort
|
||||
);
|
||||
return socket;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to get a new socket connection to the given host within the given time limit.
|
||||
* <p>
|
||||
* To circumvent the limitations of older JREs that do not support connect timeout a
|
||||
* controller thread is executed. The controller thread attempts to create a new socket
|
||||
* within the given limit of time. If socket constructor does not return until the
|
||||
* timeout expires, the controller terminates and throws an {@link ConnectTimeoutException}
|
||||
* </p>
|
||||
*
|
||||
* @param host the host name/IP
|
||||
* @param port the port on the host
|
||||
* @param clientHost the local host name/IP to bind the socket to
|
||||
* @param clientPort the port on the local machine
|
||||
* @param params {@link HttpConnectionParams Http connection parameters}
|
||||
* @return Socket a new socket
|
||||
* @throws IOException if an I/O error occurs while creating the socket
|
||||
* @throws UnknownHostException if the IP address of the host cannot be
|
||||
* determined
|
||||
*/
|
||||
public Socket createSocket(
|
||||
final String host,
|
||||
final int port,
|
||||
final InetAddress localAddress,
|
||||
final int localPort,
|
||||
final HttpConnectionParams params
|
||||
) throws IOException, UnknownHostException, ConnectTimeoutException {
|
||||
if (params == null) {
|
||||
throw new IllegalArgumentException("Parameters may not be null");
|
||||
}
|
||||
int timeout = params.getConnectionTimeout();
|
||||
SocketFactory socketfactory = getSSLContext().getSocketFactory();
|
||||
Socket socket;
|
||||
if (timeout == 0) {
|
||||
socket = socketfactory.createSocket(host, port, localAddress, localPort);
|
||||
} else {
|
||||
socket = socketfactory.createSocket();
|
||||
SocketAddress localaddr = new InetSocketAddress(localAddress, localPort);
|
||||
SocketAddress remoteaddr = new InetSocketAddress(host, port);
|
||||
socket.bind(localaddr);
|
||||
socket.connect(remoteaddr, timeout);
|
||||
}
|
||||
|
||||
SSLSocket sslSocket = (SSLSocket) socket;
|
||||
sslSocket.setEnabledProtocols(SSL_PROTOCOLS);
|
||||
sslSocket.setEnabledCipherSuites(SSL_CYPHER_SUITES);
|
||||
|
||||
return socket;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SecureProtocolSocketFactory#createSocket(java.lang.String, int)
|
||||
*/
|
||||
public Socket createSocket(String host, int port)
|
||||
throws IOException, UnknownHostException {
|
||||
return getSSLContext().getSocketFactory().createSocket(
|
||||
host,
|
||||
port
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SecureProtocolSocketFactory#createSocket(java.net.Socket, java.lang.String, int, boolean)
|
||||
*/
|
||||
public Socket createSocket(
|
||||
Socket socket,
|
||||
String host,
|
||||
int port,
|
||||
boolean autoClose)
|
||||
throws IOException, UnknownHostException {
|
||||
return getSSLContext().getSocketFactory().createSocket(
|
||||
socket,
|
||||
host,
|
||||
port,
|
||||
autoClose
|
||||
);
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
return ((obj != null) && obj.getClass().equals(EasySSLProtocolSocketFactory.class));
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return EasySSLProtocolSocketFactory.class.hashCode();
|
||||
}
|
||||
|
||||
}
|
@ -1,114 +0,0 @@
|
||||
/*
|
||||
* ====================================================================
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package processing.app.debug;
|
||||
|
||||
import java.security.KeyStore;
|
||||
import java.security.KeyStoreException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.security.cert.X509Certificate;
|
||||
|
||||
import javax.net.ssl.TrustManagerFactory;
|
||||
import javax.net.ssl.TrustManager;
|
||||
import javax.net.ssl.X509TrustManager;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* EasyX509TrustManager unlike default {@link X509TrustManager} accepts
|
||||
* self-signed certificates.
|
||||
* </p>
|
||||
* <p>
|
||||
* This trust manager SHOULD NOT be used for productive systems
|
||||
* due to security reasons, unless it is a concious decision and
|
||||
* you are perfectly aware of security implications of accepting
|
||||
* self-signed certificates
|
||||
* </p>
|
||||
*
|
||||
* @author <a href="mailto:adrian.sutton@ephox.com">Adrian Sutton</a>
|
||||
* @author <a href="mailto:oleg@ural.ru">Oleg Kalnichevski</a>
|
||||
*
|
||||
* <p>
|
||||
* DISCLAIMER: HttpClient developers DO NOT actively support this component.
|
||||
* The component is provided as a reference material, which may be inappropriate
|
||||
* for use without additional customization.
|
||||
* </p>
|
||||
*/
|
||||
|
||||
public class EasyX509TrustManager implements X509TrustManager
|
||||
{
|
||||
private X509TrustManager standardTrustManager = null;
|
||||
|
||||
/** Log object for this class. */
|
||||
private static final Log LOG = LogFactory.getLog(EasyX509TrustManager.class);
|
||||
|
||||
/**
|
||||
* Constructor for EasyX509TrustManager.
|
||||
*/
|
||||
public EasyX509TrustManager(KeyStore keystore) throws NoSuchAlgorithmException, KeyStoreException {
|
||||
super();
|
||||
TrustManagerFactory factory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
|
||||
factory.init(keystore);
|
||||
TrustManager[] trustmanagers = factory.getTrustManagers();
|
||||
if (trustmanagers.length == 0) {
|
||||
throw new NoSuchAlgorithmException("no trust manager found");
|
||||
}
|
||||
this.standardTrustManager = (X509TrustManager)trustmanagers[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.net.ssl.X509TrustManager#checkClientTrusted(X509Certificate[],String authType)
|
||||
*/
|
||||
public void checkClientTrusted(X509Certificate[] certificates,String authType) throws CertificateException {
|
||||
standardTrustManager.checkClientTrusted(certificates,authType);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.net.ssl.X509TrustManager#checkServerTrusted(X509Certificate[],String authType)
|
||||
*/
|
||||
public void checkServerTrusted(X509Certificate[] certificates,String authType) throws CertificateException {
|
||||
if ((certificates != null) && LOG.isDebugEnabled()) {
|
||||
LOG.debug("Server certificate chain:");
|
||||
for (int i = 0; i < certificates.length; i++) {
|
||||
LOG.debug("X509Certificate[" + i + "]=" + certificates[i]);
|
||||
}
|
||||
}
|
||||
if ((certificates != null) && (certificates.length == 1)) {
|
||||
certificates[0].checkValidity();
|
||||
} else {
|
||||
standardTrustManager.checkServerTrusted(certificates,authType);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.net.ssl.X509TrustManager#getAcceptedIssuers()
|
||||
*/
|
||||
public X509Certificate[] getAcceptedIssuers() {
|
||||
return this.standardTrustManager.getAcceptedIssuers();
|
||||
}
|
||||
}
|
@ -1,62 +0,0 @@
|
||||
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2004-08 Ben Fry and Casey Reas
|
||||
Copyright (c) 2001-04 Massachusetts Institute of Technology
|
||||
|
||||
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 USA
|
||||
*/
|
||||
|
||||
package processing.app.debug;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
|
||||
/**
|
||||
* OutputStream to handle stdout/stderr messages.
|
||||
* <P>
|
||||
* This is used by Editor, System.err is set to
|
||||
* new PrintStream(new MessageStream()).
|
||||
* It's also used by Compiler.
|
||||
*/
|
||||
class MessageStream extends OutputStream {
|
||||
|
||||
MessageConsumer messageConsumer;
|
||||
|
||||
public MessageStream(MessageConsumer messageConsumer) {
|
||||
this.messageConsumer = messageConsumer;
|
||||
}
|
||||
|
||||
public void close() { }
|
||||
|
||||
public void flush() { }
|
||||
|
||||
public void write(byte b[]) {
|
||||
// this never seems to get called
|
||||
System.out.println("leech1: " + new String(b));
|
||||
}
|
||||
|
||||
public void write(byte b[], int offset, int length) {
|
||||
//System.out.println("leech2: " + new String(b));
|
||||
this.messageConsumer.message(new String(b, offset, length));
|
||||
}
|
||||
|
||||
public void write(int b) {
|
||||
// this never seems to get called
|
||||
System.out.println("leech3: '" + ((char)b) + "'");
|
||||
}
|
||||
}
|
@ -8,7 +8,7 @@ import java.awt.event.ActionEvent;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.io.File;
|
||||
|
||||
import static processing.app.I18n._;
|
||||
import static processing.app.I18n.tr;
|
||||
|
||||
public class PasswordAuthorizationDialog extends JDialog {
|
||||
|
||||
@ -36,15 +36,15 @@ public class PasswordAuthorizationDialog extends JDialog {
|
||||
|
||||
icon.setIcon(new ImageIcon(new File(Base.getContentFile("lib"), "theme/lock.png").getAbsolutePath()));
|
||||
|
||||
passwordLabel.setText(_("Password:"));
|
||||
passwordLabel.setText(tr("Password:"));
|
||||
|
||||
passwordField.setText("");
|
||||
passwordField.addActionListener(PasswordAuthorizationDialog.this::uploadButtonPressed);
|
||||
|
||||
uploadButton.setText(_("Upload"));
|
||||
uploadButton.setText(tr("Upload"));
|
||||
uploadButton.addActionListener(PasswordAuthorizationDialog.this::uploadButtonPressed);
|
||||
|
||||
cancelButton.setText(_("Cancel"));
|
||||
cancelButton.setText(tr("Cancel"));
|
||||
cancelButton.addActionListener(PasswordAuthorizationDialog.this::cancelButtonPressed);
|
||||
|
||||
Base.registerWindowCloseKeys(getRootPane(), this::cancelButtonPressed);
|
||||
|
@ -3,77 +3,74 @@ package processing.app.helpers;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
public class CircularBuffer {
|
||||
private double[] elements;
|
||||
|
||||
private final double[] elements;
|
||||
private int start = -1;
|
||||
private int end = -1;
|
||||
private int capacity;
|
||||
|
||||
private final int capacity;
|
||||
|
||||
public void add(double num) {
|
||||
end = (end + 1) % capacity;
|
||||
elements[end] = num;
|
||||
if(start == end || start == -1) {
|
||||
if (start == end || start == -1) {
|
||||
start = (start + 1) % capacity;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public double get(int index) {
|
||||
if(index >= capacity) {
|
||||
if (index >= capacity) {
|
||||
throw new IndexOutOfBoundsException();
|
||||
}
|
||||
if(index >= size()) {
|
||||
if (index >= size()) {
|
||||
throw new IndexOutOfBoundsException();
|
||||
}
|
||||
|
||||
|
||||
return elements[(start + index) % capacity];
|
||||
}
|
||||
|
||||
|
||||
public boolean isEmpty() {
|
||||
return start == -1 && end == -1;
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
start = end = -1;
|
||||
}
|
||||
|
||||
|
||||
public CircularBuffer(int capacity) {
|
||||
this.capacity = capacity;
|
||||
elements = new double[capacity];
|
||||
}
|
||||
|
||||
|
||||
public double min() {
|
||||
if(size() == 0) {
|
||||
if (size() == 0) {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
|
||||
|
||||
double out = get(0);
|
||||
for(int i = 1; i < size(); ++i) {
|
||||
for (int i = 1; i < size(); ++i) {
|
||||
out = Math.min(out, get(i));
|
||||
}
|
||||
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
public double max() {
|
||||
if(size() == 0) {
|
||||
if (size() == 0) {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
|
||||
|
||||
double out = get(0);
|
||||
for(int i = 1; i < size(); ++i) {
|
||||
for (int i = 1; i < size(); ++i) {
|
||||
out = Math.max(out, get(i));
|
||||
}
|
||||
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
public int size() {
|
||||
if(end == -1) {
|
||||
if (end == -1) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
return (end - start + capacity) % capacity + 1;
|
||||
}
|
||||
|
||||
|
||||
public int capacity() {
|
||||
return capacity;
|
||||
}
|
||||
|
@ -2,9 +2,7 @@ package processing.app.helpers;
|
||||
|
||||
import processing.app.Base;
|
||||
|
||||
import static processing.app.I18n._;
|
||||
|
||||
import java.awt.Frame;
|
||||
import static processing.app.I18n.tr;
|
||||
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
@ -22,7 +20,7 @@ public class GUIUserNotifier extends UserNotifier {
|
||||
* for errors that allow P5 to continue running.
|
||||
*/
|
||||
public void showError(String title, String message, Throwable e, int exit_code) {
|
||||
if (title == null) title = _("Error");
|
||||
if (title == null) title = tr("Error");
|
||||
|
||||
JOptionPane.showMessageDialog(base.getActiveEditor(), message, title,
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
@ -36,7 +34,7 @@ public class GUIUserNotifier extends UserNotifier {
|
||||
* much of a bummer, but something to notify the user about.
|
||||
*/
|
||||
public void showMessage(String title, String message) {
|
||||
if (title == null) title = _("Message");
|
||||
if (title == null) title = tr("Message");
|
||||
|
||||
JOptionPane.showMessageDialog(base.getActiveEditor(), message, title,
|
||||
JOptionPane.INFORMATION_MESSAGE);
|
||||
@ -46,7 +44,7 @@ public class GUIUserNotifier extends UserNotifier {
|
||||
* Non-fatal error message with optional stack trace side dish.
|
||||
*/
|
||||
public void showWarning(String title, String message, Exception e) {
|
||||
if (title == null) title = _("Warning");
|
||||
if (title == null) title = tr("Warning");
|
||||
|
||||
JOptionPane.showMessageDialog(base.getActiveEditor(), message, title,
|
||||
JOptionPane.WARNING_MESSAGE);
|
||||
|
@ -1,45 +1,50 @@
|
||||
package processing.app.helpers;
|
||||
|
||||
public class Ticks {
|
||||
|
||||
private final int tickCount;
|
||||
private final double[] ticks;
|
||||
private double tickMin;
|
||||
private double tickMax;
|
||||
private double tickStep;
|
||||
private int tickCount;
|
||||
|
||||
private double[] ticks;
|
||||
|
||||
public Ticks(double min, double max, int tickCount) {
|
||||
|
||||
public Ticks(double min, double max, int tickCount) {
|
||||
double range = max - min;
|
||||
double exp = Math.floor(Math.log10(range / (tickCount - 1)));
|
||||
double exp;
|
||||
if (range == 0.0) {
|
||||
exp = 0;
|
||||
} else {
|
||||
exp = Math.floor(Math.log10(range / (tickCount - 1)));
|
||||
}
|
||||
double scale = Math.pow(10, exp);
|
||||
|
||||
|
||||
double rawTickStep = (range / (tickCount - 1)) / scale;
|
||||
for(double potentialStep : new double[] {1.0, 1.5, 2.0, 2.5, 3.0, 4.0, 5.0, 6.0, 8.0, 10.0}) {
|
||||
if(potentialStep < rawTickStep) {
|
||||
for (double potentialStep : new double[]{1.0, 1.5, 2.0, 2.5, 3.0, 4.0, 5.0, 6.0, 8.0, 10.0}) {
|
||||
if (potentialStep < rawTickStep) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
tickStep = potentialStep * scale;
|
||||
tickMin = tickStep * Math.floor(min / tickStep);
|
||||
tickMax = tickMin + tickStep * (tickCount - 1);
|
||||
if(tickMax >= max) {
|
||||
if (tickMax >= max) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
tickCount -= (int)Math.floor((tickMax - max) / tickStep);
|
||||
|
||||
tickCount -= (int) Math.floor((tickMax - max) / tickStep);
|
||||
this.tickCount = tickCount;
|
||||
|
||||
|
||||
ticks = new double[tickCount];
|
||||
for(int i = 0; i < tickCount; ++i) {
|
||||
for (int i = 0; i < tickCount; ++i) {
|
||||
ticks[i] = tickMin + i * tickStep;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public double getTick(int i) {
|
||||
return ticks[i];
|
||||
}
|
||||
|
||||
|
||||
public int getTickCount() {
|
||||
return tickCount;
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ import org.fife.ui.rsyntaxtextarea.TokenTypes;
|
||||
import processing.app.Base;
|
||||
import processing.app.BaseNoGui;
|
||||
import processing.app.legacy.PApplet;
|
||||
import processing.app.debug.TargetPlatform;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
@ -43,7 +44,7 @@ import java.util.regex.Pattern;
|
||||
|
||||
public class PdeKeywords {
|
||||
|
||||
private static final Map<String, Integer> KNOWN_TOKEN_TYPES = new HashMap<String, Integer>();
|
||||
private static final Map<String, Integer> KNOWN_TOKEN_TYPES = new HashMap<>();
|
||||
private static final Pattern ALPHA = Pattern.compile("\\w");
|
||||
|
||||
static {
|
||||
@ -54,6 +55,7 @@ public class PdeKeywords {
|
||||
KNOWN_TOKEN_TYPES.put("DATA_TYPE", TokenTypes.DATA_TYPE);
|
||||
KNOWN_TOKEN_TYPES.put("LITERAL_BOOLEAN", TokenTypes.LITERAL_BOOLEAN);
|
||||
KNOWN_TOKEN_TYPES.put("LITERAL_CHAR", TokenTypes.LITERAL_CHAR);
|
||||
KNOWN_TOKEN_TYPES.put("PREPROCESSOR", TokenTypes.PREPROCESSOR);
|
||||
}
|
||||
|
||||
// lookup table for the TokenMarker subclass, handles coloring
|
||||
@ -66,9 +68,9 @@ public class PdeKeywords {
|
||||
|
||||
public PdeKeywords() {
|
||||
this.keywordTokenType = new TokenMap();
|
||||
this.keywordOldToken = new HashMap<String, String>();
|
||||
this.keywordTokenTypeAsString = new HashMap<String, String>();
|
||||
this.keywordToReference = new HashMap<String, String>();
|
||||
this.keywordOldToken = new HashMap<>();
|
||||
this.keywordTokenTypeAsString = new HashMap<>();
|
||||
this.keywordToReference = new HashMap<>();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -83,6 +85,11 @@ public class PdeKeywords {
|
||||
public void reload() {
|
||||
try {
|
||||
parseKeywordsTxt(new File(BaseNoGui.getContentFile("lib"), "keywords.txt"));
|
||||
TargetPlatform tp = BaseNoGui.getTargetPlatform();
|
||||
if (tp != null) {
|
||||
File platformKeywords = new File(tp.getFolder(), "keywords.txt");
|
||||
if (platformKeywords.exists()) parseKeywordsTxt(platformKeywords);
|
||||
}
|
||||
for (ContributedLibrary lib : Base.getLibraries()) {
|
||||
File keywords = new File(lib.getInstalledFolder(), "keywords.txt");
|
||||
if (keywords.exists()) {
|
||||
@ -112,6 +119,9 @@ public class PdeKeywords {
|
||||
String pieces[] = PApplet.split(line, '\t');
|
||||
|
||||
String keyword = pieces[0].trim();
|
||||
if (keyword.startsWith("\\#")) {
|
||||
keyword = keyword.replace("\\#", "#");
|
||||
}
|
||||
|
||||
if (pieces.length >= 2) {
|
||||
keywordOldToken.put(keyword, pieces[1]);
|
||||
|
@ -74,13 +74,18 @@ public class SketchTextArea extends RSyntaxTextArea {
|
||||
|
||||
private EditorListener editorListener;
|
||||
|
||||
private final PdeKeywords pdeKeywords;
|
||||
private PdeKeywords pdeKeywords;
|
||||
|
||||
public SketchTextArea(PdeKeywords pdeKeywords) throws IOException {
|
||||
this.pdeKeywords = pdeKeywords;
|
||||
installFeatures();
|
||||
}
|
||||
|
||||
public void setKeywords(PdeKeywords keywords) {
|
||||
pdeKeywords = keywords;
|
||||
setLinkGenerator(new DocLinkGenerator(pdeKeywords));
|
||||
}
|
||||
|
||||
private void installFeatures() throws IOException {
|
||||
setTheme(PreferencesData.get("editor.syntax_theme", "default"));
|
||||
|
||||
@ -101,6 +106,7 @@ public class SketchTextArea extends RSyntaxTextArea {
|
||||
IOUtils.closeQuietly(defaultXmlInputStream);
|
||||
}
|
||||
|
||||
setEOLMarkersVisible(processing.app.Theme.getBoolean("editor.eolmarkers"));
|
||||
setBackground(processing.app.Theme.getColor("editor.bgcolor"));
|
||||
setHighlightCurrentLine(processing.app.Theme.getBoolean("editor.linehighlight"));
|
||||
setCurrentLineHighlightColor(processing.app.Theme.getColor("editor.linehighlight.color"));
|
||||
@ -125,10 +131,16 @@ public class SketchTextArea extends RSyntaxTextArea {
|
||||
setSyntaxTheme(TokenTypes.LITERAL_BOOLEAN, "literal_boolean");
|
||||
setSyntaxTheme(TokenTypes.LITERAL_CHAR, "literal_char");
|
||||
setSyntaxTheme(TokenTypes.LITERAL_STRING_DOUBLE_QUOTE, "literal_string_double_quote");
|
||||
setSyntaxTheme(TokenTypes.PREPROCESSOR, "preprocessor");
|
||||
|
||||
Style style = getSyntaxScheme().getStyle(TokenTypes.IDENTIFIER);
|
||||
style.foreground = processing.app.Theme.getColor("editor.fgcolor");
|
||||
getSyntaxScheme().setStyle(TokenTypes.IDENTIFIER, style);
|
||||
setColorForToken(TokenTypes.IDENTIFIER, "editor.fgcolor");
|
||||
setColorForToken(TokenTypes.WHITESPACE, "editor.eolmarkers.color");
|
||||
}
|
||||
|
||||
private void setColorForToken(int tokenType, String colorKeyFromTheme) {
|
||||
Style style = getSyntaxScheme().getStyle(tokenType);
|
||||
style.foreground = processing.app.Theme.getColor(colorKeyFromTheme);
|
||||
getSyntaxScheme().setStyle(tokenType, style);
|
||||
}
|
||||
|
||||
private void setSyntaxTheme(int tokenType, String id) {
|
||||
|
@ -15,6 +15,7 @@ public class SketchTextAreaDefaultInputMap extends RSyntaxTextAreaDefaultInputMa
|
||||
|
||||
public SketchTextAreaDefaultInputMap() {
|
||||
int defaultModifier = getDefaultModifier();
|
||||
int ctrl = InputEvent.CTRL_MASK;
|
||||
int alt = InputEvent.ALT_MASK;
|
||||
int shift = InputEvent.SHIFT_MASK;
|
||||
boolean isOSX = RTextArea.isOSX();
|
||||
@ -49,6 +50,14 @@ public class SketchTextAreaDefaultInputMap extends RSyntaxTextAreaDefaultInputMa
|
||||
|
||||
put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, defaultModifier | shift), DefaultEditorKit.selectionBeginAction);
|
||||
put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, defaultModifier | shift), DefaultEditorKit.selectionEndAction);
|
||||
|
||||
if (!PreferencesData.getBoolean("editor.keys.home_and_end_beginning_end_of_doc")) {
|
||||
put(KeyStroke.getKeyStroke(KeyEvent.VK_HOME, 0), DefaultEditorKit.beginLineAction);
|
||||
put(KeyStroke.getKeyStroke(KeyEvent.VK_END, 0), DefaultEditorKit.endLineAction);
|
||||
}
|
||||
|
||||
put(KeyStroke.getKeyStroke(KeyEvent.VK_A, ctrl), DefaultEditorKit.beginLineAction);
|
||||
put(KeyStroke.getKeyStroke(KeyEvent.VK_E, ctrl), DefaultEditorKit.endLineAction);
|
||||
}
|
||||
|
||||
put(KeyStroke.getKeyStroke(KeyEvent.VK_DIVIDE, defaultModifier), RSyntaxTextAreaEditorKit.rstaToggleCommentAction);
|
||||
|
@ -1,5 +1,6 @@
|
||||
package processing.app.syntax;
|
||||
|
||||
import org.fife.ui.rsyntaxtextarea.RSyntaxDocument;
|
||||
import org.fife.ui.rsyntaxtextarea.RSyntaxTextAreaEditorKit;
|
||||
import org.fife.ui.rtextarea.RTextArea;
|
||||
import org.fife.ui.rtextarea.RecordableTextAction;
|
||||
@ -16,7 +17,8 @@ public class SketchTextAreaEditorKit extends RSyntaxTextAreaEditorKit {
|
||||
private static final Action[] defaultActions = {
|
||||
new DeleteNextWordAction(),
|
||||
new DeleteLineToCursorAction(),
|
||||
new SelectWholeLineAction()
|
||||
new SelectWholeLineAction(),
|
||||
new ToggleCommentAction()
|
||||
};
|
||||
|
||||
@Override
|
||||
@ -126,4 +128,103 @@ public class SketchTextAreaEditorKit extends RSyntaxTextAreaEditorKit {
|
||||
|
||||
}
|
||||
|
||||
public static class ToggleCommentAction extends RecordableTextAction {
|
||||
|
||||
public ToggleCommentAction() {
|
||||
super(rstaToggleCommentAction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformedImpl(ActionEvent e, RTextArea textArea) {
|
||||
|
||||
if (!textArea.isEditable() || !textArea.isEnabled()) {
|
||||
UIManager.getLookAndFeel().provideErrorFeedback(textArea);
|
||||
return;
|
||||
}
|
||||
|
||||
RSyntaxDocument doc = (RSyntaxDocument) textArea.getDocument();
|
||||
Element map = doc.getDefaultRootElement();
|
||||
Caret c = textArea.getCaret();
|
||||
int dot = c.getDot();
|
||||
int mark = c.getMark();
|
||||
int line1 = map.getElementIndex(dot);
|
||||
int line2 = map.getElementIndex(mark);
|
||||
int start = Math.min(line1, line2);
|
||||
int end = Math.max(line1, line2);
|
||||
|
||||
org.fife.ui.rsyntaxtextarea.Token t = doc.getTokenListForLine(start);
|
||||
int languageIndex = t != null ? t.getLanguageIndex() : 0;
|
||||
String[] startEnd = doc.getLineCommentStartAndEnd(languageIndex);
|
||||
|
||||
if (startEnd == null) {
|
||||
UIManager.getLookAndFeel().provideErrorFeedback(textArea);
|
||||
return;
|
||||
}
|
||||
|
||||
// Don't toggle comment on last line if there is no
|
||||
// text selected on it.
|
||||
if (start != end) {
|
||||
Element elem = map.getElement(end);
|
||||
if (Math.max(dot, mark) == elem.getStartOffset()) {
|
||||
end--;
|
||||
}
|
||||
}
|
||||
|
||||
textArea.beginAtomicEdit();
|
||||
try {
|
||||
boolean add = getDoAdd(doc, map, start, end, startEnd);
|
||||
for (line1 = start; line1 <= end; line1++) {
|
||||
Element elem = map.getElement(line1);
|
||||
handleToggleComment(elem, doc, startEnd, add);
|
||||
}
|
||||
} catch (BadLocationException ble) {
|
||||
ble.printStackTrace();
|
||||
UIManager.getLookAndFeel().provideErrorFeedback(textArea);
|
||||
} finally {
|
||||
textArea.endAtomicEdit();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private boolean getDoAdd(Document doc, Element map, int startLine, int endLine, String[] startEnd) throws BadLocationException {
|
||||
boolean doAdd = false;
|
||||
for (int i = startLine; i <= endLine; i++) {
|
||||
Element elem = map.getElement(i);
|
||||
int start = elem.getStartOffset();
|
||||
String t = doc.getText(start, elem.getEndOffset() - start - 1).trim();
|
||||
if (!t.startsWith(startEnd[0]) ||
|
||||
(startEnd[1] != null && !t.endsWith(startEnd[1]))) {
|
||||
doAdd = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return doAdd;
|
||||
}
|
||||
|
||||
private void handleToggleComment(Element elem, Document doc, String[] startEnd, boolean add) throws BadLocationException {
|
||||
int start = elem.getStartOffset();
|
||||
int end = elem.getEndOffset() - 1;
|
||||
if (add) {
|
||||
doc.insertString(start, startEnd[0], null);
|
||||
if (startEnd[1] != null) {
|
||||
doc.insertString(end + startEnd[0].length(), startEnd[1], null);
|
||||
}
|
||||
} else {
|
||||
String text = doc.getText(start, elem.getEndOffset() - start - 1);
|
||||
start += text.indexOf(startEnd[0]);
|
||||
doc.remove(start, startEnd[0].length());
|
||||
if (startEnd[1] != null) {
|
||||
int temp = startEnd[1].length();
|
||||
doc.remove(end - startEnd[0].length() - temp, temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String getMacroID() {
|
||||
return rstaToggleCommentAction;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -30,8 +30,12 @@
|
||||
|
||||
package processing.app.syntax;
|
||||
|
||||
import org.fife.ui.rsyntaxtextarea.TokenTypes;
|
||||
import org.fife.ui.rsyntaxtextarea.modes.CPlusPlusTokenMaker;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Controls the syntax highlighting of {@link SketchTextArea} based on the {@link PdeKeywords}
|
||||
*
|
||||
@ -41,6 +45,8 @@ import org.fife.ui.rsyntaxtextarea.modes.CPlusPlusTokenMaker;
|
||||
*/
|
||||
public class SketchTokenMaker extends CPlusPlusTokenMaker {
|
||||
|
||||
private static final List<Integer> COMMENT_TOKEN_TYPES = Arrays.asList(TokenTypes.COMMENT_DOCUMENTATION, TokenTypes.COMMENT_EOL, TokenTypes.COMMENT_KEYWORD, TokenTypes.COMMENT_MARKUP, TokenTypes.COMMENT_MULTILINE);
|
||||
|
||||
private final PdeKeywords pdeKeywords;
|
||||
|
||||
public SketchTokenMaker(PdeKeywords pdeKeywords) {
|
||||
@ -54,6 +60,11 @@ public class SketchTokenMaker extends CPlusPlusTokenMaker {
|
||||
return;
|
||||
}
|
||||
|
||||
if (COMMENT_TOKEN_TYPES.contains(tokenType)) {
|
||||
super.addToken(array, start, end, tokenType, startOffset, hyperlink);
|
||||
return;
|
||||
}
|
||||
|
||||
// This assumes all of your extra tokens would normally be scanned as IDENTIFIER.
|
||||
int newType = pdeKeywords.getTokenType(array, start, end);
|
||||
if (newType > -1) {
|
||||
|
@ -38,7 +38,7 @@ import java.util.Date;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
import static processing.app.I18n._;
|
||||
import static processing.app.I18n.tr;
|
||||
|
||||
|
||||
public class Archiver implements Tool {
|
||||
@ -53,7 +53,7 @@ public class Archiver implements Tool {
|
||||
|
||||
|
||||
public String getMenuTitle() {
|
||||
return _("Archive Sketch");
|
||||
return tr("Archive Sketch");
|
||||
}
|
||||
|
||||
|
||||
@ -79,8 +79,8 @@ public class Archiver implements Tool {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (!success) {
|
||||
Base.showWarning(_("Couldn't archive sketch"),
|
||||
_("Archiving the sketch has been canceled because\nthe sketch couldn't save properly."), null);
|
||||
Base.showWarning(tr("Couldn't archive sketch"),
|
||||
tr("Archiving the sketch has been canceled because\nthe sketch couldn't save properly."), null);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -113,7 +113,7 @@ public class Archiver implements Tool {
|
||||
} while (newbie.exists());
|
||||
|
||||
// open up a prompt for where to save this fella
|
||||
FileDialog fd = new FileDialog(editor, _("Archive sketch as:"), FileDialog.SAVE);
|
||||
FileDialog fd = new FileDialog(editor, tr("Archive sketch as:"), FileDialog.SAVE);
|
||||
fd.setDirectory(parent.getAbsolutePath());
|
||||
fd.setFile(newbie.getName());
|
||||
fd.setVisible(true);
|
||||
@ -142,7 +142,7 @@ public class Archiver implements Tool {
|
||||
IOUtils.closeQuietly(zos);
|
||||
}
|
||||
} else {
|
||||
editor.statusNotice(_("Archive sketch canceled."));
|
||||
editor.statusNotice(tr("Archive sketch canceled."));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -143,7 +143,7 @@ public class DiscourseFormat {
|
||||
} else if (c == '&') {
|
||||
buffer.append("&");
|
||||
} else if (c > 127) {
|
||||
buffer.append("&#" + ((int) c) + ";"); // use unicode entity
|
||||
buffer.append("&#").append((int) c).append(";"); // use unicode entity
|
||||
} else {
|
||||
buffer.append(c); // normal character
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ import javax.swing.JOptionPane;
|
||||
|
||||
import org.apache.commons.compress.utils.IOUtils;
|
||||
import processing.app.*;
|
||||
import static processing.app.I18n._;
|
||||
import static processing.app.I18n.tr;
|
||||
|
||||
|
||||
public class FixEncoding implements Tool {
|
||||
@ -39,7 +39,7 @@ public class FixEncoding implements Tool {
|
||||
|
||||
|
||||
public String getMenuTitle() {
|
||||
return _("Fix Encoding & Reload");
|
||||
return tr("Fix Encoding & Reload");
|
||||
}
|
||||
|
||||
|
||||
@ -55,8 +55,8 @@ public class FixEncoding implements Tool {
|
||||
if (sketch.isModified()) {
|
||||
int result =
|
||||
JOptionPane.showConfirmDialog(editor,
|
||||
_("Discard all changes and reload sketch?"),
|
||||
_("Fix Encoding & Reload"),
|
||||
tr("Discard all changes and reload sketch?"),
|
||||
tr("Fix Encoding & Reload"),
|
||||
JOptionPane.YES_NO_OPTION,
|
||||
JOptionPane.QUESTION_MESSAGE);
|
||||
|
||||
@ -75,9 +75,9 @@ public class FixEncoding implements Tool {
|
||||
|
||||
} catch (IOException e) {
|
||||
String msg =
|
||||
_("An error occurred while trying to fix the file encoding.\nDo not attempt to save this sketch as it may overwrite\nthe old version. Use Open to re-open the sketch and try again.\n") +
|
||||
tr("An error occurred while trying to fix the file encoding.\nDo not attempt to save this sketch as it may overwrite\nthe old version. Use Open to re-open the sketch and try again.\n") +
|
||||
e.getMessage();
|
||||
Base.showWarning(_("Fix Encoding & Reload"), msg, e);
|
||||
Base.showWarning(tr("Fix Encoding & Reload"), msg, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -31,14 +31,11 @@ import processing.app.Editor;
|
||||
*/
|
||||
public interface Tool extends Runnable {
|
||||
|
||||
public void init(Editor editor);
|
||||
|
||||
public void run();
|
||||
void init(Editor editor);
|
||||
|
||||
// Not doing shortcuts for now, no way to resolve between tools.
|
||||
// Also would need additional modifiers for shift and alt.
|
||||
//public char getShortcutKey();
|
||||
void run();
|
||||
|
||||
String getMenuTitle();
|
||||
|
||||
public String getMenuTitle();
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ public class GzippedJsonDownloaderTest {
|
||||
|
||||
@Test
|
||||
public void testJsonDownload() throws Exception {
|
||||
new GZippedJsonDownloader(downloader, new URL("http://downloads.arduino.cc/libraries/library_index.json"), new URL("http://downloads.arduino.cc/libraries/library_index.json.gz")).download(tempFile, new MultiStepProgress(1), "");
|
||||
new GZippedJsonDownloader(downloader, new URL("http://downloads.arduino.cc/libraries/library_index.json"), new URL("http://downloads.arduino.cc/libraries/library_index.json.gz")).download(tempFile, new MultiStepProgress(1), "", new NoopProgressListener());
|
||||
|
||||
InputStream indexIn = new FileInputStream(tempFile);
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
|
@ -38,7 +38,7 @@ public class JsonDownloaderTest {
|
||||
|
||||
@Test
|
||||
public void testJsonDownload() throws Exception {
|
||||
new JsonDownloader(downloader, new URL("http://downloads.arduino.cc/libraries/library_index.json")).download(tempFile, new MultiStepProgress(1), "");
|
||||
new JsonDownloader(downloader, new URL("http://downloads.arduino.cc/libraries/library_index.json")).download(tempFile, new MultiStepProgress(1), "", new NoopProgressListener());
|
||||
|
||||
InputStream indexIn = new FileInputStream(tempFile);
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
|
@ -0,0 +1,95 @@
|
||||
/*
|
||||
* This file is part of Arduino.
|
||||
*
|
||||
* Copyright 2015 Arduino LLC (http://www.arduino.cc/)
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package cc.arduino.i18n;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class ExternalProcessOutputParserTest {
|
||||
|
||||
@Test
|
||||
public void testParser1() throws Exception {
|
||||
Map<String, Object> output = new ExternalProcessOutputParser().parse("===WARNING: Category '{0}' in library {1} is not valid. Setting to '{2}' ||| [ Wire Uncategorized]");
|
||||
|
||||
assertEquals("WARNING: Category '{0}' in library {1} is not valid. Setting to '{2}'", output.get("msg"));
|
||||
Object[] args = (Object[]) output.get("args");
|
||||
assertEquals(3, args.length);
|
||||
assertEquals("", args[0]);
|
||||
assertEquals("Wire", args[1]);
|
||||
assertEquals("Uncategorized", args[2]);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParser2() throws Exception {
|
||||
Map<String, Object> output = new ExternalProcessOutputParser().parse("===Using previously compiled file: {0} ||| [%2Ftmp%2Farduino-sketch-456612873D8321DA02916066CB8B2FE6%2Flibraries%2FBridge%2FBridge.cpp.o]");
|
||||
|
||||
assertEquals("Using previously compiled file: {0}", output.get("msg"));
|
||||
Object[] args = (Object[]) output.get("args");
|
||||
assertEquals(1, args.length);
|
||||
assertEquals("/tmp/arduino-sketch-456612873D8321DA02916066CB8B2FE6/libraries/Bridge/Bridge.cpp.o", args[0]);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParser3() throws Exception {
|
||||
Map<String, Object> output = new ExternalProcessOutputParser().parse("===Using library {0} at version {1} in folder: {2} {3} {4} ||| [Stepper 1.1.1 %2Fhome%2Ffederico%2Fmateriale%2Fworks_Arduino%2FArduino%2Fbuild%2Flinux%2Fwork%2Flibraries%2FStepper ]");
|
||||
|
||||
assertEquals("Using library {0} at version {1} in folder: {2} {3} {4}", output.get("msg"));
|
||||
Object[] args = (Object[]) output.get("args");
|
||||
assertEquals(5, args.length);
|
||||
assertEquals("Stepper", args[0]);
|
||||
assertEquals("1.1.1", args[1]);
|
||||
assertEquals("/home/federico/materiale/works_Arduino/Arduino/build/linux/work/libraries/Stepper", args[2]);
|
||||
assertEquals("", args[3]);
|
||||
assertEquals("", args[4]);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParser4() throws Exception {
|
||||
Map<String, Object> output = new ExternalProcessOutputParser().parse("==={0} ||| []");
|
||||
|
||||
assertEquals("{0}", output.get("msg"));
|
||||
Object[] args = (Object[]) output.get("args");
|
||||
assertEquals(0, args.length);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParser5() throws Exception {
|
||||
Map<String, Object> output = new ExternalProcessOutputParser().parse("==={0} ||| [ ]");
|
||||
|
||||
assertEquals("{0}", output.get("msg"));
|
||||
Object[] args = (Object[]) output.get("args");
|
||||
assertEquals(1, args.length);
|
||||
assertEquals("", args[0]);
|
||||
}
|
||||
|
||||
}
|
31
app/test/processing/app/debug/CompilerTest.java → app/test/cc/arduino/i18n/I18NTest.java
Executable file → Normal file
31
app/test/processing/app/debug/CompilerTest.java → app/test/cc/arduino/i18n/I18NTest.java
Executable file → Normal file
@ -27,25 +27,30 @@
|
||||
* the GNU General Public License.
|
||||
*/
|
||||
|
||||
package processing.app.debug;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static processing.app.debug.Compiler.unescapeDepFile;
|
||||
package cc.arduino.i18n;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import processing.app.AbstractWithPreferencesTest;
|
||||
import processing.app.I18n;
|
||||
|
||||
public class CompilerTest extends AbstractWithPreferencesTest {
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class I18NTest extends AbstractWithPreferencesTest {
|
||||
|
||||
@Test
|
||||
public void makeDepUnescapeTest() throws Exception {
|
||||
assertEquals("C:\\Arduino\\hardware\\arduino\\avr\\cores\\arduino\\Stream.cpp",
|
||||
unescapeDepFile("C:\\Arduino\\hardware\\arduino\\avr\\cores\\arduino\\Stream.cpp"));
|
||||
assertEquals("C:\\Arduino 1.5.3\\hardware\\arduino\\avr\\cores\\arduino\\Stream.cpp",
|
||||
unescapeDepFile("C:\\Arduino\\ 1.5.3\\hardware\\arduino\\avr\\cores\\arduino\\Stream.cpp"));
|
||||
assertEquals("C:\\Ard$ui#\\\\ no 1.5.3\\hardware\\arduino\\avr\\cores\\arduino\\Stream.cpp",
|
||||
unescapeDepFile("C:\\Ard$$ui\\#\\\\\\\\\\ no 1.5.3\\hardware\\arduino\\avr\\cores\\arduino\\Stream.cpp"));
|
||||
public void testMessageFormat() throws Exception {
|
||||
Object[] args = new Object[]{"a", "b", "c"};
|
||||
String actual = I18n.format("WARNING: Category '{0}' in library {1} is not valid. Setting to '{2}'", args);
|
||||
assertEquals("WARNING: Category 'a' in library b is not valid. Setting to 'c'", actual);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMessageFormatFromExternalProcess() throws Exception {
|
||||
Map<String, Object> output = new ExternalProcessOutputParser().parse("===WARNING: Category '{0}' in library {1} is not valid. Setting to '{2}' ||| [ Wire Uncategorized]");
|
||||
|
||||
String actual = I18n.format((String) output.get("msg"), (Object[])output.get("args"));
|
||||
assertEquals("WARNING: Category '' in library Wire is not valid. Setting to 'Uncategorized'", actual);
|
||||
}
|
||||
}
|
169
app/test/cc/arduino/net/CustomProxySelectorTest.java
Normal file
169
app/test/cc/arduino/net/CustomProxySelectorTest.java
Normal file
@ -0,0 +1,169 @@
|
||||
/*
|
||||
* 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.net;
|
||||
|
||||
import cc.arduino.Constants;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.net.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class CustomProxySelectorTest {
|
||||
|
||||
private Map<String, String> preferences;
|
||||
private URI uri;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
System.setProperty("java.net.useSystemProxies", "true");
|
||||
uri = new URL("https://www.arduino.cc").toURI();
|
||||
preferences = new HashMap<>();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoProxy() throws Exception {
|
||||
preferences.put(Constants.PREF_PROXY_TYPE, Constants.PROXY_TYPE_NONE);
|
||||
CustomProxySelector proxySelector = new CustomProxySelector(preferences);
|
||||
Proxy proxy = proxySelector.getProxyFor(uri);
|
||||
|
||||
assertEquals(Proxy.NO_PROXY, proxy);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSystemProxy() throws Exception {
|
||||
preferences.put(Constants.PREF_PROXY_TYPE, Constants.PROXY_TYPE_AUTO);
|
||||
CustomProxySelector proxySelector = new CustomProxySelector(preferences);
|
||||
Proxy proxy = proxySelector.getProxyFor(uri);
|
||||
|
||||
assertEquals(ProxySelector.getDefault().select(uri).get(0), proxy);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProxyPACHTTP() throws Exception {
|
||||
preferences.put(Constants.PREF_PROXY_TYPE, Constants.PROXY_TYPE_AUTO);
|
||||
preferences.put(Constants.PREF_PROXY_PAC_URL, CustomProxySelectorTest.class.getResource("proxy_http.pac").toExternalForm());
|
||||
CustomProxySelector proxySelector = new CustomProxySelector(preferences);
|
||||
Proxy proxy = proxySelector.getProxyFor(uri);
|
||||
|
||||
assertEquals(new Proxy(Proxy.Type.HTTP, new InetSocketAddress("proxy.example.com", 8080)), proxy);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProxyPACHTTPWithLogin() throws Exception {
|
||||
preferences.put(Constants.PREF_PROXY_TYPE, Constants.PROXY_TYPE_AUTO);
|
||||
preferences.put(Constants.PREF_PROXY_PAC_URL, CustomProxySelectorTest.class.getResource("proxy_http.pac").toExternalForm());
|
||||
preferences.put(Constants.PREF_PROXY_AUTO_USERNAME, "auto");
|
||||
preferences.put(Constants.PREF_PROXY_AUTO_PASSWORD, "autopassword");
|
||||
CustomProxySelector proxySelector = new CustomProxySelector(preferences);
|
||||
Proxy proxy = proxySelector.getProxyFor(uri);
|
||||
|
||||
assertEquals(new Proxy(Proxy.Type.HTTP, new InetSocketAddress("proxy.example.com", 8080)), proxy);
|
||||
|
||||
PasswordAuthentication authentication = Authenticator.requestPasswordAuthentication(null, 8080, uri.toURL().getProtocol(), "ciao", "");
|
||||
assertEquals(authentication.getUserName(), "auto");
|
||||
assertEquals(String.valueOf(authentication.getPassword()), "autopassword");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProxyPACSOCKS() throws Exception {
|
||||
preferences.put(Constants.PREF_PROXY_TYPE, Constants.PROXY_TYPE_AUTO);
|
||||
preferences.put(Constants.PREF_PROXY_PAC_URL, CustomProxySelectorTest.class.getResource("proxy_socks.pac").toExternalForm());
|
||||
CustomProxySelector proxySelector = new CustomProxySelector(preferences);
|
||||
Proxy proxy = proxySelector.getProxyFor(uri);
|
||||
|
||||
assertEquals(new Proxy(Proxy.Type.SOCKS, new InetSocketAddress("proxy.example.com", 8080)), proxy);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProxyPACDirect() throws Exception {
|
||||
preferences.put(Constants.PREF_PROXY_TYPE, Constants.PROXY_TYPE_AUTO);
|
||||
preferences.put(Constants.PREF_PROXY_PAC_URL, CustomProxySelectorTest.class.getResource("proxy_direct.pac").toExternalForm());
|
||||
CustomProxySelector proxySelector = new CustomProxySelector(preferences);
|
||||
Proxy proxy = proxySelector.getProxyFor(uri);
|
||||
|
||||
assertEquals(Proxy.NO_PROXY, proxy);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProxyPACComplex() throws Exception {
|
||||
preferences.put(Constants.PREF_PROXY_TYPE, Constants.PROXY_TYPE_AUTO);
|
||||
preferences.put(Constants.PREF_PROXY_PAC_URL, CustomProxySelectorTest.class.getResource("proxy_complex.pac").toExternalForm());
|
||||
CustomProxySelector proxySelector = new CustomProxySelector(preferences);
|
||||
Proxy proxy = proxySelector.getProxyFor(uri);
|
||||
|
||||
assertEquals(new Proxy(Proxy.Type.HTTP, new InetSocketAddress("4.5.6.7", 8080)), proxy);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProxyPACComplex2() throws Exception {
|
||||
preferences.put(Constants.PREF_PROXY_TYPE, Constants.PROXY_TYPE_AUTO);
|
||||
preferences.put(Constants.PREF_PROXY_PAC_URL, CustomProxySelectorTest.class.getResource("proxy_complex.pac").toExternalForm());
|
||||
CustomProxySelector proxySelector = new CustomProxySelector(preferences);
|
||||
Proxy proxy = proxySelector.getProxyFor(new URL("http://www.intranet.domain.com/ciao").toURI());
|
||||
|
||||
assertEquals(Proxy.NO_PROXY, proxy);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testManualProxy() throws Exception {
|
||||
preferences.put(Constants.PREF_PROXY_TYPE, Constants.PROXY_TYPE_MANUAL);
|
||||
preferences.put(Constants.PREF_PROXY_MANUAL_TYPE, Constants.PROXY_MANUAL_TYPE_HTTP);
|
||||
preferences.put(Constants.PREF_PROXY_MANUAL_HOSTNAME, "localhost");
|
||||
preferences.put(Constants.PREF_PROXY_MANUAL_PORT, "8080");
|
||||
|
||||
CustomProxySelector proxySelector = new CustomProxySelector(preferences);
|
||||
Proxy proxy = proxySelector.getProxyFor(uri);
|
||||
|
||||
assertEquals(new Proxy(Proxy.Type.HTTP, new InetSocketAddress("localhost", 8080)), proxy);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testManualProxyWithLogin() throws Exception {
|
||||
preferences.put(Constants.PREF_PROXY_TYPE, Constants.PROXY_TYPE_MANUAL);
|
||||
preferences.put(Constants.PREF_PROXY_MANUAL_TYPE, Constants.PROXY_MANUAL_TYPE_HTTP);
|
||||
preferences.put(Constants.PREF_PROXY_MANUAL_HOSTNAME, "localhost");
|
||||
preferences.put(Constants.PREF_PROXY_MANUAL_PORT, "8080");
|
||||
preferences.put(Constants.PREF_PROXY_MANUAL_USERNAME, "username");
|
||||
preferences.put(Constants.PREF_PROXY_MANUAL_PASSWORD, "pwd");
|
||||
|
||||
CustomProxySelector proxySelector = new CustomProxySelector(preferences);
|
||||
Proxy proxy = proxySelector.getProxyFor(uri);
|
||||
|
||||
assertEquals(new Proxy(Proxy.Type.HTTP, new InetSocketAddress("localhost", 8080)), proxy);
|
||||
|
||||
PasswordAuthentication authentication = Authenticator.requestPasswordAuthentication(null, 8080, uri.toURL().getProtocol(), "ciao", "");
|
||||
assertEquals(authentication.getUserName(), "username");
|
||||
assertEquals(String.valueOf(authentication.getPassword()), "pwd");
|
||||
}
|
||||
}
|
28
app/test/cc/arduino/net/PACSupportMethodsTest.java
Normal file
28
app/test/cc/arduino/net/PACSupportMethodsTest.java
Normal file
@ -0,0 +1,28 @@
|
||||
package cc.arduino.net;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class PACSupportMethodsTest {
|
||||
|
||||
private PACSupportMethods pacSupportMethods;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
pacSupportMethods = new PACSupportMethods();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsInNet() throws Exception {
|
||||
assertFalse(pacSupportMethods.isInNet("192.168.0.121", "198.95.249.79", "255.255.255.255"));
|
||||
assertFalse(pacSupportMethods.isInNet("198.95.249.78", "198.95.249.79", "255.255.255.255"));
|
||||
assertTrue(pacSupportMethods.isInNet("198.95.249.79", "198.95.249.79", "255.255.255.255"));
|
||||
|
||||
assertFalse(pacSupportMethods.isInNet("192.168.0.121", "198.95.0.0", "255.255.0.0"));
|
||||
assertTrue(pacSupportMethods.isInNet("198.95.249.78", "198.95.0.0", "255.255.0.0"));
|
||||
assertTrue(pacSupportMethods.isInNet("198.95.249.79", "198.95.0.0", "255.255.0.0"));
|
||||
}
|
||||
}
|
32
app/test/cc/arduino/net/proxy_complex.pac
Normal file
32
app/test/cc/arduino/net/proxy_complex.pac
Normal file
@ -0,0 +1,32 @@
|
||||
// example downloaded from http://findproxyforurl.com/example-pac-file/
|
||||
|
||||
function FindProxyForURL(url, host) {
|
||||
|
||||
// If the hostname matches, send direct.
|
||||
if (dnsDomainIs(host, ".intranet.domain.com") ||
|
||||
shExpMatch(host, "(*.abcdomain.com|abcdomain.com)"))
|
||||
return "DIRECT";
|
||||
|
||||
// If the protocol or URL matches, send direct.
|
||||
if (url.substring(0, 4)=="ftp:" ||
|
||||
shExpMatch(url, "http://abcdomain.com/folder/*"))
|
||||
return "DIRECT";
|
||||
|
||||
// If the requested website is hosted within the internal network, send direct.
|
||||
if (isPlainHostName(host) ||
|
||||
shExpMatch(host, "*.local") ||
|
||||
isInNet(dnsResolve(host), "10.0.0.0", "255.0.0.0") ||
|
||||
isInNet(dnsResolve(host), "172.16.0.0", "255.240.0.0") ||
|
||||
isInNet(dnsResolve(host), "192.168.0.0", "255.255.0.0") ||
|
||||
isInNet(dnsResolve(host), "127.0.0.0", "255.255.255.0"))
|
||||
return "DIRECT";
|
||||
|
||||
// If the IP address of the local machine is within a defined
|
||||
// subnet, send to a specific proxy.
|
||||
if (isInNet(myIpAddress(), "10.10.5.0", "255.255.255.0"))
|
||||
return "PROXY 1.2.3.4:8080";
|
||||
|
||||
// DEFAULT RULE: All other traffic, use below proxies, in fail-over order.
|
||||
return "PROXY 4.5.6.7:8080; PROXY 7.8.9.10:8080";
|
||||
|
||||
}
|
4
app/test/cc/arduino/net/proxy_direct.pac
Normal file
4
app/test/cc/arduino/net/proxy_direct.pac
Normal file
@ -0,0 +1,4 @@
|
||||
function FindProxyForURL(url, host)
|
||||
{
|
||||
return "DIRECT";
|
||||
}
|
4
app/test/cc/arduino/net/proxy_http.pac
Normal file
4
app/test/cc/arduino/net/proxy_http.pac
Normal file
@ -0,0 +1,4 @@
|
||||
function FindProxyForURL(url, host)
|
||||
{
|
||||
return "PROXY proxy.example.com:8080; DIRECT";
|
||||
}
|
4
app/test/cc/arduino/net/proxy_socks.pac
Normal file
4
app/test/cc/arduino/net/proxy_socks.pac
Normal file
@ -0,0 +1,4 @@
|
||||
function FindProxyForURL(url, host)
|
||||
{
|
||||
return "SOCKS proxy.example.com:8080; DIRECT";
|
||||
}
|
@ -36,8 +36,10 @@ import org.fest.swing.edt.GuiQuery;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import processing.app.helpers.ArduinoFrameFixture;
|
||||
import processing.app.helpers.FileUtils;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.Random;
|
||||
|
||||
public abstract class AbstractGUITest {
|
||||
|
||||
@ -56,7 +58,7 @@ public abstract class AbstractGUITest {
|
||||
JPopupMenu.setDefaultLightWeightPopupEnabled(false);
|
||||
Theme.init();
|
||||
BaseNoGui.getPlatform().setLookAndFeel();
|
||||
Base.untitledFolder = BaseNoGui.createTempFolder("untitled");
|
||||
Base.untitledFolder = FileUtils.createTempFolder("untitled" + new Random().nextInt(Integer.MAX_VALUE), ".tmp");
|
||||
DeleteFilesOnShutdown.add(Base.untitledFolder);
|
||||
|
||||
window = GuiActionRunner.execute(new GuiQuery<ArduinoFrameFixture>() {
|
||||
|
@ -31,6 +31,9 @@ package processing.app;
|
||||
|
||||
import cc.arduino.files.DeleteFilesOnShutdown;
|
||||
import org.junit.Before;
|
||||
import processing.app.helpers.FileUtils;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public abstract class AbstractWithPreferencesTest {
|
||||
|
||||
@ -44,7 +47,7 @@ public abstract class AbstractWithPreferencesTest {
|
||||
|
||||
BaseNoGui.initPackages();
|
||||
|
||||
Base.untitledFolder = BaseNoGui.createTempFolder("untitled");
|
||||
Base.untitledFolder = FileUtils.createTempFolder("untitled" + new Random().nextInt(Integer.MAX_VALUE), ".tmp");
|
||||
DeleteFilesOnShutdown.add(Base.untitledFolder);
|
||||
}
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user