Skip to content

Commit

Permalink
removed TrayIcon, as it caused more problems than the notifications h…
Browse files Browse the repository at this point in the history
…elped
  • Loading branch information
patschuh committed Jan 18, 2020
1 parent 2ac7c94 commit 706e97f
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 134 deletions.
1 change: 1 addition & 0 deletions src/main/java/at/esque/kafka/Controller.java
Expand Up @@ -259,6 +259,7 @@ public void setup(Stage controlledStage) {
headerValueColumn.setCellValueFactory(param -> new SimpleStringProperty(new String(param.getValue().value())));

fetchModeCombobox.setItems(FXCollections.observableArrayList(FetchTypes.values()));
fetchModeCombobox.getSelectionModel().select(FetchTypes.NEWEST);

fetchModeCombobox.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) ->
specificOffsetTextField.setVisible(newValue == FetchTypes.SPECIFIC_OFFSET));
Expand Down
8 changes: 0 additions & 8 deletions src/main/java/at/esque/kafka/CrossClusterController.java
Expand Up @@ -12,7 +12,6 @@
import at.esque.kafka.handlers.ConsumerHandler;
import at.esque.kafka.handlers.CrossClusterOperationHandler;
import at.esque.kafka.handlers.ProducerHandler;
import at.esque.kafka.handlers.TrayHandler;
import com.google.inject.Inject;
import javafx.application.Platform;
import javafx.beans.binding.Bindings;
Expand Down Expand Up @@ -76,8 +75,6 @@ public class CrossClusterController {
private ProducerHandler producerHandler;
@Inject
private ConsumerHandler consumerHandler;
@Inject
private TrayHandler trayHandler;

public void setup() {
ClusterConfigs clusterConfigs = configHandler.loadOrCreateConfigs();
Expand All @@ -100,10 +97,6 @@ public void setup() {
} else {
cell.textProperty().set(MessageFormat.format("{0} / {1} ---> {2} / {3}", newValue.getFromCluster().getIdentifier(), newValue.getFromTopic().getName(), newValue.getToCluster().getIdentifier(), newValue.getToTopic().getName()));
cell.getItem().statusProperty().addListener((observable1, oldValue1, newValue1) -> {
if (newValue1 != null && newValue1.equals("Finished")) {
trayHandler.showInfoNotification("Operation Finished!",
MessageFormat.format("{0} / {1} ---> {2} / {3}", newValue.getFromCluster().getIdentifier(), newValue.getFromTopic().getName(), newValue.getToCluster().getIdentifier(), newValue.getToTopic().getName()));
}
});
cell.graphicProperty().bind(Bindings.createObjectBinding(() -> {
if (cell.getItem() != null) {
Expand Down Expand Up @@ -181,7 +174,6 @@ private void startOperation(UUID operationId) {
} catch (Exception e) {
Platform.runLater(() -> {
operation.setStatus("Error");
trayHandler.showErrorNotification("Operation stopped with an error!", e.getMessage());
});
}
});
Expand Down
33 changes: 0 additions & 33 deletions src/main/java/at/esque/kafka/Main.java
@@ -1,34 +1,21 @@
package at.esque.kafka;

import at.esque.kafka.guice.GuiceEsqueModule;
import at.esque.kafka.handlers.TrayHandler;
import com.google.inject.Guice;
import com.google.inject.Injector;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.event.Event;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.control.ButtonType;
import javafx.scene.control.Dialog;
import javafx.scene.image.Image;
import javafx.stage.Stage;
import javafx.stage.WindowEvent;

import java.util.Arrays;
import java.util.Optional;

public class Main extends Application {

private TrayHandler trayHandler;

@Override
public void start(Stage primaryStage) throws Exception {
Injector injector = Guice.createInjector(new GuiceEsqueModule());
trayHandler = injector.getInstance(TrayHandler.class);
trayHandler.setPrimaryStage(primaryStage);
FXMLLoader loader = injector.getInstance(FXMLLoader.class);
loader.setLocation(getClass().getResource("/fxml/mainScene.fxml"));
Parent root = loader.load();
Expand All @@ -37,28 +24,9 @@ public void start(Stage primaryStage) throws Exception {
primaryStage.getIcons().add(new Image(getClass().getResourceAsStream("/icons/kafkaesque.png")));
primaryStage.setTitle("Kafkaesque");
primaryStage.setScene(createStyledScene(root, 1600, 900));
primaryStage.getScene().getWindow().addEventFilter(WindowEvent.WINDOW_CLOSE_REQUEST, this::primaryStageClose);
primaryStage.show();
}

private <T extends Event> void primaryStageClose(T event) {
if (trayHandler.isTraySupported()) {
Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
alert.setTitle("Confirmation");
alert.setHeaderText("Should KafkaEsque stay open in the Tray?");

alert.getButtonTypes().setAll(Arrays.asList(ButtonType.YES, ButtonType.NO));

Optional<ButtonType> result = alert.showAndWait();

if (result.orElse(ButtonType.NO) == ButtonType.YES) {
trayHandler.getPrimaryStage().hide();
} else {
Platform.exit();
}
}
}

public static Scene createStyledScene(Parent parent, double width, double height) {
Scene scene = new Scene(parent, width, height);
applyStylesheet(scene);
Expand All @@ -80,6 +48,5 @@ public static void main(String[] args) {

@Override
public void stop() {
trayHandler.shutdown();
}
}
93 changes: 0 additions & 93 deletions src/main/java/at/esque/kafka/handlers/TrayHandler.java

This file was deleted.

0 comments on commit 706e97f

Please sign in to comment.