mirror of
https://github.com/cryptomator/cryptomator.git
synced 2024-10-07 01:03:31 +00:00
introduced NotificationBar control
This commit is contained in:
parent
edbeea5502
commit
3497144034
@ -36,6 +36,7 @@ public enum FxmlFile {
|
|||||||
MIGRATION_RUN("/fxml/migration_run.fxml"), //
|
MIGRATION_RUN("/fxml/migration_run.fxml"), //
|
||||||
MIGRATION_START("/fxml/migration_start.fxml"), //
|
MIGRATION_START("/fxml/migration_start.fxml"), //
|
||||||
MIGRATION_SUCCESS("/fxml/migration_success.fxml"), //
|
MIGRATION_SUCCESS("/fxml/migration_success.fxml"), //
|
||||||
|
NOTIFICATION("/fxml/notification.fxml"),
|
||||||
PREFERENCES("/fxml/preferences.fxml"), //
|
PREFERENCES("/fxml/preferences.fxml"), //
|
||||||
QUIT("/fxml/quit.fxml"), //
|
QUIT("/fxml/quit.fxml"), //
|
||||||
QUIT_FORCED("/fxml/quit_forced.fxml"), //
|
QUIT_FORCED("/fxml/quit_forced.fxml"), //
|
||||||
|
@ -0,0 +1,96 @@
|
|||||||
|
package org.cryptomator.ui.controls;
|
||||||
|
|
||||||
|
import org.cryptomator.ui.common.FxmlFile;
|
||||||
|
|
||||||
|
import javafx.beans.property.BooleanProperty;
|
||||||
|
import javafx.beans.property.SimpleBooleanProperty;
|
||||||
|
import javafx.beans.property.SimpleStringProperty;
|
||||||
|
import javafx.beans.property.StringProperty;
|
||||||
|
import javafx.fxml.FXML;
|
||||||
|
import javafx.fxml.FXMLLoader;
|
||||||
|
import javafx.scene.control.Button;
|
||||||
|
import javafx.scene.control.Label;
|
||||||
|
import javafx.scene.layout.HBox;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class NotificationBar extends HBox {
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private Label notificationLabel;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private Button closeButton;
|
||||||
|
|
||||||
|
private final StringProperty textProperty = new SimpleStringProperty();
|
||||||
|
private final BooleanProperty dismissable = new SimpleBooleanProperty();
|
||||||
|
private final BooleanProperty notify = new SimpleBooleanProperty();
|
||||||
|
|
||||||
|
|
||||||
|
public NotificationBar() {
|
||||||
|
loadFXML();
|
||||||
|
closeButton.visibleProperty().bind(dismissable);
|
||||||
|
notificationLabel.textProperty().bind(textProperty);
|
||||||
|
|
||||||
|
visibleProperty().bind(notifyProperty());
|
||||||
|
managedProperty().bind(notifyProperty());
|
||||||
|
|
||||||
|
closeButton.setOnAction(_ -> {
|
||||||
|
visibleProperty().unbind();
|
||||||
|
managedProperty().unbind();
|
||||||
|
visibleProperty().set(false);
|
||||||
|
managedProperty().set(false);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadFXML() {
|
||||||
|
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource(FxmlFile.NOTIFICATION.getRessourcePathString()));
|
||||||
|
fxmlLoader.setController(this);
|
||||||
|
try {
|
||||||
|
HBox content = fxmlLoader.load();
|
||||||
|
this.getChildren().addAll(content.getChildren());
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getText() {
|
||||||
|
return textProperty.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setText(String text) {
|
||||||
|
textProperty.set(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
public StringProperty textProperty() {
|
||||||
|
return textProperty;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStyleClass(String styleClass) {
|
||||||
|
getStyleClass().add(styleClass);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isDismissable() {
|
||||||
|
return dismissable.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDismissable(boolean value) {
|
||||||
|
dismissable.set(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BooleanProperty dismissableProperty() {
|
||||||
|
return dismissable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getNotify() {
|
||||||
|
return notify.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNotify(boolean value) {
|
||||||
|
notify.set(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BooleanProperty notifyProperty() {
|
||||||
|
return notify;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,5 +1,13 @@
|
|||||||
package org.cryptomator.ui.mainwindow;
|
package org.cryptomator.ui.mainwindow;
|
||||||
|
|
||||||
|
import javafx.beans.Observable;
|
||||||
|
import javafx.beans.binding.BooleanBinding;
|
||||||
|
import javafx.beans.property.ObjectProperty;
|
||||||
|
import javafx.beans.property.ReadOnlyBooleanProperty;
|
||||||
|
import javafx.beans.property.ReadOnlyObjectProperty;
|
||||||
|
import javafx.fxml.FXML;
|
||||||
|
import javafx.scene.layout.StackPane;
|
||||||
|
import javafx.stage.Stage;
|
||||||
import org.apache.commons.lang3.SystemUtils;
|
import org.apache.commons.lang3.SystemUtils;
|
||||||
import org.cryptomator.common.LicenseHolder;
|
import org.cryptomator.common.LicenseHolder;
|
||||||
import org.cryptomator.common.settings.Settings;
|
import org.cryptomator.common.settings.Settings;
|
||||||
@ -13,17 +21,6 @@ import org.slf4j.Logger;
|
|||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javafx.beans.Observable;
|
|
||||||
import javafx.beans.binding.Bindings;
|
|
||||||
import javafx.beans.binding.BooleanBinding;
|
|
||||||
import javafx.beans.property.BooleanProperty;
|
|
||||||
import javafx.beans.property.ObjectProperty;
|
|
||||||
import javafx.beans.property.ReadOnlyBooleanProperty;
|
|
||||||
import javafx.beans.property.ReadOnlyObjectProperty;
|
|
||||||
import javafx.beans.property.SimpleBooleanProperty;
|
|
||||||
import javafx.fxml.FXML;
|
|
||||||
import javafx.scene.layout.StackPane;
|
|
||||||
import javafx.stage.Stage;
|
|
||||||
|
|
||||||
@MainWindowScoped
|
@MainWindowScoped
|
||||||
public class MainWindowController implements FxController {
|
public class MainWindowController implements FxController {
|
||||||
@ -37,12 +34,9 @@ public class MainWindowController implements FxController {
|
|||||||
private final UpdateChecker updateChecker;
|
private final UpdateChecker updateChecker;
|
||||||
private final BooleanBinding updateAvailable;
|
private final BooleanBinding updateAvailable;
|
||||||
private final LicenseHolder licenseHolder;
|
private final LicenseHolder licenseHolder;
|
||||||
private final BooleanProperty hideSupportNotificationClicked = new SimpleBooleanProperty(false);
|
|
||||||
private final BooleanProperty supportNotificationHidden = new SimpleBooleanProperty();
|
|
||||||
private final BooleanProperty hideUpdateNotificationClicked = new SimpleBooleanProperty(false);
|
|
||||||
private final BooleanProperty updateNotificationHidden = new SimpleBooleanProperty();
|
|
||||||
|
|
||||||
public StackPane root;
|
@FXML
|
||||||
|
private StackPane root;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public MainWindowController(@MainWindow Stage window, //
|
public MainWindowController(@MainWindow Stage window, //
|
||||||
@ -80,16 +74,12 @@ public class MainWindowController implements FxController {
|
|||||||
window.heightProperty().addListener((_, _, _) -> savePositionalSettings());
|
window.heightProperty().addListener((_, _, _) -> savePositionalSettings());
|
||||||
window.xProperty().addListener((_, _, _) -> savePositionalSettings());
|
window.xProperty().addListener((_, _, _) -> savePositionalSettings());
|
||||||
window.yProperty().addListener((_, _, _) -> savePositionalSettings());
|
window.yProperty().addListener((_, _, _) -> savePositionalSettings());
|
||||||
|
|
||||||
supportNotificationHidden.bind(Bindings.createBooleanBinding(() -> !licenseHolder.isValidLicense() && !hideSupportNotificationClicked.get(), hideSupportNotificationClicked, licenseHolder.validLicenseProperty()));
|
|
||||||
updateNotificationHidden.bind(Bindings.createBooleanBinding(() -> updateAvailable.get() && !hideUpdateNotificationClicked.get(), hideUpdateNotificationClicked, updateAvailable));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean neverTouched() {
|
private boolean neverTouched() {
|
||||||
return (settings.windowHeight.get() == 0) && (settings.windowWidth.get() == 0) && (settings.windowXPosition.get() == 0) && (settings.windowYPosition.get() == 0);
|
return (settings.windowHeight.get() == 0) && (settings.windowWidth.get() == 0) && (settings.windowXPosition.get() == 0) && (settings.windowYPosition.get() == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
|
||||||
public void savePositionalSettings() {
|
public void savePositionalSettings() {
|
||||||
settings.windowWidth.setValue(window.getWidth());
|
settings.windowWidth.setValue(window.getWidth());
|
||||||
settings.windowHeight.setValue(window.getHeight());
|
settings.windowHeight.setValue(window.getHeight());
|
||||||
@ -119,25 +109,11 @@ public class MainWindowController implements FxController {
|
|||||||
appWindows.showPreferencesWindow(SelectedPreferencesTab.UPDATES);
|
appWindows.showPreferencesWindow(SelectedPreferencesTab.UPDATES);
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
|
||||||
public void hideSupportNotification() {
|
|
||||||
this.hideSupportNotificationClicked.setValue(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
public void hideUpdateNotification() {
|
|
||||||
this.hideUpdateNotificationClicked.setValue(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public LicenseHolder getLicenseHolder() {
|
|
||||||
return licenseHolder;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ReadOnlyBooleanProperty debugModeEnabledProperty() {
|
public ReadOnlyBooleanProperty debugModeEnabledProperty() {
|
||||||
return settings.debugMode;
|
return settings.debugMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDebugModeEnabled() {
|
public boolean getDebugModeEnabled() {
|
||||||
return debugModeEnabledProperty().get();
|
return debugModeEnabledProperty().get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,40 +121,16 @@ public class MainWindowController implements FxController {
|
|||||||
return updateAvailable;
|
return updateAvailable;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isUpdateAvailable() {
|
public boolean getUpdateAvailable() {
|
||||||
return updateAvailable.get();
|
return updateAvailable.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public BooleanProperty hideSupportNotificationClickedProperty() {
|
public BooleanBinding licenseValidProperty(){
|
||||||
return hideSupportNotificationClicked;
|
return licenseHolder.validLicenseProperty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isHideSupportNotificationClicked() {
|
public boolean getLicenseValid() {
|
||||||
return hideSupportNotificationClicked.get();
|
return licenseHolder.isValidLicense();
|
||||||
}
|
|
||||||
|
|
||||||
public BooleanProperty supportNotificationHiddenProperty() {
|
|
||||||
return supportNotificationHidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSupportNotificationHidden() {
|
|
||||||
return supportNotificationHidden.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
public BooleanProperty hideUpdateNotificationClickedProperty() {
|
|
||||||
return hideUpdateNotificationClicked;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isHideUpdateNotificationClicked() {
|
|
||||||
return hideUpdateNotificationClicked.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
public BooleanProperty updateNotificationHiddenProperty() {
|
|
||||||
return updateNotificationHidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isUpdateNotificationHidden() {
|
|
||||||
return updateNotificationHidden.get();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,36 +3,31 @@
|
|||||||
<?import javafx.scene.control.SplitPane?>
|
<?import javafx.scene.control.SplitPane?>
|
||||||
<?import javafx.scene.layout.StackPane?>
|
<?import javafx.scene.layout.StackPane?>
|
||||||
<?import javafx.scene.layout.VBox?>
|
<?import javafx.scene.layout.VBox?>
|
||||||
<?import javafx.scene.layout.HBox?>
|
<?import org.cryptomator.ui.controls.NotificationBar?>
|
||||||
<?import javafx.scene.control.Label?>
|
|
||||||
<?import javafx.scene.layout.Region?>
|
|
||||||
<?import javafx.scene.control.Button?>
|
|
||||||
<StackPane xmlns:fx="http://javafx.com/fxml"
|
<StackPane xmlns:fx="http://javafx.com/fxml"
|
||||||
xmlns="http://javafx.com/javafx"
|
xmlns="http://javafx.com/javafx"
|
||||||
fx:id="root"
|
fx:id="root"
|
||||||
fx:controller="org.cryptomator.ui.mainwindow.MainWindowController"
|
fx:controller="org.cryptomator.ui.mainwindow.MainWindowController"
|
||||||
styleClass="main-window">
|
styleClass="main-window">
|
||||||
<VBox minWidth="650">
|
<VBox minWidth="650">
|
||||||
<HBox onMouseClicked="#showUpdatePreferences" alignment="CENTER" styleClass="notification-update" VBox.vgrow="ALWAYS" visible="${controller.updateNotificationHidden}" managed="${controller.updateNotificationHidden}">
|
<NotificationBar onMouseClicked="#showUpdatePreferences"
|
||||||
<Region minWidth="40"/>
|
text="%main.notification.updateAvailable"
|
||||||
<Region HBox.hgrow="ALWAYS"/>
|
dismissable="true"
|
||||||
<Label text="%main.notification.updateAvailable" styleClass="notification-label" />
|
notify="${controller.updateAvailable}"
|
||||||
<Region HBox.hgrow="ALWAYS"/>
|
styleClass="notification-update"/>
|
||||||
<Button minWidth="40" text="X" onMouseClicked="#hideUpdateNotification" style="-fx-background-color: transparent; -fx-text-fill: white; -fx-font-weight: bold;"/>
|
<NotificationBar onMouseClicked="#showContributePreferences"
|
||||||
</HBox>
|
text="%main.notification.support"
|
||||||
<HBox onMouseClicked="#showContributePreferences" alignment="CENTER" styleClass="notification-support" VBox.vgrow="ALWAYS" visible="${controller.supportNotificationHidden}" managed="${controller.supportNotificationHidden}">
|
dismissable="true"
|
||||||
<Region minWidth="40"/>
|
notify="${!controller.licenseValid}"
|
||||||
<Region HBox.hgrow="ALWAYS"/>
|
styleClass="notification-support"/>
|
||||||
<Label text="%main.notification.support" styleClass="notification-label" />
|
|
||||||
<Region HBox.hgrow="ALWAYS"/>
|
|
||||||
<Button minWidth="40" text="X" onMouseClicked="#hideSupportNotification" style="-fx-background-color: transparent; -fx-text-fill: white; -fx-font-weight: bold;"/>
|
|
||||||
</HBox>
|
|
||||||
<SplitPane dividerPositions="0.33" orientation="HORIZONTAL" VBox.vgrow="ALWAYS">
|
<SplitPane dividerPositions="0.33" orientation="HORIZONTAL" VBox.vgrow="ALWAYS">
|
||||||
<fx:include source="vault_list.fxml" SplitPane.resizableWithParent="false"/>
|
<fx:include source="vault_list.fxml" SplitPane.resizableWithParent="false"/>
|
||||||
<fx:include source="vault_detail.fxml" SplitPane.resizableWithParent="true"/>
|
<fx:include source="vault_detail.fxml" SplitPane.resizableWithParent="true"/>
|
||||||
</SplitPane>
|
</SplitPane>
|
||||||
<HBox onMouseClicked="#showGeneralPreferences" alignment="CENTER" styleClass="notification-debug" VBox.vgrow="ALWAYS" visible="${controller.debugModeEnabled}" managed="${controller.debugModeEnabled}">
|
<NotificationBar onMouseClicked="#showGeneralPreferences"
|
||||||
<Label text="DEBUG MODE" styleClass="notification-label"/>
|
text="DEBUG MODE"
|
||||||
</HBox>
|
styleClass="notification-debug"
|
||||||
|
notify="${controller.debugModeEnabled}"/>
|
||||||
</VBox>
|
</VBox>
|
||||||
</StackPane>
|
</StackPane>
|
||||||
|
21
src/main/resources/fxml/notification.fxml
Normal file
21
src/main/resources/fxml/notification.fxml
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<?import javafx.scene.layout.HBox?>
|
||||||
|
<?import javafx.scene.layout.Region?>
|
||||||
|
<?import javafx.scene.control.Label?>
|
||||||
|
<?import javafx.scene.control.Button?>
|
||||||
|
|
||||||
|
<?import javafx.scene.layout.VBox?>
|
||||||
|
<HBox xmlns:fx="http://javafx.com/fxml"
|
||||||
|
xmlns="http://javafx.com/javafx"
|
||||||
|
alignment="CENTER"
|
||||||
|
style="-fx-alignment: center;">
|
||||||
|
<Region minWidth="40"/>
|
||||||
|
<Region HBox.hgrow="ALWAYS"/>
|
||||||
|
<VBox alignment="CENTER" HBox.hgrow="ALWAYS">
|
||||||
|
<Label fx:id="notificationLabel" styleClass="notification-label" style="-fx-alignment: center;"/>
|
||||||
|
</VBox>
|
||||||
|
<Region HBox.hgrow="ALWAYS"/>
|
||||||
|
|
||||||
|
<Button fx:id="closeButton" minWidth="40" text="X" style="-fx-background-color: transparent; -fx-text-fill: white; -fx-font-weight: bold;"/>
|
||||||
|
</HBox>
|
Loading…
Reference in New Issue
Block a user