Skip to content

Commit 87fb45c

Browse files
committed
Merge pull request #3055 from ffissore/other-packages
Allow listing other boards in boards manager
2 parents d87f0fa + cd49d29 commit 87fb45c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1522
-518
lines changed

.classpath

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
<classpathentry kind="lib" path="app/lib/jmdns-3.4.1.jar"/>
2121
<classpathentry kind="lib" path="app/lib/jsch-0.1.50.jar"/>
2222
<classpathentry kind="lib" path="app/lib/jssc-2.8.0.jar"/>
23-
<classpathentry kind="lib" path="app/lib/bcpg-jdk15on-149.jar"/>
24-
<classpathentry kind="lib" path="app/lib/bcprov-jdk15on-149.jar"/>
23+
<classpathentry kind="lib" path="app/lib/bcpg-jdk15on-152.jar"/>
24+
<classpathentry kind="lib" path="app/lib/bcprov-jdk15on-152.jar"/>
2525
<classpathentry kind="lib" path="app/lib/jackson-core-2.2.3.jar"/>
2626
<classpathentry kind="lib" path="app/lib/jackson-databind-2.2.3.jar"/>
2727
<classpathentry kind="lib" path="app/lib/jackson-module-mrbean-2.2.3.jar"/>

app/.classpath

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
<classpathentry kind="lib" path="lib/jna.jar"/>
88
<classpathentry kind="lib" path="lib/ecj.jar"/>
99
<classpathentry kind="lib" path="lib/apple.jar"/>
10-
<classpathentry kind="lib" path="lib/bcpg-jdk15on-149.jar"/>
11-
<classpathentry kind="lib" path="lib/bcprov-jdk15on-149.jar"/>
10+
<classpathentry kind="lib" path="lib/bcpg-jdk15on-152.jar"/>
11+
<classpathentry kind="lib" path="lib/bcprov-jdk15on-152.jar"/>
1212
<classpathentry kind="lib" path="lib/commons-codec-1.7.jar"/>
1313
<classpathentry kind="lib" path="lib/commons-compress-1.8.jar"/>
1414
<classpathentry kind="lib" path="lib/commons-exec-1.1.jar"/>

app/build.xml

+2
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@
9999
<fileset dir="test" includes="**/*.txt" />
100100
<fileset dir="test" includes="**/*.properties" />
101101
<fileset dir="test" includes="**/*.ino" />
102+
<fileset dir="test" includes="**/*.json*" />
103+
<fileset dir="test" includes="**/*.key" />
102104
</copy>
103105

104106
<junit printsummary="yes" dir="${work.dir}" fork="true">

app/lib/bcpg-jdk15on-149.jar

-243 KB
Binary file not shown.

app/lib/bcpg-jdk15on-152.jar

268 KB
Binary file not shown.

app/lib/bcprov-jdk15on-149.jar

-2.36 MB
Binary file not shown.

app/lib/bcprov-jdk15on-152.jar

2.77 MB
Binary file not shown.

