Skip to content

Commit

Permalink
Remove Base dependency from AstractTextMonitor
Browse files Browse the repository at this point in the history
  • Loading branch information
cmaglie authored and facchinm committed Jul 18, 2019
1 parent 1cacd79 commit 2f68d2a
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 15 deletions.
7 changes: 3 additions & 4 deletions app/src/cc/arduino/packages/MonitorFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,23 @@
package cc.arduino.packages;

import processing.app.AbstractMonitor;
import processing.app.Base;
import processing.app.NetworkMonitor;
import processing.app.SerialMonitor;

public class MonitorFactory {

public AbstractMonitor newMonitor(Base base, BoardPort port) {
public AbstractMonitor newMonitor(BoardPort port) {
if ("network".equals(port.getProtocol())) {
if ("yes".equals(port.getPrefs().get("ssh_upload"))) {
// the board is SSH capable
return new NetworkMonitor(base, port);
return new NetworkMonitor(port);
} else {
// SSH not supported, no monitor support
return null;
}
}

return new SerialMonitor(base, port);
return new SerialMonitor(port);
}

}
19 changes: 15 additions & 4 deletions app/src/processing/app/AbstractTextMonitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyListener;
import java.awt.event.MouseWheelListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.text.SimpleDateFormat;
Expand Down Expand Up @@ -46,12 +48,21 @@ public abstract class AbstractTextMonitor extends AbstractMonitor {
protected JComboBox<String> lineEndings;
protected JComboBox<String> serialRates;

public AbstractTextMonitor(Base base, BoardPort boardPort) {
public AbstractTextMonitor(BoardPort boardPort) {
super(boardPort);
}

// Add font size adjustment listeners. This has to be done here due to
// super(boardPort) invoking onCreateWindow(...) before we can store base.
base.addEditorFontResizeListeners(textArea);
@Override
public synchronized void addMouseWheelListener(MouseWheelListener l) {
super.addMouseWheelListener(l);
textArea.addMouseWheelListener(l);
}

@Override
public synchronized void addKeyListener(KeyListener l) {
super.addKeyListener(l);
textArea.addKeyListener(l);
textField.addKeyListener(l);
}

@Override
Expand Down
3 changes: 2 additions & 1 deletion app/src/processing/app/Editor.java
Original file line number Diff line number Diff line change
Expand Up @@ -2212,7 +2212,7 @@ public void handleSerial() {
return;
}

serialMonitor = new MonitorFactory().newMonitor(base, port);
serialMonitor = new MonitorFactory().newMonitor(port);

if (serialMonitor == null) {
String board = port.getPrefs().get("board");
Expand All @@ -2221,6 +2221,7 @@ public void handleSerial() {
return;
}

base.addEditorFontResizeListeners(serialMonitor);
Base.setIcon(serialMonitor);

// If currently uploading, disable the monitor (it will be later
Expand Down
2 changes: 0 additions & 2 deletions app/src/processing/app/EditorTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseWheelListener;
import java.awt.event.MouseWheelEvent;

import java.io.IOException;

Expand Down
4 changes: 2 additions & 2 deletions app/src/processing/app/NetworkMonitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ public class NetworkMonitor extends AbstractTextMonitor implements MessageConsum
private Channel channel;
private int connectionAttempts;

public NetworkMonitor(Base base, BoardPort port) {
super(base, port);
public NetworkMonitor(BoardPort port) {
super(port);

onSendCommand(new ActionListener() {
public void actionPerformed(ActionEvent event) {
Expand Down
4 changes: 2 additions & 2 deletions app/src/processing/app/SerialMonitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public class SerialMonitor extends AbstractTextMonitor {
private Serial serial;
private int serialRate;

public SerialMonitor(Base base, BoardPort port) {
super(base, port);
public SerialMonitor(BoardPort port) {
super(port);

serialRate = PreferencesData.getInteger("serial.debug_rate");
serialRates.setSelectedItem(serialRate + " " + tr("baud"));
Expand Down

0 comments on commit 2f68d2a

Please sign in to comment.