package com.spectralogic.dsbrowser.gui;

import com.spectralogic.dsbrowser.gui.components.about.AboutView;
import com.spectralogic.dsbrowser.gui.components.ds3panel.Ds3PanelView;
import com.spectralogic.dsbrowser.gui.components.license.LicenseView;
import com.spectralogic.dsbrowser.gui.components.localfiletreetable.LocalFileTreeTableView;
import com.spectralogic.dsbrowser.gui.components.newsession.NewSessionPopup;
import com.spectralogic.dsbrowser.gui.components.settings.SettingsView;
import com.spectralogic.dsbrowser.gui.services.JobWorkers;
import com.spectralogic.dsbrowser.gui.util.Popup;
import javafx.application.Platform;
import javafx.beans.binding.Bindings;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.CheckMenuItem;
import javafx.scene.control.SplitPane;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.AnchorPane;
import org.controlsfx.control.TaskProgressView;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.inject.Inject;
import java.net.URL;
import java.util.ResourceBundle;

public class DeepStorageBrowserPresenter implements Initializable {

    private final static Logger LOG = LoggerFactory.getLogger(DeepStorageBrowserPresenter.class);

    @FXML
    AnchorPane fileSystem;

    @FXML
    AnchorPane blackPearl;

    @FXML
    SplitPane jobSplitter;

    @FXML
    CheckMenuItem jobsMenuItem;

    @Inject
    JobWorkers jobWorkers;

    TaskProgressView<Ds3JobTask> jobProgressView;

    @Override
    public void initialize(final URL location, final ResourceBundle resources) {

        try {
            LOG.info("Loading Main view");
            jobProgressView = new TaskProgressView<>();
            Bindings.bindContentBidirectional(jobWorkers.getTasks(), jobProgressView.getTasks());
            jobsMenuItem.setOnAction(event -> {
                if (jobsMenuItem.isSelected()) {
                    jobSplitter.getItems().add(jobProgressView);
                    jobSplitter.setDividerPositions(0.75);
                } else {
                    jobSplitter.setDividerPositions(1.0);
                    jobSplitter.getItems().remove(jobProgressView);
                }
            });
            final LocalFileTreeTableView localTreeView = new LocalFileTreeTableView();
            final Ds3PanelView ds3PanelView = new Ds3PanelView();
            localTreeView.getViewAsync(fileSystem.getChildren()::add);
            ds3PanelView.getViewAsync(blackPearl.getChildren()::add);
        } catch (final Throwable e) {
            LOG.error("Encountered an error when creating Main view", e);
            throw e;
        }
    }

    public void showSettingsPopup() {
        final SettingsView settingsView = new SettingsView();
        Popup.show(settingsView.getView(), "Settings");
    }

    public void showLicensePopup() {
        final LicenseView licenseView = new LicenseView();
        Popup.show(licenseView.getView(), "Licenses");
    }

    public void showAboutPopup() {
        final AboutView aboutView = new AboutView();
        Popup.show(aboutView.getView(), "About");
    }

    public void showSessionPopup() {
        NewSessionPopup.show();
    }

    public void closeWindow() {
        Platform.exit();
    }

}

@@ -768,16 +768,88 @@
 nuItem;%0A
+import javafx.scene.control.Menu;%0Aimport javafx.scene.control.MenuItem;%0A
 import j
@@ -875,24 +875,24 @@
 .SplitPane;%0A
-
 import javaf
@@ -1467,16 +1467,266 @@
 MenuItem
+, darkViewCheckMenuItem, lightViewCheckMenuItem;%0A%0A    @FXML%0A    MenuItem versionMenuItem, licenseMenuItem, aboutMenuItem, helpMenuItem, themeMenuItem, closeMenuItem, sessionsMenuItem, settingsMenuItem;%0A%0A    @FXML%0A    Menu fileMenu, helpMenu, viewMenu
 ;%0A%0A    @
@@ -1811,16 +1811,64 @@
 sView;%0A%0A
+    @Inject%0A    ResourceBundle resourceBundle;%0A%0A
     @Ove
@@ -2064,24 +2064,24 @@
 ssView%3C%3E();%0A
-
             
@@ -2166,16 +2166,1132 @@
 sks());%0A
+%0A            fileMenu.setText(resourceBundle.getString(%22fileMenu%22));%0A            sessionsMenuItem.setText(resourceBundle.getString(%22sessionsMenuItem%22));%0A            settingsMenuItem.setText(resourceBundle.getString(%22settingsMenuItem%22));%0A            closeMenuItem.setText(resourceBundle.getString(%22closeMenuItem%22));%0A%0A            viewMenu.setText(resourceBundle.getString(%22viewMenu%22));%0A            jobsMenuItem.setText(resourceBundle.getString(%22jobsMenuItem%22));%0A            themeMenuItem.setText(resourceBundle.getString(%22themeMenuItem%22));%0A            darkViewCheckMenuItem.setText(resourceBundle.getString(%22darkViewCheckMenuItem%22));%0A            lightViewCheckMenuItem.setText(resourceBundle.getString(%22lightViewCheckMenuItem%22));%0A%0A            helpMenu.setText(resourceBundle.getString(%22helpMenu%22));%0A            helpMenuItem.setText(resourceBundle.getString(%22helpMenuItem%22));%0A            licenseMenuItem.setText(resourceBundle.getString(%22licenseMenuItem%22));%0A            aboutMenuItem.setText(resourceBundle.getString(%22aboutMenuItem%22));%0A            versionMenuItem.setText(resourceBundle.getString(%22versionMenuItem%22));%0A%0A
         

Create bucket, Delete objects and folder, Physical placement, Internationalization, few user session validations