Skip to content

Commit

Permalink
Support for toast message notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
Riekr committed Mar 11, 2024
1 parent 6d35cde commit dd6d309
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 7 deletions.
10 changes: 7 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
## In progress:

## v0.4.0
- UI:
- Support for [toast message notifications](https://github.com/DJ-Raven/swing-toast-notifications)
- Text Viewer:
- Fix line highlighting if not whole hierarchy is selected in settings
- I/O:
- Autoscale page size to fit text file line length
- General:
- Better detection of other instances
- Updated to flatlaf 3.3
- Increase default page size to 4MB
- Updated to flatlaf 3.4
- Increase default page size to 2MB
- Updated to perspective 2.8.1
- Autoscale page size to fit text file line length

## v0.3.4
- General:
Expand Down
10 changes: 8 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,17 @@ compileJava {

dependencies {
// flatlaf 2.2 has troubles with JSplitPane programmatic divider positioning
implementation 'com.formdev:flatlaf:3.3'
implementation 'com.formdev:flatlaf-intellij-themes:3.3'
implementation 'com.formdev:flatlaf:3.4'
implementation 'com.formdev:flatlaf-extras:3.4'
implementation 'com.formdev:flatlaf-intellij-themes:3.4'

// https://github.com/DJ-Raven/swing-toast-notifications
implementation files('libs/swing-toast-notifications-1.0.1.jar')

implementation 'org.drjekyll:fontchooser:2.5.2'
implementation 'org.nanohttpd:nanohttpd-websocket:2.3.1'
implementation 'com.google.code.gson:gson:2.10.1'

testImplementation 'junit:junit:4.13.2'
compileOnly 'org.jetbrains:annotations:24.1.0'
}
Expand Down
Binary file added libs/swing-toast-notifications-1.0.1.jar
Binary file not shown.
8 changes: 7 additions & 1 deletion src/main/java/org/riekr/jloga/io/TextFileSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import static org.riekr.jloga.utils.MouseListenerBuilder.mouse;
import static org.riekr.jloga.utils.PopupUtils.popupError;
import static org.riekr.jloga.utils.PopupUtils.popupWarning;
import static org.riekr.jloga.utils.TextUtils.humanReadableByteCountSI;

import javax.swing.*;
import java.awt.*;
Expand Down Expand Up @@ -63,6 +64,8 @@
import org.riekr.jloga.utils.CancellableFuture;
import org.riekr.jloga.utils.TextUtils;

import raven.toast.Notifications;

public class TextFileSource implements TextSource {

interface IndexTask {
Expand Down Expand Up @@ -141,7 +144,10 @@ private void reindex(@NotNull ProgressListener indexingListener, boolean autopag
if (autopage) {
@Nullable Integer next = Preferences.PAGE_SIZE.nextOf(_pageSize);
if (next != null && next > _pageSize) {
System.err.println("Trying to increment page size from " + _pageSize + " to " + next);
String msg = "Trying to increment page size from " + humanReadableByteCountSI(_pageSize) + " to " + humanReadableByteCountSI(next);
System.err.println(msg);
Notifications.getInstance()
.show(Notifications.Type.SUCCESS, Notifications.Location.BOTTOM_CENTER, msg);
_pageSize = next;
Preferences.PAGE_SIZE.set(_pageSize);
allowFinish = false;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/riekr/jloga/prefs/Preferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public interface Preferences extends KeyBindings {
.addDescription("Select which threading model should be used for simple searches (eg: plain text and regex).")
.add(SimpleSearchPredicate::getThreadModels);

GUIPreference<Integer> PAGE_SIZE = of("page_size", () -> 1024 * 1024 * 4)
GUIPreference<Integer> PAGE_SIZE = of("page_size", () -> 1024 * 1024 * 2)
.describe(Type.Combo, "Size of disk pages")
.group(IO)
.addDescription("Text files will be read in blocks of this size, a lower size will reduce disk i/o but increase ")
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/org/riekr/jloga/ui/MainPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
import org.riekr.jloga.utils.FileUtils;
import org.riekr.jloga.utils.UIUtils;

import raven.toast.Notifications;

public class MainPanel extends JFrame implements FileDropListener {
private static final long serialVersionUID = -5418006859279219934L;

Expand Down Expand Up @@ -122,6 +124,9 @@ public MainPanel() {
e.printStackTrace(System.err);
}
});

// notifications
Notifications.getInstance().setJFrame(this);
}

private void refreshCurrentTab() {
Expand Down

0 comments on commit dd6d309

Please sign in to comment.