There is some code that, for each submenu under Tools, shows the
selected item in the label of the submenu itself (e.g. before opening
the submenu). This was done whenever the Tools menu is opened and
iterated over all the items in the submenu to identify the s
Previously, this code only looked at direct children of the submenu.
Now, this code also looks through submenus recursively, to keep the code
working even when items are divided over sub-submenus.
This makes a small behaviour change: previously, the first selected item
with a non-zero label was used. Now, the first selected item is used,
which makes the code a bit cleaner. I cannot quickly see any case where
the first selected item would have an empty text (and even more that
there is *another* selected item), so this check seems unnecessary. If
this case would occur nonetheless, it would only mean the selected item
is not displayed in the tools menu, nothing would otherwise break.
When there are no programmers available for the current board, the
programmers menu would remain empty, which would prevent it from
unfolding and could make users think there was something wrong with the
menu.
Now, a disabled item with a message is added if no programmers are
available, which should make it more clear what is going on.
This is a followup for #9373.
`if ((screen.width != screenW) || (screen.height != screenH))` was making sure to reset every preference in case the display geometry changed.
Unfortunately, on Windows 10, `Toolkit.getDefaultToolkit().getScreenSize()` reports only the primary monitor either if external display is connected or not.
Fixes#9781
Previously, the programmers menu always showed *all* programmers of
*all* platforms. This made it hard to find the programmer you need.
When selecting a programmer from another platform, it would typically
not work, since the tool definitions rely on specific variables to be
defined by the board, or files available in the variant directory, which
are typically platform-dependent. Also, some programmers might be
defined in multiple platforms, but there is currently no way to tell
which one is for the current platform an will work, and which is for
another platform and will break.
This commit changes the programmer menu to only show programmers from
the platforms that define the board and the core used. The latter is
only used when boar definition refers a core in another platform, in
which case the core and variant already have a strong coupling (the
variant must offer the right variables for the core to work), so that
would also apply to the programmer, so programmers from the referenced
core's platform can be expected to work.
When a board is selected, the menu of available programmers is
refreshed, but the currently selected programmer preference is
untouched. This might mean that a programmer is selected that is invalid
for the current board and will not actually work. This could be fixed by
clearing the current programmer when it becomes invalid, but that would
mean that changing to another platform and back would always require
reselecting the programmer to use, which seems counter-productive. An
alternative fix would be to check the programmer against the board and
throw an error, but that would require duplicating some code, which did
not seem worthwile (ideally, all this code will be moved to arduino-cli
anyway in the future).
This fixes#9373.
In commit 93581b03d (Set foreground color in library/board manager), the
foreground color was set in addition to the background color, to make
sure that the library and board manager would remain readable even with
a non-standard color scheme (e.g. a dark theme).
When that commit was created, this worked properly. However, between
creating that commit and merging it as part of #9272, the title
rendering was changed from being part of the description (which had its
color set up properly) to being part of the title border (which used
default colors) in #9262.
This commit fixes this again by applying the foreground color also to
the TitledBorder component.
In ContributedPlatformTableCellJPanel this also moves the creation of
the TitledBorder into the constructor, and for
ContributedLibraryTableCellJPanel upwards in the constructor (where it
is run unconditionally), so the property can be final.
When the serial device disconnects, the serial monitor and plotter are
disabled. Previously, the window would be completely disabled. Now, the
configuration controls (autoscroll, add timestamp, baudrate, line
endings) can still be changed while the window is disconnected. These
settings will not take effect immediately, but will be used when the
port is next opened.
Also, the clear output button can now also be used when the port is
disconnected, which makes it easy to get a clean start when reconnecting
the serial port.
There was an error in the following constants:
PREF_PROXY_AUTO_USERNAME = "proxy.manual.username"
PREF_PROXY_AUTO_PASSWORD = "proxy.manual.password"
they should be set to "auto" and not "manual":
PREF_PROXY_AUTO_USERNAME = "proxy.auto.username"
PREF_PROXY_AUTO_PASSWORD = "proxy.auto.password"
Changing the constants to the correct value now will fix the problem for
future installations of the IDE but will produce an annoying side-effect
for users upgrading from previous version of the IDE: they will lose
their saved user and pass (because it was saved as "proxy.manual.*")
and the IDE will suddenly stop working without any clear reason.
To avoid this I've left the value to "proxy.manual.*" and removed
the distinction from AUTO and MANUAL, so now we have only:
PREF_PROXY_USERNAME = "proxy.manual.username"
PREF_PROXY_PASSWORD = "proxy.manual.password"
The corresponding textbox in the preference dialog will be filled based on
the PROXY_TYPE selection.
Previously it could lead to contract violations for example consider
this:
A = Library{ Name:"A", Types: ["Sensors"] }
B = Library{ Name:"B", Types: null }
C = Library{ Name:"C", Types: ["Arduino"] }
it results in:
A<B (because B has Types==null and compare("A","B")<0)
B<C (because B has Types==null and compare("B","C")<0)
C<A (becuase C has Types=="Arduino" and the comparator returns -1)
This commit fix this behavior
For some reason the combination of the AdoptJDKJre 8 and Microsoft store
do not like JFileChooser.
This commit replace JFileChooser with a FileDialog that seems to work
without issues.
This commit fixes instances when setText is called on editorTab and the rectangle that highlights the bracket match becomes incorrect.
This is because text is inserted to the document without notifying the textarea.
Calling setLineWrap internally fires an event that recalculates the bracket match rectangle and thus solves the problem.
Previously, only the background color was changed to white or light
grey. This worked well for the default theme with a black or dark text,
but not for a dark theme with white or light text.
This commit fixes this by also overriding the text color to be black.
Since the colors are set on the JPanel table cell, but the actual text
is rendered by the description JTextPane, the `setForeground` method is
overridden to forward the foreground color to the description pane.
Note that this commit only touches the table cell and description
inside, the dropdowns and buttons have neither background nor foreground
color set (thus these use both colors from the system theme). It might
be more consistent to also override these, but such native UI components
are typically tricky to colorize properly, so best let the system handle
that normally.
An alternative solution would be only use the default colors, which
would actually preserve the dark theme colors in these managers as well
(rather than forcing black-on-white/grey as now). There are default
colors for selected and non-selected table cells that could be used, but
these are different from the current colors. Additionally, the current
odd/even alternating colors are then also no longer available.
Previously,`makeNewDescription` was called in the constructor and then
again later in the `update` method (board manager) or later in the
constructor (library manager) to recreate the description JTextPane so
it can be filled with text. In all cases, the pane would be created
equal, so there is no point in recreating it.
Now, it is created only once and stored in an instance variable for
later reference. Additionally, `makeNewDescription` now only creates the
JTextPane, the constructor handles adding it (like for other
components).
This change slightly simplifies code, but also prepares for allowing
to change the description text color externally in a later commit.
For the library manager it is not currently strictly needed to have an
instance variable (since the description is only used inside the
constructor), but the instance variable is added for consistency and to
prepare for this same upcoming change.
Previously, for the boards manager:
- InstallerJDialog would set the "selection background" color on the
table, using the "status.notice.bgcolor" the color (default blueish
green). This color is not used directly, but made available for cell
renderers to use.
a1448876a1/app/src/cc/arduino/contributions/ui/InstallerJDialog.java (L183)
- For each cell, either a ContributedPlatformTableCellEditor or
ContributedPlatformTableCellRenderer is used, depending on whether
the cell is being edited (i.e. when selected).
- Both of these create a ContributedPlatformTableCellJPanel, and call
its `update` method, which creates the components for the cell.
- The `update` method als sets the background color of the description
to white, which does not actually have any effect because the
description is not opaque.
a1448876a1/app/src/cc/arduino/contributions/packages/ui/ContributedPlatformTableCellJPanel.java (L271)a1448876a1/app/src/cc/arduino/contributions/packages/ui/ContributedPlatformTableCellJPanel.java (L309)https://docs.oracle.com/javase/7/docs/api/javax/swing/JComponent.html#setBackground(java.awt.Color)
- The `update` method also sets its colors of itself (JPanel) to the FG
and BG color, or the selected FG and BG color of the table depending
on the selected status of the cell. These seem to default to black on
white for non-selected and white on blue-ish for selected cells.
However, InstallJDialog has replaced the selected BG with a blueish
green, as shown above.
Of these, only the BG colors actually seem to take effect. The fg
color of the description component is actually used (default black).
a1448876a1/app/src/cc/arduino/contributions/packages/ui/ContributedPlatformTableCellJPanel.java (L282-L288)
- After calling `update`, ContributedPlatformTableCellEditor overrides
the JPanel background color with a fixed grey color. Similarly,
ContributedPlatformTableCellRenderer sets an alternating white and
(slightly lighter) grey background color. Together, this means that
the background color set by ContributedPlatformTableCellJPanel is
never actually used.
a1448876a1/app/src/cc/arduino/contributions/packages/ui/ContributedPlatformTableCellEditor.java (L132-L133)a1448876a1/app/src/cc/arduino/contributions/packages/ui/ContributedPlatformTableCellRenderer.java (L47-L53)
For the library manager, pretty much the same happens.
Effectively, the only colors that were actually used were the background
colors set by ContributedPlatformTableCellEditor and
ContributedPlatformTableCellRenderer. This is problematic because:
- There is a lot of other confusing and unused code
- The foreground color is never set. This is fine when it is black or
another dark color, but when the system is configured with a dark
theme, the default foreground color will be white, which is
problematic on a white background.
This commit remove the unneeded code, setting the foreground color
is left for later. It also removes the (now unused) `isSelected` from
`ContributedPlatformTableCellJPanel::update`. For the library manager,
the corresponding argument is still used to decide the "author" color.
ContributedLibraryTableCellJPanel.java: Add description to accessibility context
ContributedPlatformTableCellJPanel.java: Add description to accessibility context
ProgressJProgressBar.java:
Add status to accessibility context
make progress bar focusable so screen reader can access