Skip to content

Commit 8caa0b0

Browse files
author
Bytekeeper
committed
Library updates and graphical/usability improvements
1 parent 8471576 commit 8caa0b0

8 files changed

Lines changed: 43 additions & 30 deletions

File tree

build.gradle

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ buildscript {
1111
}
1212

1313
plugins {
14-
id "net.ltgt.apt" version "0.9"
14+
id "net.ltgt.apt" version "0.10"
1515
}
1616

17-
apply plugin: 'application';
18-
apply plugin: 'java';
19-
apply plugin: 'findbugs';
20-
apply plugin: 'pmd';
21-
apply plugin: 'jacoco';
17+
apply plugin: 'application'
18+
apply plugin: 'java'
19+
apply plugin: 'findbugs'
20+
apply plugin: 'pmd'
21+
apply plugin: 'jacoco'
2222
apply plugin: 'com.github.ben-manes.versions'
2323
apply plugin: 'idea'
2424
apply plugin: 'antlr'
@@ -39,13 +39,9 @@ repositories {
3939
version = '2'
4040
archivesBaseName = 'STT'
4141

42-
def javaHome = System.properties['java.home']
43-
4442
sourceCompatibility = 1.8
4543
mainClassName='org.stt.StartWithJFX'
4644

47-
ext.mainClass = mainClassName
48-
4945
findbugs {
5046
excludeFilter = file("$rootProject.projectDir/config/findbugs/excludeFilter.xml")
5147
}
@@ -97,7 +93,7 @@ tasks.withType(FindBugs) {
9793
}
9894

9995
task wrapper(type: Wrapper) {
100-
gradleVersion = '3.4'
96+
gradleVersion = '3.5'
10197
}
10298

10399
task release(dependsOn: 'distZip') {

src/main/java/org/stt/gui/jfx/ActivitiesController.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ public void onAchievementsRefresh(AchievementsUpdated refreshedAchievements) {
158158
updateAchievements();
159159
}
160160

161-
@Handler(priority = -1)
161+
@Handler
162162
public void onItemChange(ItemModified event) {
163163
updateItems();
164164
}
@@ -315,9 +315,9 @@ private ObservableList<String> createSuggestionsForContinuationList() {
315315

316316
@FXML
317317
public void initialize() {
318-
if (activitiesConfig.isAutoCompletionPopup()) {
319-
setupAutoCompletionPopup();
320-
}
318+
// if (activitiesConfig.isAutoCompletionPopup()) {
319+
// setupAutoCompletionPopup();
320+
// }
321321

322322
addWorktimePanel();
323323
addCommandText();

src/main/java/org/stt/gui/jfx/ReportController.java

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,16 @@
2424
import javafx.scene.text.Font;
2525
import javafx.scene.text.Text;
2626
import javafx.scene.text.TextFlow;
27+
import net.engio.mbassy.bus.MBassador;
28+
import net.engio.mbassy.listener.Handler;
29+
import net.engio.mbassy.listener.Listener;
30+
import net.engio.mbassy.listener.References;
2731
import org.controlsfx.control.NotificationPane;
2832
import org.stt.config.ReportConfig;
2933
import org.stt.gui.jfx.binding.MappedListBinding;
3034
import org.stt.gui.jfx.binding.ReportBinding;
3135
import org.stt.gui.jfx.binding.STTBindings;
36+
import org.stt.model.ItemModified;
3237
import org.stt.query.TimeTrackingItemQueries;
3338
import org.stt.reporting.SummingReportGenerator.Report;
3439
import org.stt.text.ItemGrouper;
@@ -89,6 +94,7 @@ public class ReportController {
8994

9095
private NotificationPane panel;
9196
private Font fontaweSome;
97+
private final MBassador<Object> eventBus;
9298
private PauseTransition notificationPause = new PauseTransition(javafx.util.Duration.seconds(2));
9399
private TemporalField dayOfWeekField = WeekFields.of(Locale.getDefault()).dayOfWeek();
94100
private Set<LocalDate> trackedDays;
@@ -99,13 +105,15 @@ public class ReportController {
99105
DurationRounder rounder,
100106
ItemGrouper itemGrouper,
101107
ReportConfig config,
102-
@Named("glyph") Font fontaweSome) {
108+
@Named("glyph") Font fontaweSome,
109+
MBassador<Object> eventBus) {
103110
this.localization = requireNonNull(localization);
104111
this.config = requireNonNull(config);
105112
this.timeTrackingItemQueries = requireNonNull(searcher);
106113
this.rounder = requireNonNull(rounder);
107114
this.itemGrouper = requireNonNull(itemGrouper);
108115
this.fontaweSome = requireNonNull(fontaweSome);
116+
this.eventBus = requireNonNull(eventBus);
109117

110118
List<String> colorStrings = config.getGroupColors();
111119
groupColors = new Color[colorStrings.size()];
@@ -142,7 +150,8 @@ public void initialize() {
142150
tableForReport.getSelectionModel().selectedIndexProperty().addListener(i ->
143151
Platform.runLater(tableForReport.getSelectionModel()::clearSelection));
144152

145-
final ObservableValue<Report> reportModel = createReportModel();
153+
final ObjectBinding<Report> reportModel = createReportModel();
154+
eventBus.subscribe(new OnItemChangeListener(reportModel));
146155
final StringBinding startBinding = createBindingForStartOfReport(reportModel);
147156
final StringBinding endBinding = createBindingForEndOfReport(reportModel);
148157
final ObjectBinding<Duration> uncoveredTimeBinding = createBindingForUncoveredTimeOfReport(reportModel);
@@ -237,7 +246,7 @@ public void updateItem(LocalDate item, boolean empty) {
237246
toolbar.getItems().add(oneWeekForward);
238247
}
239248

240-
private ObservableValue<Report> createReportModel() {
249+
private ObjectBinding<Report> createReportModel() {
241250
ObservableValue<LocalDate> nextDay = Bindings.createObjectBinding(
242251
() -> datePicker.getValue() != null ? datePicker
243252
.getValue().plusDays(1) : null, datePicker.valueProperty());
@@ -467,4 +476,18 @@ public Duration getRoundedDuration() {
467476
return roundedDuration;
468477
}
469478
}
479+
480+
@Listener(references = References.Strong)
481+
private static class OnItemChangeListener {
482+
private final ObjectBinding<?> binding;
483+
484+
private OnItemChangeListener(ObjectBinding<?> binding) {
485+
this.binding = binding;
486+
}
487+
488+
@Handler
489+
public void onItemChanged(ItemModified changeEvent) {
490+
binding.invalidate();
491+
}
492+
}
470493
}

src/main/java/org/stt/gui/jfx/TimeTrackingItemCell.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ class TimeTrackingItemCell extends ListCell<TimeTrackingItem> {
100100
setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
101101
}
102102

103-
private VBox createDateSubheader(Font fontAwesome) {
103+
private Node createDateSubheader(Font fontAwesome) {
104104
HBox newDayHbox = new HBox(5);
105105
newDayHbox.setPadding(new Insets(2));
106106
Label calenderIcon = glyph(fontAwesome, Glyph.CALENDAR);
@@ -112,7 +112,7 @@ private VBox createDateSubheader(Font fontAwesome) {
112112
() -> itemProperty().get() == null ? "" : DATE_FORMATTER.format(itemProperty().get().getStart()),
113113
itemProperty()));
114114
newDayHbox.getChildren().add(dayLabel);
115-
return new VBox(10, new Separator(), newDayHbox);
115+
return newDayHbox;
116116
}
117117

118118
protected void setupTooltips(ResourceBundle localization) {

src/main/java/org/stt/query/TimeTrackingItemQueries.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public TimeTrackingItemQueries(Provider<ItemReader> provider,
3535
eventbus.ifPresent(bus -> bus.subscribe(this));
3636
}
3737

38-
@Handler
38+
@Handler(priority = Integer.MAX_VALUE)
3939
public synchronized void sourceChanged(ItemModified event) {
4040
cachedItems = null;
4141
LOG.fine("Clearing query cache");

src/main/resources/org/stt/gui/jfx/Activities.css

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,3 @@
99
}
1010

1111
.value { -fx-fill: blue; }
12-
13-
.list-cell:odd { -fx-background-color: transparent; }
14-
.list-cell:even{ -fx-background-color: transparent; }
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
.table-view {
2-
-fx-control-inner-background-alt: -fx-control-inner-background;
3-
}
4-
51
.table-cell {
6-
-fx-border-color: transparent transparent -fx-table-cell-border-color transparent;
2+
-fx-border-color: transparent;
73
-fx-padding: 1em;
84
}

src/test/java/org/stt/gui/jfx/binding/ReportBindingTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ public class ReportBindingTest {
4242
@Before
4343
public void setup() {
4444
readerProvider = () -> itemReader;
45-
sut = new ReportBinding(reportStart, reportEnd, new TimeTrackingItemQueries(readerProvider, Optional.empty()));
45+
sut = new ReportBinding(reportStart, reportEnd,
46+
new TimeTrackingItemQueries(readerProvider, Optional.empty()));
4647
}
4748

4849
@Test

0 commit comments

Comments
 (0)