mirror of
https://github.com/arduino/Arduino.git
synced 2025-02-26 20:54:22 +01:00
Some small makeup
- use diamond notation <> to remove redundant type specification - do no cache listeners, because it makes the code heavier for a a very small gain in memory usage. - removed redundant "this" keywords
This commit is contained in:
parent
2f68d2af1b
commit
3438b86699
@ -136,7 +136,7 @@ public abstract class AbstractTextMonitor extends AbstractMonitor {
|
|||||||
minimumSize.setSize(minimumSize.getWidth() / 3, minimumSize.getHeight());
|
minimumSize.setSize(minimumSize.getWidth() / 3, minimumSize.getHeight());
|
||||||
noLineEndingAlert.setMinimumSize(minimumSize);
|
noLineEndingAlert.setMinimumSize(minimumSize);
|
||||||
|
|
||||||
lineEndings = new JComboBox<String>(new String[]{tr("No line ending"), tr("Newline"), tr("Carriage return"), tr("Both NL & CR")});
|
lineEndings = new JComboBox<>(new String[]{tr("No line ending"), tr("Newline"), tr("Carriage return"), tr("Both NL & CR")});
|
||||||
lineEndings.addActionListener((ActionEvent event) -> {
|
lineEndings.addActionListener((ActionEvent event) -> {
|
||||||
PreferencesData.setInteger("serial.line_ending", lineEndings.getSelectedIndex());
|
PreferencesData.setInteger("serial.line_ending", lineEndings.getSelectedIndex());
|
||||||
noLineEndingAlert.setForeground(pane.getBackground());
|
noLineEndingAlert.setForeground(pane.getBackground());
|
||||||
@ -146,7 +146,7 @@ public abstract class AbstractTextMonitor extends AbstractMonitor {
|
|||||||
|
|
||||||
lineEndings.setMaximumSize(lineEndings.getMinimumSize());
|
lineEndings.setMaximumSize(lineEndings.getMinimumSize());
|
||||||
|
|
||||||
serialRates = new JComboBox<String>();
|
serialRates = new JComboBox<>();
|
||||||
for (String rate : serialRateStrings) {
|
for (String rate : serialRateStrings) {
|
||||||
serialRates.addItem(rate + " " + tr("baud"));
|
serialRates.addItem(rate + " " + tr("baud"));
|
||||||
}
|
}
|
||||||
|
@ -1880,9 +1880,6 @@ public class Base {
|
|||||||
getEditors().forEach(Editor::applyPreferences);
|
getEditors().forEach(Editor::applyPreferences);
|
||||||
}
|
}
|
||||||
|
|
||||||
private MouseWheelListener editorFontResizeMouseWheelListener = null;
|
|
||||||
private KeyListener editorFontResizeKeyListener = null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a {@link MouseWheelListener} and {@link KeyListener} to the given
|
* Adds a {@link MouseWheelListener} and {@link KeyListener} to the given
|
||||||
* component that will make "CTRL scroll" and "CTRL +/-"
|
* component that will make "CTRL scroll" and "CTRL +/-"
|
||||||
@ -1894,8 +1891,8 @@ public class Base {
|
|||||||
* @param comp - The component to add the listener to.
|
* @param comp - The component to add the listener to.
|
||||||
*/
|
*/
|
||||||
public void addEditorFontResizeListeners(Component comp) {
|
public void addEditorFontResizeListeners(Component comp) {
|
||||||
this.addEditorFontResizeMouseWheelListener(comp);
|
addEditorFontResizeMouseWheelListener(comp);
|
||||||
this.addEditorFontResizeKeyListener(comp);
|
addEditorFontResizeKeyListener(comp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1907,20 +1904,17 @@ public class Base {
|
|||||||
* @param comp - The component to add the listener to.
|
* @param comp - The component to add the listener to.
|
||||||
*/
|
*/
|
||||||
public void addEditorFontResizeMouseWheelListener(Component comp) {
|
public void addEditorFontResizeMouseWheelListener(Component comp) {
|
||||||
if (this.editorFontResizeMouseWheelListener == null) {
|
comp.addMouseWheelListener(e -> {
|
||||||
this.editorFontResizeMouseWheelListener = (MouseWheelEvent e) -> {
|
if (e.isControlDown()) {
|
||||||
if (e.isControlDown()) {
|
if (e.getWheelRotation() < 0) {
|
||||||
if (e.getWheelRotation() < 0) {
|
this.handleFontSizeChange(1);
|
||||||
this.handleFontSizeChange(1);
|
|
||||||
} else {
|
|
||||||
this.handleFontSizeChange(-1);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
e.getComponent().getParent().dispatchEvent(e);
|
this.handleFontSizeChange(-1);
|
||||||
}
|
}
|
||||||
};
|
} else {
|
||||||
}
|
e.getComponent().getParent().dispatchEvent(e);
|
||||||
comp.addMouseWheelListener(this.editorFontResizeMouseWheelListener);
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1930,29 +1924,26 @@ public class Base {
|
|||||||
* @param comp - The component to add the listener to.
|
* @param comp - The component to add the listener to.
|
||||||
*/
|
*/
|
||||||
public void addEditorFontResizeKeyListener(Component comp) {
|
public void addEditorFontResizeKeyListener(Component comp) {
|
||||||
if (this.editorFontResizeKeyListener == null) {
|
comp.addKeyListener(new KeyAdapter() {
|
||||||
this.editorFontResizeKeyListener = new KeyAdapter() {
|
@Override
|
||||||
@Override
|
public void keyPressed(KeyEvent e) {
|
||||||
public void keyPressed(KeyEvent e) {
|
if (e.getModifiersEx() == KeyEvent.CTRL_DOWN_MASK
|
||||||
if (e.getModifiersEx() == KeyEvent.CTRL_DOWN_MASK
|
|| e.getModifiersEx() == (KeyEvent.CTRL_DOWN_MASK
|
||||||
|| e.getModifiersEx() == (KeyEvent.CTRL_DOWN_MASK
|
| KeyEvent.SHIFT_DOWN_MASK)) {
|
||||||
| KeyEvent.SHIFT_DOWN_MASK)) {
|
switch (e.getKeyCode()) {
|
||||||
switch (e.getKeyCode()) {
|
case KeyEvent.VK_PLUS:
|
||||||
case KeyEvent.VK_PLUS:
|
case KeyEvent.VK_EQUALS:
|
||||||
case KeyEvent.VK_EQUALS:
|
Base.this.handleFontSizeChange(1);
|
||||||
Base.this.handleFontSizeChange(1);
|
break;
|
||||||
break;
|
case KeyEvent.VK_MINUS:
|
||||||
case KeyEvent.VK_MINUS:
|
if (!e.isShiftDown()) {
|
||||||
if (!e.isShiftDown()) {
|
Base.this.handleFontSizeChange(-1);
|
||||||
Base.this.handleFontSizeChange(-1);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
}
|
});
|
||||||
comp.addKeyListener(this.editorFontResizeKeyListener);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<JMenu> getBoardsCustomMenus() {
|
public List<JMenu> getBoardsCustomMenus() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user