1
0
mirror of https://github.com/arduino/Arduino.git synced 2024-12-01 12:24:14 +01:00

Merge pull request #2626 from ffissore/hide-cu-devs-on-mac

Macosx: filter out /dev/cu* ports
This commit is contained in:
Cristian Maglie 2015-02-13 15:49:27 +01:00
commit cf3e9480a5
3 changed files with 26 additions and 1 deletions

View File

@ -1004,6 +1004,8 @@ public class Editor extends JFrame implements RunnerListener {
List<BoardPort> ports = Base.getDiscoveryManager().discovery(); List<BoardPort> ports = Base.getDiscoveryManager().discovery();
ports = Base.getPlatform().filterPorts(ports, Preferences.getBoolean("serial.ports.showall"));
Collections.sort(ports, new Comparator<BoardPort>() { Collections.sort(ports, new Comparator<BoardPort>() {
@Override @Override
public int compare(BoardPort o1, BoardPort o2) { public int compare(BoardPort o1, BoardPort o2) {

View File

@ -30,6 +30,7 @@ import java.util.Map;
import javax.swing.UIManager; import javax.swing.UIManager;
import cc.arduino.packages.BoardPort;
import com.sun.jna.Library; import com.sun.jna.Library;
import com.sun.jna.Native; import com.sun.jna.Native;
import processing.app.debug.TargetBoard; import processing.app.debug.TargetBoard;
@ -217,4 +218,8 @@ public class Platform {
_("Unspecified platform, no launcher available.\nTo enable opening URLs or folders, add a \n\"launcher=/path/to/app\" line to preferences.txt"), _("Unspecified platform, no launcher available.\nTo enable opening URLs or folders, add a \n\"launcher=/path/to/app\" line to preferences.txt"),
null); null);
} }
public List<BoardPort> filterPorts(List<BoardPort> ports, boolean aBoolean) {
return new LinkedList<BoardPort>(ports);
}
} }

View File

@ -22,6 +22,7 @@
package processing.app.macosx; package processing.app.macosx;
import cc.arduino.packages.BoardPort;
import com.apple.eio.FileManager; import com.apple.eio.FileManager;
import org.apache.commons.exec.CommandLine; import org.apache.commons.exec.CommandLine;
import org.apache.commons.exec.Executor; import org.apache.commons.exec.Executor;
@ -35,7 +36,8 @@ import java.awt.*;
import java.io.*; import java.io.*;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.net.URI; import java.net.URI;
import java.util.Map; import java.util.*;
import java.util.List;
/** /**
@ -239,4 +241,20 @@ public class Platform extends processing.app.Platform {
return super.preListAllCandidateDevices(); return super.preListAllCandidateDevices();
} }
} }
@Override
public java.util.List<BoardPort> filterPorts(java.util.List<BoardPort> ports, boolean showAll) {
if (showAll) {
return super.filterPorts(ports, true);
}
List<BoardPort> filteredPorts = new LinkedList<BoardPort>();
for (BoardPort port : ports) {
if (!port.getAddress().startsWith("/dev/cu.")) {
filteredPorts.add(port);
}
}
return filteredPorts;
}
} }