Refactor + a few improvements to UI #8

Merged
Ecorous merged 5 commits from TheKodeToad/rework-ui into main 2024-06-12 13:37:25 -04:00
4 changed files with 15 additions and 8 deletions
Showing only changes of commit c784a8b286 - Show all commits

View file

@ -4,6 +4,7 @@ import dev.frogmc.frogloader.impl.gui.component.DependencyErrorEntry;
import dev.frogmc.frogloader.impl.mod.ModDependencyResolver;
import javax.swing.*;
import java.awt.*;
import java.util.Objects;
public class BreakingDepPage extends JScrollPane {
@ -47,6 +48,7 @@ public class BreakingDepPage extends JScrollPane {
list.add(result);
});
setViewportView(list);
SwingUtilities.invokeLater(() -> getViewport().setViewPosition(new Point()));
}
}

View file

@ -1,8 +1,7 @@
package dev.frogmc.frogloader.impl.gui.page;
import dev.frogmc.frogloader.impl.util.PlatformUtil;
import javax.swing.*;
import java.awt.*;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
@ -10,18 +9,24 @@ import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
public class ReportPage extends JTextPane {
public class ReportPage extends JScrollPane {
public ReportPage(Path reportPath) {
setEditable(false);
getHorizontalScrollBar().setUnitIncrement(16);
getVerticalScrollBar().setUnitIncrement(16);
JTextPane text = new JTextPane();
text.setEditable(false);
try {
setText(Files.readString(reportPath, StandardCharsets.UTF_8));
text.setText(Files.readString(reportPath, StandardCharsets.UTF_8));
} catch (IOException e) {
StringWriter writer = new StringWriter();
PrintWriter printer = new PrintWriter(writer);
printer.printf("Could not load contents of %s:%n", reportPath);
e.printStackTrace(printer);
}
setViewportView(text);
SwingUtilities.invokeLater(() -> getViewport().setViewPosition(new Point(0, 0)));
}
}

View file

@ -1,12 +1,11 @@
package dev.frogmc.frogloader.impl.gui.page;
import dev.frogmc.frogloader.impl.FrogLoaderImpl;
import dev.frogmc.frogloader.impl.gui.component.DependencyErrorEntry;
import dev.frogmc.frogloader.impl.mod.ModDependencyResolver;
import dev.frogmc.frogloader.impl.mod.ModUtil;
import dev.frogmc.frogloader.impl.util.PlatformUtil;
import javax.swing.*;
import java.awt.*;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Objects;
@ -73,6 +72,7 @@ public class UnfulfilledDepPage extends JScrollPane {
});
setViewportView(list);
SwingUtilities.invokeLater(() -> getViewport().setViewPosition(new Point()));
}
}

View file

@ -153,7 +153,7 @@ public class AccessWidener {
public record Entry(AccessType type, String targetType, String className, String name, String descriptor) {
public Entry(String[] line) {
this(AccessType.of(line[0]), line[1], line[2], line[3], line[4]);
this(AccessType.of(line[0]), line[1], line[2], line.length > 3 ? line[3] : null, line.length > 4 ? line[4] : null);
}
public boolean isAccessGreaterThan(Entry other) {