1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-01-30 19:52:13 +01:00

Split UploaderAndMonitorFactory in two distinct classes.

This commit is contained in:
Claudio Indellicati 2014-08-25 12:13:45 +02:00 committed by Cristian Maglie
parent 0919b0e4fe
commit 83c61376e0
5 changed files with 26 additions and 20 deletions

View File

@ -0,0 +1,17 @@
package cc.arduino.packages;
import processing.app.AbstractMonitor;
import processing.app.NetworkMonitor;
import processing.app.SerialMonitor;
public class MonitorFactory {
public AbstractMonitor newMonitor(BoardPort port) {
if ("network".equals(port.getProtocol())) {
return new NetworkMonitor(port);
}
return new SerialMonitor(port);
}
}

View File

@ -31,12 +31,9 @@ package cc.arduino.packages;
import cc.arduino.packages.uploaders.SSHUploader;
import cc.arduino.packages.uploaders.SerialUploader;
import processing.app.AbstractMonitor;
import processing.app.NetworkMonitor;
import processing.app.SerialMonitor;
import processing.app.debug.TargetBoard;
public class UploaderAndMonitorFactory {
public class UploaderFactory {
public Uploader newUploader(TargetBoard board, BoardPort port) {
if ("true".equals(board.getPreferences().get("upload.via_ssh")) && port != null && "network".equals(port.getProtocol())) {
@ -46,12 +43,4 @@ public class UploaderAndMonitorFactory {
return new SerialUploader();
}
public AbstractMonitor newMonitor(BoardPort port) {
if ("network".equals(port.getProtocol())) {
return new NetworkMonitor(port);
}
return new SerialMonitor(port);
}
}

View File

@ -22,7 +22,7 @@
package processing.app;
import cc.arduino.packages.UploaderAndMonitorFactory;
import cc.arduino.packages.MonitorFactory;
import com.jcraft.jsch.JSchException;
@ -2518,7 +2518,7 @@ public class Editor extends JFrame implements RunnerListener {
return;
}
serialMonitor = new UploaderAndMonitorFactory().newMonitor(port);
serialMonitor = new MonitorFactory().newMonitor(port);
serialMonitor.setIconImage(getIconImage());
boolean success = false;

View File

@ -24,7 +24,7 @@
package processing.app;
import cc.arduino.packages.BoardPort;
import cc.arduino.packages.UploaderAndMonitorFactory;
import cc.arduino.packages.UploaderFactory;
import cc.arduino.packages.Uploader;
import processing.app.debug.Compiler;
import processing.app.debug.Compiler.ProgressListener;
@ -1198,7 +1198,7 @@ public class Sketch {
BoardPort boardPort = Base.getDiscoveryManager().find(Preferences.get("serial.port"));
Uploader uploader = new UploaderAndMonitorFactory().newUploader(target.getBoards().get(board), boardPort);
Uploader uploader = new UploaderFactory().newUploader(target.getBoards().get(board), boardPort);
boolean success = false;
do {

View File

@ -2,7 +2,7 @@ package processing.app.debug;
import cc.arduino.packages.BoardPort;
import cc.arduino.packages.Uploader;
import cc.arduino.packages.UploaderAndMonitorFactory;
import cc.arduino.packages.UploaderFactory;
import cc.arduino.packages.uploaders.SSHUploader;
import cc.arduino.packages.uploaders.SerialUploader;
import org.junit.Before;
@ -29,7 +29,7 @@ public class UploaderFactoryTest extends AbstractWithPreferencesTest {
boardPort.setBoardName("yun");
boardPort.setAddress("192.168.0.1");
boardPort.setProtocol("network");
Uploader uploader = new UploaderAndMonitorFactory().newUploader(board, boardPort);
Uploader uploader = new UploaderFactory().newUploader(board, boardPort);
assertTrue(uploader instanceof SSHUploader);
}
@ -41,7 +41,7 @@ public class UploaderFactoryTest extends AbstractWithPreferencesTest {
boardPort.setBoardName("myyun");
boardPort.setAddress("192.168.0.1");
boardPort.setProtocol("network");
Uploader uploader = new UploaderAndMonitorFactory().newUploader(board, boardPort);
Uploader uploader = new UploaderFactory().newUploader(board, boardPort);
assertTrue(uploader instanceof SerialUploader);
}
@ -53,7 +53,7 @@ public class UploaderFactoryTest extends AbstractWithPreferencesTest {
boardPort.setBoardName("Arduino Leonardo");
boardPort.setAddress("/dev/ttyACM0");
boardPort.setProtocol("serial");
Uploader uploader = new UploaderAndMonitorFactory().newUploader(board, boardPort);
Uploader uploader = new UploaderFactory().newUploader(board, boardPort);
assertTrue(uploader instanceof SerialUploader);
}