Skip to content

Allow listing other boards in boards manager #3055

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
May 4, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
<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"/>
<classpathentry kind="lib" path="app/lib/bcpg-jdk15on-149.jar"/>
<classpathentry kind="lib" path="app/lib/bcprov-jdk15on-149.jar"/>
<classpathentry kind="lib" path="app/lib/bcpg-jdk15on-152.jar"/>
<classpathentry kind="lib" path="app/lib/bcprov-jdk15on-152.jar"/>
<classpathentry kind="lib" path="app/lib/jackson-core-2.2.3.jar"/>
<classpathentry kind="lib" path="app/lib/jackson-databind-2.2.3.jar"/>
<classpathentry kind="lib" path="app/lib/jackson-module-mrbean-2.2.3.jar"/>
Expand Down
4 changes: 2 additions & 2 deletions app/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<classpathentry kind="lib" path="lib/jna.jar"/>
<classpathentry kind="lib" path="lib/ecj.jar"/>
<classpathentry kind="lib" path="lib/apple.jar"/>
<classpathentry kind="lib" path="lib/bcpg-jdk15on-149.jar"/>
<classpathentry kind="lib" path="lib/bcprov-jdk15on-149.jar"/>
<classpathentry kind="lib" path="lib/bcpg-jdk15on-152.jar"/>
<classpathentry kind="lib" path="lib/bcprov-jdk15on-152.jar"/>
<classpathentry kind="lib" path="lib/commons-codec-1.7.jar"/>
<classpathentry kind="lib" path="lib/commons-compress-1.8.jar"/>
<classpathentry kind="lib" path="lib/commons-exec-1.1.jar"/>
Expand Down
2 changes: 2 additions & 0 deletions app/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@
<fileset dir="test" includes="**/*.txt" />
<fileset dir="test" includes="**/*.properties" />
<fileset dir="test" includes="**/*.ino" />
<fileset dir="test" includes="**/*.json*" />
<fileset dir="test" includes="**/*.key" />
</copy>

