Fix code inspection warnings

This commit is contained in:
mkpaz 2023-05-27 20:40:09 +04:00
parent 1f820e41bb
commit f4f1309372
28 changed files with 44 additions and 123 deletions

@ -70,7 +70,7 @@ public class ModalPane extends Control {
// Properties //
///////////////////////////////////////////////////////////////////////////
protected ObjectProperty<Node> content = new SimpleObjectProperty<>(this, "content", null);
protected final ObjectProperty<Node> content = new SimpleObjectProperty<>(this, "content", null);
public Node getContent() {
return content.get();
@ -89,7 +89,7 @@ public class ModalPane extends Control {
// ~
protected BooleanProperty display = new SimpleBooleanProperty(this, "display", false);
protected final BooleanProperty display = new SimpleBooleanProperty(this, "display", false);
public boolean isDisplay() {
return display.get();
@ -109,7 +109,7 @@ public class ModalPane extends Control {
// ~
protected ObjectProperty<Pos> alignment = new SimpleObjectProperty<>(this, "alignment", Pos.CENTER);
protected final ObjectProperty<Pos> alignment = new SimpleObjectProperty<>(this, "alignment", Pos.CENTER);
public Pos getAlignment() {
return alignment.get();
@ -128,7 +128,7 @@ public class ModalPane extends Control {
// ~
protected ObjectProperty<Function<Node, Animation>> inTransitionFactory = new SimpleObjectProperty<>(
protected final ObjectProperty<Function<Node, Animation>> inTransitionFactory = new SimpleObjectProperty<>(
this, "inTransitionFactory", node -> Animations.zoomIn(node, DEFAULT_DURATION_IN)
);
@ -150,7 +150,7 @@ public class ModalPane extends Control {
// ~
protected ObjectProperty<Function<Node, Animation>> outTransitionFactory = new SimpleObjectProperty<>(
protected final ObjectProperty<Function<Node, Animation>> outTransitionFactory = new SimpleObjectProperty<>(
this, "outTransitionFactory", node -> Animations.zoomOut(node, DEFAULT_DURATION_OUT)
);
@ -172,7 +172,7 @@ public class ModalPane extends Control {
// ~
protected BooleanProperty persistent = new SimpleBooleanProperty(this, "persistent", false);
protected final BooleanProperty persistent = new SimpleBooleanProperty(this, "persistent", false);
public boolean getPersistent() {
return persistent.get();

@ -23,16 +23,16 @@ public class Tile extends Control {
}
public Tile(@NamedArg("title") String title,
@NamedArg("subtitle") String subtitle) {
this(title, subtitle, null);
@NamedArg("subTitle") String subTitle) {
this(title, subTitle, null);
}
public Tile(@NamedArg("title") String title,
@NamedArg("subtitle") String subtitle,
@NamedArg("subTitle") String subTitle,
@NamedArg("graphic") Node graphic) {
super();
setTitle(title);
setSubTitle(subtitle);
setSubTitle(subTitle);
setGraphic(graphic);
}

@ -85,10 +85,12 @@ public class ToggleSwitch extends Labeled implements Toggle {
private BooleanProperty selected;
@Override
public final void setSelected(boolean value) {
selectedProperty().set(value);
}
@Override
public final boolean isSelected() {
return selected != null && selected.get();
}
@ -96,6 +98,7 @@ public class ToggleSwitch extends Labeled implements Toggle {
/**
* Returns whether this Toggle Switch is selected.
*/
@Override
public final BooleanProperty selectedProperty() {
if (selected == null) {
selected = new BooleanPropertyBase() {
@ -121,7 +124,7 @@ public class ToggleSwitch extends Labeled implements Toggle {
// "!tg.getSelectedToggle().isSelected()"
// looks like absurd and should always return false.
if (!tg.getSelectedToggle().isSelected()) {
for (Toggle toggle: tg.getToggles()) {
for (Toggle toggle : tg.getToggles()) {
if (toggle.isSelected()) {
return;
}

@ -22,7 +22,7 @@ import javafx.util.Duration;
import org.jetbrains.annotations.Nullable;
/**
* <p>DeckPane represents a pane that displays all of its child nodes in a deck,
* DeckPane represents a pane that displays all of its child nodes in a deck,
* where only one node can be visible at a time. It does not maintain any sequence
* (model), but only cares about the top node, which can be changed by various
* transition effects.<p/>
@ -32,12 +32,12 @@ import org.jetbrains.annotations.Nullable;
* <p>DeckPane manages {@link Node#viewOrderProperty()} of its children. Topmost
* visible node always has a higher view order value, while the rest of the nodes
* have the default value, which is zero. Following that logic, one must not set
* child nodes view order manually, because it will break the contract.<p/>
* child nodes view order manually, because it will break the contract.
*
* <p>If all child nodes have the same view order value (default state after creating
* a new DeckPane), they are displayed in order specified by the root container, which
* is {@link AnchorPane}. When a node is removed from the pane, its view order is
* restored automatically.<p/>
* restored automatically.
*/
public class DeckPane extends AnchorPane {

@ -3,7 +3,6 @@
package atlantafx.base.theme;
import atlantafx.base.Preview;
import org.jetbrains.annotations.Nullable;
/**
* A theme based on <a href="https://developer.apple.com/design/">IOS</a> color palette.

@ -243,6 +243,7 @@ public final class Styles {
* @param prop the name of the style property to remove
* @throws NullPointerException if node is null
*/
@SuppressWarnings("StringSplitter")
public static void removeStyle(Node node, String prop) {
if (node == null) {
throw new NullPointerException("Node cannot be null!");

@ -176,9 +176,9 @@ public interface BBCodeHandler {
protected static final int OL_LETTER_OFFSET = 100_000;
protected final Block root;
protected final Deque<Tag> openTags = new ArrayDeque<>();
protected final Deque<Block> openBlocks = new ArrayDeque<>();
protected char[] doc;
protected Deque<Tag> openTags = new ArrayDeque<>();
protected Deque<Block> openBlocks = new ArrayDeque<>();
protected int textCursor;
/**

@ -10,9 +10,9 @@ import org.junit.jupiter.api.Test;
public class StylesTest {
PseudoClass pcFirst = PseudoClass.getPseudoClass("first");
PseudoClass pcSecond = PseudoClass.getPseudoClass("second");
PseudoClass pcExcluded = PseudoClass.getPseudoClass("excluded");
final PseudoClass pcFirst = PseudoClass.getPseudoClass("first");
final PseudoClass pcSecond = PseudoClass.getPseudoClass("second");
final PseudoClass pcExcluded = PseudoClass.getPseudoClass("excluded");
@Test
@SuppressWarnings("DataFlowIssue")

@ -149,12 +149,6 @@ class MainLayer extends BorderPane {
.orElse(null);
final Page nextPage = pageClass.getDeclaredConstructor().newInstance();
model.setPageData(
nextPage.getName(),
nextPage.canChangeThemeSettings(),
nextPage.canDisplaySourceCode()
);
// startup, no prev page, no animation
if (getScene() == null) {
subLayerPane.getChildren().add(nextPage.getView());

@ -64,21 +64,15 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import javafx.beans.property.ReadOnlyBooleanProperty;
import javafx.beans.property.ReadOnlyBooleanWrapper;
import javafx.beans.property.ReadOnlyObjectProperty;
import javafx.beans.property.ReadOnlyObjectWrapper;
import javafx.beans.property.ReadOnlyStringProperty;
import javafx.beans.property.ReadOnlyStringWrapper;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import org.kordamp.ikonli.javafx.FontIcon;
import org.kordamp.ikonli.material2.Material2OutlinedAL;
import org.kordamp.ikonli.material2.Material2OutlinedMZ;
public class MainModel {
public static Class<? extends Page> DEFAULT_PAGE = ThemePage.class;
public static final Class<? extends Page> DEFAULT_PAGE = ThemePage.class;
private static final Map<Class<? extends Page>, NavTree.Item> NAV_TREE = createNavItems();
@ -105,33 +99,6 @@ public class MainModel {
// Properties //
///////////////////////////////////////////////////////////////////////////
private final StringProperty searchText = new SimpleStringProperty();
public StringProperty searchTextProperty() {
return searchText;
}
// ~
private final ReadOnlyStringWrapper title = new ReadOnlyStringWrapper();
public ReadOnlyStringProperty titleProperty() {
return title.getReadOnlyProperty();
}
// ~
private final ReadOnlyBooleanWrapper themeChangeToggle = new ReadOnlyBooleanWrapper();
public ReadOnlyBooleanProperty themeChangeToggleProperty() {
return themeChangeToggle.getReadOnlyProperty();
}
// ~
private final ReadOnlyBooleanWrapper sourceCodeToggle = new ReadOnlyBooleanWrapper();
public ReadOnlyBooleanProperty sourceCodeToggleProperty() {
return sourceCodeToggle.getReadOnlyProperty();
}
// ~
private final ReadOnlyObjectWrapper<Class<? extends Page>> selectedPage = new ReadOnlyObjectWrapper<>();
@ -342,12 +309,6 @@ public class MainModel {
// Commands //
///////////////////////////////////////////////////////////////////////////
public void setPageData(String text, boolean canChangeTheme, boolean canDisplaySource) {
title.set(Objects.requireNonNull(text));
themeChangeToggle.set(canChangeTheme);
sourceCodeToggle.set(canDisplaySource);
}
public void navigate(Class<? extends Page> page) {
selectedPage.set(Objects.requireNonNull(page));
currentSubLayer.set(PAGE);

@ -17,8 +17,8 @@ import javafx.scene.layout.VBox;
public abstract class ModalDialog extends DialogPane {
protected Card content = new Card();
protected Tile header = new Tile();
protected final Card content = new Card();
protected final Tile header = new Tile();
public ModalDialog() {
super("#" + ApplicationWindow.MAIN_MODAL_ID);

@ -13,7 +13,6 @@ import javafx.css.PseudoClass;
import javafx.geometry.Pos;
import javafx.scene.Cursor;
import javafx.scene.Node;
import javafx.scene.control.ContentDisplay;
import javafx.scene.control.Label;
import javafx.scene.control.TreeCell;
import javafx.scene.control.TreeItem;

@ -53,11 +53,6 @@ public abstract class AbstractPage extends StackPane implements Page {
return true;
}
@Override
public boolean canChangeThemeSettings() {
return true;
}
@Override
public @Nullable URI getJavadocUri() {
return URI.create(String.format(JFX_JAVADOC_URI_TEMPLATE, "control/" + getName()));

@ -76,7 +76,7 @@ public abstract class OutlinePage extends StackPane implements Page {
protected Consumer<Heading> createOutlineHandler() {
return heading -> {
if (heading != Heading.TOP) {
if (!Objects.equals(heading, Heading.TOP)) {
Parent container = heading.anchor().getParent();
int indexInParent = container.getChildrenUnmodifiable().indexOf(heading.anchor());
@ -164,11 +164,6 @@ public abstract class OutlinePage extends StackPane implements Page {
return true;
}
@Override
public boolean canChangeThemeSettings() {
return true;
}
@Override
public @Nullable URI getJavadocUri() {
return URI.create(String.format(JFX_JAVADOC_URI_TEMPLATE, "control/" + getName()));

@ -55,8 +55,6 @@ public interface Page {
boolean canDisplaySourceCode();
boolean canChangeThemeSettings();
@Nullable URI getJavadocUri();
@Nullable Node getSnapshotTarget();

@ -3,6 +3,7 @@
package atlantafx.sampler.page;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Objects;
import javafx.scene.Node;
import javafx.scene.layout.HBox;
@ -38,7 +39,7 @@ public final class Snippet {
try (var stream = sourceClass.getResourceAsStream(sourceFileName)) {
Objects.requireNonNull(stream, "Missing source file '" + sourceFileName + "';");
var sourceCode = new String(stream.readAllBytes());
var sourceCode = new String(stream.readAllBytes(), StandardCharsets.UTF_8);
var startTag = "//snippet_" + id + ":start";
var endTag = "//snippet_" + id + ":end";
var start = sourceCode.indexOf(startTag);

@ -132,11 +132,6 @@ public final class AnimationsPage extends StackPane implements Page {
return true;
}
@Override
public boolean canChangeThemeSettings() {
return true;
}
@Override
public URI getJavadocUri() {
return URI.create(String.format(AFX_JAVADOC_URI_TEMPLATE, "util/" + getName()));
@ -154,6 +149,7 @@ public final class AnimationsPage extends StackPane implements Page {
///////////////////////////////////////////////////////////////////////////
// this method isn't used anywhere
@SuppressWarnings("unused")
private void snippetText() {
//snippet_1:start
var rectangle = new Rectangle(100, 100);

@ -28,7 +28,7 @@ public final class BreadcrumbsPage extends OutlinePage {
}
@Override
public @Nullable URI getJavadocUri() {
public URI getJavadocUri() {
return URI.create(String.format(AFX_JAVADOC_URI_TEMPLATE, "controls/" + getName()));
}

@ -20,7 +20,6 @@ import javafx.scene.Cursor;
import javafx.scene.control.Label;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import org.jetbrains.annotations.Nullable;
import org.kordamp.ikonli.feather.Feather;
import org.kordamp.ikonli.javafx.FontIcon;
import org.kordamp.ikonli.material2.Material2OutlinedAL;
@ -151,6 +150,7 @@ public final class CustomTextFieldPage extends OutlinePage {
timeField.textProperty().addListener((obs, old, val) -> {
if (val != null) {
try {
//noinspection ResultOfMethodCallIgnored
LocalTime.parse(val, timeFormatter);
timeField.pseudoClassStateChanged(Styles.STATE_DANGER, false);
} catch (DateTimeParseException e) {

@ -79,7 +79,7 @@ public final class ToolBarPage extends OutlinePage {
private ExampleBox usageExample() {
//snippet_1:start
var toolbar1 = new ToolBar(
final var toolbar1 = new ToolBar(
new Button("New", new FontIcon(Feather.PLUS)),
new Button("Open", new FontIcon(Feather.FILE)),
new Button("Save", new FontIcon(Feather.SAVE)),
@ -102,7 +102,7 @@ public final class ToolBarPage extends OutlinePage {
));
fontSizeCmb.getSelectionModel().select(6);
var toolbar2 = new ToolBar(
final var toolbar2 = new ToolBar(
fontFamilyCmb,
fontSizeCmb,
new Separator(Orientation.VERTICAL),
@ -131,7 +131,7 @@ public final class ToolBarPage extends OutlinePage {
new MenuItem("Action 3")
);
var toolbar3 = new ToolBar(
final var toolbar3 = new ToolBar(
iconButton(Feather.CHEVRON_LEFT),
iconButton(Feather.CHEVRON_RIGHT),
new Separator(Orientation.VERTICAL),

@ -24,7 +24,7 @@ public final class BBCodePage extends OutlinePage {
}
@Override
public @Nullable URI getJavadocUri() {
public URI getJavadocUri() {
return URI.create(String.format(AFX_JAVADOC_URI_TEMPLATE, "util/BBCodeParser"));
}

@ -59,11 +59,6 @@ public final class ThemePage extends OutlinePage {
return false;
}
@Override
public boolean canChangeThemeSettings() {
return false;
}
@Override
public @Nullable URI getJavadocUri() {
return null;

@ -191,7 +191,7 @@ public final class TypographyPage extends OutlinePage {
new StyledText("300", "-fx-font-weight:300;"),
new StyledText("200", "-fx-font-weight:200;"),
new StyledText("100", "-fx-font-weight:100;"),
new Text("\uD83E\uDC60 no difference")
new Text("🡠 no difference")
);
sample2.setAlignment(Pos.BASELINE_LEFT);
@ -210,7 +210,7 @@ public final class TypographyPage extends OutlinePage {
new StyledText("300", "-fx-font-family:'Inter Light';"),
new StyledText("200", "-fx-font-family:'Inter Extra Light';"),
new StyledText("100", "-fx-font-family:'Inter Thin';"),
new Text("\uD83E\uDC60 workaround")
new Text("🡠 workaround")
);
sample3.setAlignment(Pos.BASELINE_LEFT);
//snippet_2:end

@ -64,11 +64,6 @@ public final class BlueprintsPage extends ScrollPane implements Page {
return true;
}
@Override
public boolean canChangeThemeSettings() {
return true;
}
@Override
public @Nullable URI getJavadocUri() {
return null;

@ -66,11 +66,6 @@ public final class OverviewPage extends ScrollPane implements Page {
return true;
}
@Override
public boolean canChangeThemeSettings() {
return true;
}
@Override
public @Nullable URI getJavadocUri() {
return null;

@ -28,13 +28,13 @@ public abstract class ShowcasePage extends StackPane implements Page {
protected static final int DEFAULT_WIDTH = 800;
protected static final int DEFAULT_HEIGHT = 600;
protected VBox showcaseWindow = new VBox();
protected Label windowTitle = new Label();
protected VBox showCaseContent = new VBox();
protected FontIcon aboutBtn = new FontIcon(Feather.HELP_CIRCLE);
protected final VBox showcaseWindow = new VBox();
protected final Label windowTitle = new Label();
protected final VBox showCaseContent = new VBox();
protected final FontIcon aboutBtn = new FontIcon(Feather.HELP_CIRCLE);
protected final BooleanProperty maximized = new SimpleBooleanProperty();
protected int windowWidth = DEFAULT_WIDTH;
protected int windowHeight = DEFAULT_HEIGHT;
protected BooleanProperty maximized = new SimpleBooleanProperty();
public ShowcasePage() {
super();
@ -119,11 +119,6 @@ public abstract class ShowcasePage extends StackPane implements Page {
return false;
}
@Override
public boolean canChangeThemeSettings() {
return true;
}
@Override
public @Nullable URI getJavadocUri() {
return null;

@ -75,7 +75,7 @@ final class TableDirectoryView extends AnchorPane implements DirectoryView {
table.getColumns().setAll(filenameCol, sizeCol, mtimeCol);
table.getSortOrder().add(filenameCol);
table.setSortPolicy(param -> true);
table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY_FLEX_LAST_COLUMN);
filenameCol.minWidthProperty().bind(table.widthProperty().multiply(0.5));
table.setRowFactory(param -> {
TableRow<Path> row = new TableRow<>();

@ -44,7 +44,6 @@ import javafx.scene.layout.VBox;
import javafx.scene.media.Media;
import javafx.scene.media.MediaPlayer;
import javafx.scene.paint.ImagePattern;
import javafx.scene.shape.Circle;
import javafx.scene.shape.Rectangle;
import javafx.util.Duration;
import org.kordamp.ikonli.javafx.FontIcon;