added vault list and vault detail view

This commit is contained in:
Sebastian Stenzel 2019-07-15 11:32:49 +02:00
parent 180c07cf61
commit cfea1c16bc
No known key found for this signature in database
GPG Key ID: 667B866EA8240A09
17 changed files with 217 additions and 96 deletions

5
.idea/compiler.xml generated
View File

@ -23,14 +23,11 @@
<entry name="$MAVEN_REPOSITORY$/com/google/errorprone/javac-shaded/9-dev-r4023-3/javac-shaded-9-dev-r4023-3.jar" />
<entry name="$MAVEN_REPOSITORY$/javax/annotation/jsr250-api/1.0/jsr250-api-1.0.jar" />
</processorPath>
<module name="commons" />
<module name="keychain" />
<module name="launcher" />
<module name="commons" />
<module name="ui" />
</profile>
</annotationProcessing>
<bytecodeTargetLevel>
<module name="buildkit" target="11" />
</bytecodeTargetLevel>
</component>
</project>

1
.idea/modules.xml generated
View File

@ -3,7 +3,6 @@
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/Desktop.iml" filepath="$PROJECT_DIR$/.idea/Desktop.iml" />
<module fileurl="file://$PROJECT_DIR$/main/buildkit/buildkit.iml" filepath="$PROJECT_DIR$/main/buildkit/buildkit.iml" />
</modules>
</component>
</project>

View File