<junit printsummary="yes" dir="${work.dir}" fork="true">
Expand Down
Binary file removed app/lib/bcpg-jdk15on-149.jar
Binary file not shown.
Binary file added app/lib/bcpg-jdk15on-152.jar
Binary file not shown.
Binary file removed app/lib/bcprov-jdk15on-149.jar
Binary file not shown.
Binary file added app/lib/bcprov-jdk15on-152.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import cc.arduino.contributions.filters.InstalledPredicate;
import cc.arduino.contributions.packages.ContributedPackage;
import cc.arduino.contributions.packages.ContributedPlatform;
import cc.arduino.contributions.packages.ContributionsIndex;
import cc.arduino.contributions.packages.ContributionsIndexer;
import cc.arduino.contributions.ui.FilteredAbstractTableModel;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
Expand Down Expand Up @@ -113,16 +113,16 @@ public void select(ContributedPlatform value) {

private Class<?>[] columnTypes = {ContributedPlatform.class};

private ContributionsIndex index;
private ContributionsIndexer indexer;

public void setIndex(ContributionsIndex _index) {
index = _index;
public void setIndexer(ContributionsIndexer indexer) {
this.indexer = indexer;
}

public void updateIndexFilter(String filters[], Predicate<ContributedPlatform>... additionalFilters) {
contributions.clear();
Predicate<ContributedPlatform> filter = Predicates.and(additionalFilters);
for (ContributedPackage pack : index.getPackages()) {
for (ContributedPackage pack : indexer.getPackages()) {
for (ContributedPlatform platform : pack.getPlatforms()) {
if (!filter.apply(platform)) {
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,11 @@
*/
package cc.arduino.contributions.packages.ui;

import cc.arduino.contributions.ui.InstallerJDialogUncaughtExceptionHandler;
import cc.arduino.contributions.packages.ContributedPlatform;
import cc.arduino.contributions.packages.ContributionInstaller;
import cc.arduino.contributions.packages.ContributionsIndexer;
import cc.arduino.contributions.packages.DownloadableContribution;
import cc.arduino.contributions.ui.DropdownItem;
import cc.arduino.contributions.ui.FilteredAbstractTableModel;
import cc.arduino.contributions.ui.InstallerJDialog;
import cc.arduino.contributions.ui.InstallerTableCell;
import cc.arduino.contributions.ui.*;
import cc.arduino.utils.Progress;
import processing.app.I18n;

Expand Down Expand Up @@ -95,7 +91,7 @@ public void setIndexer(ContributionsIndexer indexer) {

categoryChooser.removeActionListener(categoryChooserActionListener);

getContribModel().setIndex(indexer.getIndex());
getContribModel().setIndexer(indexer);

categoryFilter = null;
categoryChooser.removeAllItems();
Expand All @@ -106,7 +102,7 @@ public void setIndexer(ContributionsIndexer indexer) {

// Enable categories combo only if there are two or more choices
categoryChooser.addItem(new DropdownAllCoresItem());
Collection<String> categories = indexer.getIndex().getCategories();
Collection<String> categories = indexer.getCategories();
for (String s : categories) {
categoryChooser.addItem(new DropdownCoreOfCategoryItem(s));
}
Expand Down Expand Up @@ -152,7 +148,8 @@ public void onUpdatePressed() {
public void run() {
try {
setProgressVisible(true, "");
installer.updateIndex();
List<String> downloadedPackageIndexFiles = installer.updateIndex();
installer.deleteUnknownFiles(downloadedPackageIndexFiles);
onIndexesUpdated();
} catch (Exception e) {
throw new RuntimeException(e);
Expand Down
72 changes: 38 additions & 34 deletions app/src/processing/app/Base.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

package processing.app;

import cc.arduino.DefaultUncaughtExceptionHandler;
import cc.arduino.contributions.DownloadableContributionVersionComparator;
import cc.arduino.contributions.VersionHelper;
import cc.arduino.contributions.libraries.ContributedLibrary;
Expand Down Expand Up @@ -321,7 +322,8 @@ protected void onProgress(Progress progress) {
lastStatus = progress.getStatus();
}
};
installer.updateIndex();
List<String> downloadedPackageIndexFiles = installer.updateIndex();
installer.deleteUnknownFiles(downloadedPackageIndexFiles);
indexer.parseIndex();
indexer.syncWithFilesystem(getHardwareFolder());

Expand All @@ -342,7 +344,7 @@ protected void onProgress(Progress progress) {
System.exit(1);
}

ContributedPlatform installed = indexer.getIndex().getInstalled(boardToInstallParts[0], boardToInstallParts[1]);
ContributedPlatform installed = indexer.getInstalled(boardToInstallParts[0], boardToInstallParts[1]);

if (!selected.isReadOnly()) {
installer.install(selected);
Expand Down Expand Up @@ -2404,14 +2406,6 @@ static public Image getLibImage(String name, Component who) {
}


/**
* Return an InputStream for a file inside the Processing lib folder.
*/
static public InputStream getLibStream(String filename) throws IOException {
return BaseNoGui.getLibStream(filename);
}


// ...................................................................


Expand All @@ -2429,17 +2423,22 @@ static public int countLines(String what) {
*/
static public byte[] loadBytesRaw(File file) throws IOException {
int size = (int) file.length();
FileInputStream input = new FileInputStream(file);
byte buffer[] = new byte[size];
int offset = 0;
int bytesRead;
while ((bytesRead = input.read(buffer, offset, size - offset)) != -1) {
offset += bytesRead;
if (bytesRead == 0) break;
FileInputStream input = null;
try {
input = new FileInputStream(file);
byte buffer[] = new byte[size];
int offset = 0;
int bytesRead;
while ((bytesRead = input.read(buffer, offset, size - offset)) != -1) {
offset += bytesRead;
if (bytesRead == 0) break;
}
return buffer;
} finally {
if (input != null) {
input.close();
}
}
input.close(); // weren't properly being closed
input = null;
return buffer;
}


Expand Down Expand Up @@ -2474,20 +2473,25 @@ static public HashMap<String, String> readSettings(File inputFile) {

static public void copyFile(File sourceFile,
File targetFile) throws IOException {
InputStream from =
new BufferedInputStream(new FileInputStream(sourceFile));
OutputStream to =
new BufferedOutputStream(new FileOutputStream(targetFile));
byte[] buffer = new byte[16 * 1024];
int bytesRead;
while ((bytesRead = from.read(buffer)) != -1) {
to.write(buffer, 0, bytesRead);
}
to.flush();
from.close(); // ??
from = null;
to.close(); // ??
to = null;
InputStream from = null;
OutputStream to = null;
try {
from = new BufferedInputStream(new FileInputStream(sourceFile));
to = new BufferedOutputStream(new FileOutputStream(targetFile));
byte[] buffer = new byte[16 * 1024];
int bytesRead;
while ((bytesRead = from.read(buffer)) != -1) {
to.write(buffer, 0, bytesRead);
}
to.flush();
} finally {
if (from != null) {
from.close(); // ??
}
if (to != null) {
to.close(); // ??
}
}

targetFile.setLastModified(sourceFile.lastModified());
}
Expand Down
21 changes: 19 additions & 2 deletions app/src/processing/app/Preferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public String toString() {
// and linux is all over the map

static final int GUI_BIG = 13;
static final int GUI_BETWEEN = 10;
static final int GUI_BETWEEN = 5;
static final int GUI_SMALL = 6;

// gui elements
Expand Down Expand Up @@ -237,7 +237,7 @@ public String toString() {
JTextField proxyHTTPSPort;
JTextField proxyUser;
JPasswordField proxyPassword;

private final JTextField additionalBoardsManagerField;

// the calling editor, so updates can be applied

Expand Down Expand Up @@ -464,6 +464,8 @@ public void actionPerformed(ActionEvent e) {
right = Math.max(right, left + d.width);
top += d.height + GUI_BETWEEN;

// proxy settings

JPanel proxySettingsContainer = new JPanel();
pane.add(proxySettingsContainer);
setupProxySettingsFieldSet(proxySettingsContainer);
Expand All @@ -472,6 +474,17 @@ public void actionPerformed(ActionEvent e) {
right = Math.max(right, left + d.width);
top += d.height + GUI_BETWEEN;

// boards manager additional urls
box = Box.createHorizontalBox();
label = new JLabel(_("Additional Boards Manager URLs: "));
box.add(label);
additionalBoardsManagerField = new JTextField(30);
box.add(additionalBoardsManagerField);
pane.add(box);
d = box.getPreferredSize();
box.setBounds(left, top, d.width, d.height);
top += d.height + GUI_BETWEEN;

// More preferences are in the ...

label = new JLabel(_("More preferences can be edited directly in the file"));
Expand Down Expand Up @@ -788,6 +801,8 @@ protected void applyFrame() {
Preferences.set("proxy.user", proxyUser.getText());
Preferences.set("proxy.password", new String(proxyPassword.getPassword()));

Preferences.set("boardsmanager.additional.urls", additionalBoardsManagerField.getText().replace("\r\n", "\n").replace("\r", "\n").replace("\n", ","));

editor.applyPreferences();
}

Expand Down Expand Up @@ -834,6 +849,8 @@ protected void showFrame(Editor editor) {
proxyUser.setText(Preferences.get("proxy.user"));
proxyPassword.setText(Preferences.get("proxy.password"));

additionalBoardsManagerField.setText(Preferences.get("boardsmanager.additional.urls"));

dialog.setLocationRelativeTo(editor);
dialog.setVisible(true);
}
Expand Down
3 changes: 2 additions & 1 deletion app/src/processing/app/Theme.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.awt.Color;
import java.awt.Font;
import java.awt.SystemColor;
import java.io.File;

import processing.app.helpers.PreferencesHelper;
import processing.app.helpers.PreferencesMap;
Expand All @@ -45,7 +46,7 @@ public class Theme {

static protected void init() {
try {
table.load(Base.getLibStream("theme/theme.txt"));
table.load(new File(BaseNoGui.getContentFile("lib"), "theme/theme.txt"));
} catch (Exception te) {
Base.showError(null, _("Could not read color theme settings.\n" +
"You'll need to reinstall Arduino."), te);
Expand Down
23 changes: 14 additions & 9 deletions app/src/processing/app/UpdateCheck.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@

package processing.app;

import processing.app.legacy.PApplet;

import javax.swing.*;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLEncoder;
import java.util.Random;

import javax.swing.JOptionPane;

import processing.app.legacy.PApplet;
import static processing.app.I18n._;


Expand Down Expand Up @@ -126,11 +126,16 @@ public void run() {
}


protected int readInt(String filename) throws Exception {
protected int readInt(String filename) throws IOException {
URL url = new URL(filename);
InputStream stream = url.openStream();
InputStreamReader isr = new InputStreamReader(stream);
BufferedReader reader = new BufferedReader(isr);
return Integer.parseInt(reader.readLine());
BufferedReader reader = null;
try {
reader = new BufferedReader(new InputStreamReader(url.openStream()));
return Integer.parseInt(reader.readLine());
} finally {
if (reader != null) {
reader.close();
}
}
}
}
Loading