app/src/cc/arduino/contributions/packages/ui/ContributionIndexTableModel.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
import cc.arduino.contributions.filters.InstalledPredicate;
3333
import cc.arduino.contributions.packages.ContributedPackage;
3434
import cc.arduino.contributions.packages.ContributedPlatform;
35-
import cc.arduino.contributions.packages.ContributionsIndex;
35+
import cc.arduino.contributions.packages.ContributionsIndexer;
3636
import cc.arduino.contributions.ui.FilteredAbstractTableModel;
3737
import com.google.common.base.Predicate;
3838
import com.google.common.base.Predicates;
@@ -113,16 +113,16 @@ public void select(ContributedPlatform value) {
113113

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

116-
private ContributionsIndex index;
116+
private ContributionsIndexer indexer;
117117

118-
public void setIndex(ContributionsIndex _index) {
119-
index = _index;
118+
public void setIndexer(ContributionsIndexer indexer) {
119+
this.indexer = indexer;
120120
}
121121

122122
public void updateIndexFilter(String filters[], Predicate<ContributedPlatform>... additionalFilters) {
123123
contributions.clear();
124124
Predicate<ContributedPlatform> filter = Predicates.and(additionalFilters);
125-
for (ContributedPackage pack : index.getPackages()) {
125+
for (ContributedPackage pack : indexer.getPackages()) {
126126
for (ContributedPlatform platform : pack.getPlatforms()) {
127127
if (!filter.apply(platform)) {
128128
continue;

app/src/cc/arduino/contributions/packages/ui/ContributionManagerUI.java

+5-8
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,11 @@
2828
*/
2929
package cc.arduino.contributions.packages.ui;
3030

31-
import cc.arduino.contributions.ui.InstallerJDialogUncaughtExceptionHandler;
3231
import cc.arduino.contributions.packages.ContributedPlatform;
3332
import cc.arduino.contributions.packages.ContributionInstaller;
3433
import cc.arduino.contributions.packages.ContributionsIndexer;
3534
import cc.arduino.contributions.packages.DownloadableContribution;
36-
import cc.arduino.contributions.ui.DropdownItem;
37-
import cc.arduino.contributions.ui.FilteredAbstractTableModel;
38-
import cc.arduino.contributions.ui.InstallerJDialog;
39-
import cc.arduino.contributions.ui.InstallerTableCell;
35+
import cc.arduino.contributions.ui.*;
4036
import cc.arduino.utils.Progress;
4137
import processing.app.I18n;
4238

@@ -95,7 +91,7 @@ public void setIndexer(ContributionsIndexer indexer) {
9591

9692
categoryChooser.removeActionListener(categoryChooserActionListener);
9793

98-
getContribModel().setIndex(indexer.getIndex());
94+
getContribModel().setIndexer(indexer);
9995

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

107103
// Enable categories combo only if there are two or more choices
108104
categoryChooser.addItem(new DropdownAllCoresItem());
109-
Collection<String> categories = indexer.getIndex().getCategories();
105+
Collection<String> categories = indexer.getCategories();
110106
for (String s : categories) {
111107
categoryChooser.addItem(new DropdownCoreOfCategoryItem(s));
112108
}
@@ -152,7 +148,8 @@ public void onUpdatePressed() {
152148
public void run() {
153149
try {
154150
setProgressVisible(true, "");
155-
installer.updateIndex();
151+
List<String> downloadedPackageIndexFiles = installer.updateIndex();
152+
installer.deleteUnknownFiles(downloadedPackageIndexFiles);
156153
onIndexesUpdated();
157154
} catch (Exception e) {
158155
throw new RuntimeException(e);

app/src/processing/app/Base.java

+38-34
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
package processing.app;
2424

25+
import cc.arduino.DefaultUncaughtExceptionHandler;
2526
import cc.arduino.contributions.DownloadableContributionVersionComparator;
2627
import cc.arduino.contributions.VersionHelper;
2728
import cc.arduino.contributions.libraries.ContributedLibrary;
@@ -321,7 +322,8 @@ protected void onProgress(Progress progress) {
321322
lastStatus = progress.getStatus();
322323
}
323324
};
324-
installer.updateIndex();
325+
List<String> downloadedPackageIndexFiles = installer.updateIndex();
326+
installer.deleteUnknownFiles(downloadedPackageIndexFiles);
325327
indexer.parseIndex();
326328
indexer.syncWithFilesystem(getHardwareFolder());
327329

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

345-
ContributedPlatform installed = indexer.getIndex().getInstalled(boardToInstallParts[0], boardToInstallParts[1]);
347+
ContributedPlatform installed = indexer.getInstalled(boardToInstallParts[0], boardToInstallParts[1]);
346348

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

24062408

2407-
/**
2408-
* Return an InputStream for a file inside the Processing lib folder.
2409-
*/
2410-
static public InputStream getLibStream(String filename) throws IOException {
2411-
return BaseNoGui.getLibStream(filename);
2412-
}
2413-
2414-
24152409
// ...................................................................
24162410

24172411

@@ -2429,17 +2423,22 @@ static public int countLines(String what) {
24292423
*/
24302424
static public byte[] loadBytesRaw(File file) throws IOException {
24312425
int size = (int) file.length();
2432-
FileInputStream input = new FileInputStream(file);
2433-
byte buffer[] = new byte[size];
2434-
int offset = 0;
2435-
int bytesRead;
2436-
while ((bytesRead = input.read(buffer, offset, size - offset)) != -1) {
2437-
offset += bytesRead;
2438-
if (bytesRead == 0) break;
2426+
FileInputStream input = null;
2427+
try {
2428+
input = new FileInputStream(file);
2429+
byte buffer[] = new byte[size];
2430+
int offset = 0;
2431+
int bytesRead;
2432+
while ((bytesRead = input.read(buffer, offset, size - offset)) != -1) {
2433+
offset += bytesRead;
2434+
if (bytesRead == 0) break;
2435+
}
2436+
return buffer;
2437+
} finally {
2438+
if (input != null) {
2439+
input.close();
2440+
}
24392441
}
2440-
input.close(); // weren't properly being closed
2441-
input = null;
2442-
return buffer;
24432442
}
24442443

24452444

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

24752474
static public void copyFile(File sourceFile,
24762475
File targetFile) throws IOException {
2477-
InputStream from =
2478-
new BufferedInputStream(new FileInputStream(sourceFile));
2479-
OutputStream to =
2480-
new BufferedOutputStream(new FileOutputStream(targetFile));
2481-
byte[] buffer = new byte[16 * 1024];
2482-
int bytesRead;
2483-
while ((bytesRead = from.read(buffer)) != -1) {
2484-
to.write(buffer, 0, bytesRead);
2485-
}
2486-
to.flush();
2487-
from.close(); // ??
2488-
from = null;
2489-
to.close(); // ??
2490-
to = null;
2476+
InputStream from = null;
2477+
OutputStream to = null;
2478+
try {
2479+
from = new BufferedInputStream(new FileInputStream(sourceFile));
2480+
to = new BufferedOutputStream(new FileOutputStream(targetFile));
2481+
byte[] buffer = new byte[16 * 1024];
2482+
int bytesRead;
2483+
while ((bytesRead = from.read(buffer)) != -1) {
2484+
to.write(buffer, 0, bytesRead);
2485+
}
2486+
to.flush();
2487+
} finally {
2488+
if (from != null) {
2489+
from.close(); // ??
2490+
}
2491+
if (to != null) {
2492+
to.close(); // ??
2493+
}
2494+
}
24912495

24922496
targetFile.setLastModified(sourceFile.lastModified());
24932497
}

app/src/processing/app/Preferences.java

+19-2
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ public String toString() {
209209
// and linux is all over the map
210210

211211
static final int GUI_BIG = 13;
212-
static final int GUI_BETWEEN = 10;
212+
static final int GUI_BETWEEN = 5;
213213
static final int GUI_SMALL = 6;
214214

215215
// gui elements
@@ -237,7 +237,7 @@ public String toString() {
237237
JTextField proxyHTTPSPort;
238238
JTextField proxyUser;
239239
JPasswordField proxyPassword;
240-
240+
private final JTextField additionalBoardsManagerField;
241241

242242
// the calling editor, so updates can be applied
243243

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

467+
// proxy settings
468+
467469
JPanel proxySettingsContainer = new JPanel();
468470
pane.add(proxySettingsContainer);
469471
setupProxySettingsFieldSet(proxySettingsContainer);
@@ -472,6 +474,17 @@ public void actionPerformed(ActionEvent e) {
472474
right = Math.max(right, left + d.width);
473475
top += d.height + GUI_BETWEEN;
474476

477+
// boards manager additional urls
478+
box = Box.createHorizontalBox();
479+
label = new JLabel(_("Additional Boards Manager URLs: "));
480+
box.add(label);
481+
additionalBoardsManagerField = new JTextField(30);
482+
box.add(additionalBoardsManagerField);
483+
pane.add(box);
484+
d = box.getPreferredSize();
485+
box.setBounds(left, top, d.width, d.height);
486+
top += d.height + GUI_BETWEEN;
487+
475488
// More preferences are in the ...
476489

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

804+
Preferences.set("boardsmanager.additional.urls", additionalBoardsManagerField.getText().replace("\r\n", "\n").replace("\r", "\n").replace("\n", ","));
805+
791806
editor.applyPreferences();
792807
}
793808

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

852+
additionalBoardsManagerField.setText(Preferences.get("boardsmanager.additional.urls"));
853+
837854
dialog.setLocationRelativeTo(editor);
838855
dialog.setVisible(true);
839856
}

app/src/processing/app/Theme.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import java.awt.Color;
2727
import java.awt.Font;
2828
import java.awt.SystemColor;
29+
import java.io.File;
2930

3031
import processing.app.helpers.PreferencesHelper;
3132
import processing.app.helpers.PreferencesMap;
@@ -45,7 +46,7 @@ public class Theme {
4546

4647
static protected void init() {
4748
try {
48-
table.load(Base.getLibStream("theme/theme.txt"));
49+
table.load(new File(BaseNoGui.getContentFile("lib"), "theme/theme.txt"));
4950
} catch (Exception te) {
5051
Base.showError(null, _("Could not read color theme settings.\n" +
5152
"You'll need to reinstall Arduino."), te);

app/src/processing/app/UpdateCheck.java

+14-9
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@
2222

2323
package processing.app;
2424

25+
import processing.app.legacy.PApplet;
26+
27+
import javax.swing.*;
2528
import java.io.BufferedReader;
26-
import java.io.InputStream;
29+
import java.io.IOException;
2730
import java.io.InputStreamReader;
2831
import java.net.URL;
2932
import java.net.URLEncoder;
3033
import java.util.Random;
3134

32-
import javax.swing.JOptionPane;
33-
34-
import processing.app.legacy.PApplet;
3535
import static processing.app.I18n._;
3636

3737

@@ -126,11 +126,16 @@ public void run() {
126126
}
127127

128128

129-
protected int readInt(String filename) throws Exception {
129+
protected int readInt(String filename) throws IOException {
130130
URL url = new URL(filename);
131-
InputStream stream = url.openStream();
132-
InputStreamReader isr = new InputStreamReader(stream);
133-
BufferedReader reader = new BufferedReader(isr);
134-
return Integer.parseInt(reader.readLine());
131+
BufferedReader reader = null;
132+
try {
133+
reader = new BufferedReader(new InputStreamReader(url.openStream()));
134+
return Integer.parseInt(reader.readLine());
135+
} finally {
136+
if (reader != null) {
137+
reader.close();
138+
}
139+
}
135140
}
136141
}

0 commit comments

Comments
 (0)