@ -89,11 +89,7 @@ public class Cryptomator {
private int runGuiApplication() {
try {
shutdownPerformer.registerShutdownHook();
Platform.startup(() -> {
assert Platform.isFxApplicationThread();
FxApplication app = CRYPTOMATOR_COMPONENT.fxApplicationComponent().application();
app.start();
});
CRYPTOMATOR_COMPONENT.fxApplicationComponent().start();
shutdownLatch.await();
LOG.info("UI shut down");
return 0;

View File

@ -6,11 +6,20 @@
package org.cryptomator.ui;
import dagger.Subcomponent;
import javafx.application.Application;
import javafx.application.Platform;
@FxApplicationScoped
@Subcomponent(modules = FxApplicationModule.class)
public interface FxApplicationComponent {
FxApplication application();
default void start() {
Platform.startup(() -> {
assert Platform.isFxApplicationThread();
application().start();
});
}
}

View File

@ -15,10 +15,8 @@ import org.apache.commons.lang3.SystemUtils;
import org.cryptomator.common.settings.Settings;
import org.cryptomator.frontend.webdav.WebDavServer;
import org.cryptomator.keychain.KeychainModule;
import org.cryptomator.ui.controllers.ViewControllerModule;
import org.cryptomator.ui.mainwindow.MainWindowModule;
import org.cryptomator.ui.model.VaultComponent;
import org.cryptomator.ui.vaultlist.VaultListModule;
import org.fxmisc.easybind.EasyBind;
import javax.inject.Named;
@ -29,7 +27,7 @@ import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer;
@Module(includes = {ViewControllerModule.class, KeychainModule.class, VaultListModule.class, MainWindowModule.class}, subcomponents = {VaultComponent.class})
@Module(includes = {KeychainModule.class, MainWindowModule.class}, subcomponents = {VaultComponent.class})
public class UiModule {
private static final int NUM_SCHEDULER_THREADS = 4;

View File

@ -2,10 +2,16 @@ package org.cryptomator.ui.mainwindow;
import dagger.Binds;
import dagger.Module;
import dagger.Provides;
import dagger.multibindings.IntoMap;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.collections.ObservableList;
import org.cryptomator.ui.FxApplicationScoped;
import org.cryptomator.ui.FxController;
import org.cryptomator.ui.FxControllerKey;
import org.cryptomator.ui.vaultlist.VaultListController;
import org.cryptomator.ui.model.Vault;
import org.cryptomator.ui.model.VaultList;
@Module
public abstract class MainWindowModule {
@ -13,6 +19,27 @@ public abstract class MainWindowModule {
@Binds
@IntoMap
@FxControllerKey(MainWindowController.class)
abstract FxController bindController(MainWindowController controller);
abstract FxController bindMainWindowController(MainWindowController controller);
@Binds
@IntoMap
@FxControllerKey(VaultListController.class)
abstract FxController bindVaultListController(VaultListController controller);
@Binds
@IntoMap
@FxControllerKey(VaultDetailController.class)
abstract FxController bindVaultDetailController(VaultDetailController controller);
// ------------------
@Binds
abstract ObservableList<Vault> provideVaults(VaultList vaultList);
@Provides
@FxApplicationScoped
static ObjectProperty<Vault> provideSelectedVault() {
return new SimpleObjectProperty<>();
}
}

View File

@ -0,0 +1,32 @@
package org.cryptomator.ui.mainwindow;
import javafx.beans.property.ObjectProperty;
import org.cryptomator.ui.FxApplicationScoped;
import org.cryptomator.ui.FxController;
import org.cryptomator.ui.model.Vault;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.inject.Inject;
@FxApplicationScoped
public class VaultDetailController implements FxController {
private static final Logger LOG = LoggerFactory.getLogger(VaultDetailController.class);
private final ObjectProperty<Vault> vault;
@Inject
VaultDetailController(ObjectProperty<Vault> vault) {
this.vault = vault;
}
public ObjectProperty<Vault> vaultProperty() {
return vault;
}
public Vault getVault() {
return vault.get();
}
}

View File

@ -0,0 +1,47 @@
package org.cryptomator.ui.mainwindow;
import javafx.beans.binding.Bindings;
import javafx.beans.property.ObjectProperty;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.ListView;
import javafx.scene.layout.AnchorPane;
import org.cryptomator.ui.FxApplicationScoped;
import org.cryptomator.ui.FxController;
import org.cryptomator.ui.model.Vault;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.inject.Inject;
@FxApplicationScoped
public class VaultListController implements FxController {
private static final Logger LOG = LoggerFactory.getLogger(VaultListController.class);
private final ObservableList<Vault> vaults;
private final ObjectProperty<Vault> selectedVault;
public ListView vaultList;
public AnchorPane onboardingOverlay;
@Inject
public VaultListController(ObservableList<Vault> vaults, ObjectProperty<Vault> selectedVault) {
this.vaults = vaults;
this.selectedVault = selectedVault;
}
@FXML
public void initialize() {
LOG.debug("init VaultListController");
onboardingOverlay.visibleProperty().bind(Bindings.isEmpty(vaults));
vaultList.setItems(vaults);
selectedVault.bind(vaultList.getSelectionModel().selectedItemProperty());
}
public void didClickAddVault(ActionEvent actionEvent) {
}
public void didClickRemoveVault(ActionEvent actionEvent) {
}
}

View File

@ -1,25 +0,0 @@
package org.cryptomator.ui.vaultlist;
import javafx.fxml.FXML;
import org.cryptomator.ui.FxApplicationScoped;
import org.cryptomator.ui.FxController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.inject.Inject;
@FxApplicationScoped
public class VaultListController implements FxController {
private static final Logger LOG = LoggerFactory.getLogger(VaultListController.class);
@Inject
public VaultListController() {
}
@FXML
public void initialize() {
LOG.debug("init VaultListController");
}
}

View File

@ -1,17 +0,0 @@
package org.cryptomator.ui.vaultlist;
import dagger.Binds;
import dagger.Module;
import dagger.multibindings.IntoMap;
import org.cryptomator.ui.FxController;
import org.cryptomator.ui.FxControllerKey;
@Module
public abstract class VaultListModule {
@Binds
@IntoMap
@FxControllerKey(VaultListController.class)
abstract FxController bindController(VaultListController controller);
}

View File

@ -8,31 +8,33 @@
<?import javafx.scene.layout.VBox?>
<VBox xmlns="http://javafx.com/javafx"
xmlns:fx="http://javafx.com/fxml"
fx:controller="org.cryptomator.ui.mainwindow.MainWindowController">
<children>
<HBox fx:id="titleBar" alignment="CENTER_RIGHT" prefHeight="49.0" prefWidth="600.0" style="-fx-background-color: #79b01a;">
<padding>
<Insets bottom="6.0" left="6.0" right="6.0" top="6.0"/>
</padding>
<children>
<Button contentDisplay="GRAPHIC_ONLY" mnemonicParsing="false" style="-fx-background-color: none;" text="Button">
<graphic>
<FontAwesomeIconView fill="WHITE" glyphName="COGS"/>
</graphic>
<tooltip>
<Tooltip text="%main.settingsBtn.tooltip"/>
</tooltip>
</Button>
<Button contentDisplay="GRAPHIC_ONLY" layoutX="612.0" layoutY="16.0" mnemonicParsing="false" onAction="#close" style="-fx-background-color: none;" text="Button">
<graphic>
<FontAwesomeIconView fill="WHITE" glyphName="CLOSE"/>
</graphic>
<tooltip>
<Tooltip text="%main.closeBtn.tooltip"/>
</tooltip>
</Button>
</children>
</HBox>
<fx:include source="/fxml/vaultlist.fxml"/>
</children>
fx:controller="org.cryptomator.ui.mainwindow.MainWindowController"
styleClass="main-window">
<HBox styleClass="title" fx:id="titleBar" alignment="CENTER_RIGHT" minHeight="50" maxHeight="50" VBox.vgrow="NEVER" spacing="12">
<padding>
<Insets bottom="6" left="12" right="12" top="6"/>
</padding>
<children>
<Button contentDisplay="GRAPHIC_ONLY" mnemonicParsing="false" style="-fx-background-color: none;">
<graphic>
<FontAwesomeIconView fill="WHITE" glyphName="COGS"/>
</graphic>
<tooltip>
<Tooltip text="%main.settingsBtn.tooltip"/>
</tooltip>
</Button>
<Button contentDisplay="GRAPHIC_ONLY" mnemonicParsing="false" onAction="#close" style="-fx-background-color: none;">
<graphic>
<FontAwesomeIconView fill="WHITE" glyphName="CLOSE"/>
</graphic>
<tooltip>
<Tooltip text="%main.closeBtn.tooltip"/>
</tooltip>
</Button>
</children>
</HBox>
<HBox VBox.vgrow="ALWAYS">
<fx:include source="/fxml/vault_list.fxml" HBox.hgrow="ALWAYS"/>
<fx:include source="/fxml/vault_detail.fxml" HBox.hgrow="NEVER"/>
</HBox>
</VBox>

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.VBox?>
<?import javafx.geometry.Insets?>
<VBox xmlns="http://javafx.com/javafx"
xmlns:fx="http://javafx.com/fxml"
fx:controller="org.cryptomator.ui.mainwindow.VaultDetailController"
prefWidth="400.0">
<padding>
<Insets bottom="6.0" left="6.0" right="6.0" top="6.0"/>
</padding>
<children>
<Label text="${controller.vault}"/>
</children>
</VBox>

View File

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import de.jensd.fx.glyphs.fontawesome.FontAwesomeIconView?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.ListView?>
<?import javafx.scene.control.Tooltip?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.StackPane?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.shape.Arc?>
<VBox xmlns="http://javafx.com/javafx"
xmlns:fx="http://javafx.com/fxml"
fx:controller="org.cryptomator.ui.mainwindow.VaultListController">
<StackPane VBox.vgrow="ALWAYS">
<ListView fx:id="vaultList" editable="true"/>
<AnchorPane fx:id="onboardingOverlay">
<HBox AnchorPane.leftAnchor="10.0" AnchorPane.rightAnchor="10.0" AnchorPane.bottomAnchor="100.0" alignment="BOTTOM_LEFT">
<Label textAlignment="CENTER" text="%vaultlist.emptyList.onboardingInstruction" wrapText="true"/>
</HBox>
<Arc AnchorPane.bottomAnchor="5.0" type="OPEN" centerX="-10.0" centerY="0.0" radiusY="100.0" radiusX="60.0" startAngle="0" length="-60.0" strokeWidth="1" stroke="BLACK" fill="TRANSPARENT"/>
</AnchorPane>
</StackPane>
<HBox VBox.vgrow="NEVER" spacing="6" alignment="CENTER_LEFT">
<padding>
<Insets bottom="6" left="6" right="6" top="6"/>
</padding>
<children>
<Button contentDisplay="GRAPHIC_ONLY" mnemonicParsing="false" onAction="#didClickAddVault">
<graphic>
<FontAwesomeIconView glyphName="PLUS"/>
</graphic>
<tooltip>
<Tooltip text="Add Vault"/>
</tooltip>
</Button>
<Button contentDisplay="GRAPHIC_ONLY" mnemonicParsing="false" onAction="#didClickRemoveVault">
<graphic>
<FontAwesomeIconView glyphName="MINUS"/>
</graphic>
<tooltip>
<Tooltip text="Remove vault"/>
</tooltip>
</Button>
</children>
</HBox>
</VBox>

View File

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.control.Label?>
<VBox xmlns="http://javafx.com/javafx"
xmlns:fx="http://javafx.com/fxml"
fx:controller="org.cryptomator.ui.vaultlist.VaultListController">
<Label text="%title"/>
</VBox>

View File

@ -1,3 +1,3 @@
main.closeBtn.tooltip=Close
main.settingsBtn.tooltip=Settings
title=Cryptomator
vaultlist.emptyList.onboardingInstruction=Click here to add a vault

View File

@ -1,3 +1,3 @@
main.closeBtn.tooltip=Close
main.settingsBtn.tooltip=Settings
title=CryptomatorDE
vaultlist.emptyList.onboardingInstruction=Klicken Sie hier, um neue Tresore hinzuzufügen

View File

@ -1,3 +1,3 @@
main.closeBtn.tooltip=Close
main.settingsBtn.tooltip=Settings
title=CryptomatorEN
vaultlist.emptyList.onboardingInstruction=Click here to add a vault