From 426da9fccba697ed2aeb25feeaeab34375d2b793 Mon Sep 17 00:00:00 2001 From: Thierry Wasylczenko Date: Sun, 6 Oct 2013 11:20:32 +0200 Subject: [PATCH] Release v0.2.0 --- .../twasyl/compilerfx/app/CompilerFXApp.java | 9 ++- .../compilerfx/beans/MavenRepository.java | 23 ++++++- .../twasyl/compilerfx/beans/PropertyBean.java | 5 ++ .../twasyl/compilerfx/beans/Workspace.java | 12 +++- .../com/twasyl/compilerfx/control/Dialog.java | 59 +++++++++++------- .../controllers/AddRepositoryController.java | 9 +-- .../controllers/AddWorkspaceController.java | 31 ++++++--- .../controllers/CompilerFXController.java | 27 +++++++- .../controllers/EditRepositoryController.java | 9 ++- .../MavenRepositoriesController.java | 38 +++++++++++ .../controllers/WorkspaceController.java | 7 ++- .../compilerfx/utils/MavenExecutor.java | 7 ++- .../com/twasyl/compilerfx/utils/UIUtils.java | 43 ------------- .../twasyl/compilerfx/fxml/AddWorkspace.fxml | 2 +- .../compilerfx/fxml/MavenRepositories.fxml | 19 +++++- .../com/twasyl/compilerfx/images/stop.png | Bin 0 -> 804 bytes 16 files changed, 202 insertions(+), 98 deletions(-) create mode 100644 src/main/java/com/twasyl/compilerfx/beans/PropertyBean.java create mode 100644 src/main/resources/com/twasyl/compilerfx/images/stop.png diff --git a/src/main/java/com/twasyl/compilerfx/app/CompilerFXApp.java b/src/main/java/com/twasyl/compilerfx/app/CompilerFXApp.java index 577ef02..78b8567 100644 --- a/src/main/java/com/twasyl/compilerfx/app/CompilerFXApp.java +++ b/src/main/java/com/twasyl/compilerfx/app/CompilerFXApp.java @@ -19,7 +19,7 @@ public class CompilerFXApp extends Application { - public static String version = "0.1.0"; + public static String version = "0.2.0"; @Override public void start(final Stage stage) throws Exception { @@ -44,9 +44,12 @@ public void handle(WindowEvent windowEvent) { while(processIterator.hasNext()) { repository = processIterator.next(); - repository.setStatus(Status.ABORTED); - if(repository.getActiveProcess() != null) repository.getActiveProcess().destroy(); + synchronized (repository) { + repository.setStatus(Status.ABORTED); + + if(repository.getActiveProcess() != null) repository.getActiveProcess().destroy(); + } } } else { windowEvent.consume(); diff --git a/src/main/java/com/twasyl/compilerfx/beans/MavenRepository.java b/src/main/java/com/twasyl/compilerfx/beans/MavenRepository.java index a4987e9..1c552a9 100644 --- a/src/main/java/com/twasyl/compilerfx/beans/MavenRepository.java +++ b/src/main/java/com/twasyl/compilerfx/beans/MavenRepository.java @@ -11,7 +11,7 @@ import java.util.LinkedHashMap; import java.util.Map; -public class MavenRepository { +public class MavenRepository implements PropertyBean { public static enum Goal { CLEAN("clean"), INSTALL("install"); @@ -101,4 +101,25 @@ public Boolean isGoalActive(Goal goal) { return result; } + + @Override + public void unbindAll() { + if(idProperty().isBound()) idProperty().unbind(); + if(pathProperty().isBound()) pathProperty().unbind(); + if(repositoryNameProperty().isBound()) repositoryNameProperty().unbind(); + if(statusProperty().isBound()) statusProperty().unbind(); + if(selectedProperty().isBound()) selectedProperty().unbind(); + + for(Map.Entry entry : goalsProperty().entrySet()) { + if(entry.getKey().isBound()) entry.getKey().unbind(); + if(entry.getValue().isBound()) entry.getValue().unbind(); + } + + if(lastExecutionStackProperty().isBound()) lastExecutionStackProperty().unbind(); + if(priorityProperty().isBound()) priorityProperty().unbind(); + if(optionsProperty().isBound()) optionsProperty().unbind(); + if(postBuildCommandsProperty().isBound()) postBuildCommandsProperty().unbind(); + if(workspaceProperty().isBound()) workspaceProperty().unbind(); + if(activeProcessProperty().isBound()) activeProcessProperty().unbind(); + } } diff --git a/src/main/java/com/twasyl/compilerfx/beans/PropertyBean.java b/src/main/java/com/twasyl/compilerfx/beans/PropertyBean.java new file mode 100644 index 0000000..2e660c7 --- /dev/null +++ b/src/main/java/com/twasyl/compilerfx/beans/PropertyBean.java @@ -0,0 +1,5 @@ +package com.twasyl.compilerfx.beans; + +public interface PropertyBean { + void unbindAll(); +} diff --git a/src/main/java/com/twasyl/compilerfx/beans/Workspace.java b/src/main/java/com/twasyl/compilerfx/beans/Workspace.java index 95cad5f..e7967a5 100644 --- a/src/main/java/com/twasyl/compilerfx/beans/Workspace.java +++ b/src/main/java/com/twasyl/compilerfx/beans/Workspace.java @@ -2,15 +2,13 @@ import javafx.beans.property.*; import javafx.collections.FXCollections; -import javafx.collections.ObservableList; import javafx.collections.ObservableSet; import javafx.collections.SetChangeListener; import java.util.Comparator; -import java.util.LinkedList; import java.util.TreeSet; -public class Workspace { +public class Workspace implements PropertyBean { private final LongProperty id = new SimpleLongProperty(); private final StringProperty name = new SimpleStringProperty(); @@ -50,4 +48,12 @@ public void onChanged(Change change) { public BooleanProperty activeProperty() { return this.active; } public boolean getActive() { return this.activeProperty().get(); } public void setActive(boolean active) { this.activeProperty().set(active); } + + @Override + public void unbindAll() { + if(idProperty().isBound()) idProperty().unbind(); + if(nameProperty().isBound()) nameProperty().unbind(); + if(repositoriesProperty().isBound()) repositoriesProperty().unbind(); + if(activeProperty().isBound()) activeProperty().unbind(); + } } diff --git a/src/main/java/com/twasyl/compilerfx/control/Dialog.java b/src/main/java/com/twasyl/compilerfx/control/Dialog.java index 48c6be2..1216d80 100644 --- a/src/main/java/com/twasyl/compilerfx/control/Dialog.java +++ b/src/main/java/com/twasyl/compilerfx/control/Dialog.java @@ -3,9 +3,13 @@ import com.twasyl.compilerfx.utils.UIUtils; import javafx.event.ActionEvent; import javafx.event.EventHandler; +import javafx.geometry.Insets; +import javafx.geometry.Pos; import javafx.scene.Node; import javafx.scene.Scene; import javafx.scene.control.Button; +import javafx.scene.image.Image; +import javafx.scene.image.ImageView; import javafx.scene.layout.HBox; import javafx.scene.layout.VBox; import javafx.scene.text.Text; @@ -45,17 +49,11 @@ private void setUserResponse(Response userResponse) { } public static Response showDialog(Stage owner, String title, Node content) { - final Button okButton = new Button("OK"); + final Button okButton = new Button("OK"); final Dialog dialog = buildDialog(owner, title, content, okButton); - okButton.setOnAction(new EventHandler() { - @Override - public void handle(ActionEvent actionEvent) { - dialog.setUserResponse(Response.OK); - dialog.close(); - } - }); + setButtonAction(okButton, Response.OK, dialog); dialog.showDialog(); @@ -73,29 +71,48 @@ public static Response showConfirmDialog(Stage owner, String title, String messa final Dialog dialog = buildDialog(owner, title, messageText, noButton, yesButton); - yesButton.setOnAction(new EventHandler() { - @Override - public void handle(ActionEvent actionEvent) { - dialog.setUserResponse(Response.YES); - dialog.close(); - } - }); + setButtonAction(yesButton, Response.YES, dialog); + setButtonAction(noButton, Response.NO, dialog); + + dialog.showDialog(); + + return dialog.getUserResponse(); + } - noButton.setOnAction(new EventHandler() { + public static Response showErrorDialog(Stage owner, String title, String message) { + final Button okButton = new Button("OK"); + + final Text textMessage = new Text(message); + textMessage.setStyle("-fx-fill: white; -fx-font-size: 15pt;"); + + final ImageView image = new ImageView(new Image(UIUtils.class.getResource("/com/twasyl/compilerfx/images/error_white.png").toExternalForm())); + + final HBox root = new HBox(10); + root.setPadding(new Insets(10)); + root.getChildren().addAll(textMessage, image); + + final Dialog dialog = buildDialog(owner, title, root, okButton); + + setButtonAction(okButton, Response.OK, dialog); + + dialog.showDialog(); + + return dialog.getUserResponse(); + } + + private static void setButtonAction(final Button button, final Response response, final Dialog dialog) { + button.setOnAction(new EventHandler() { @Override public void handle(ActionEvent actionEvent) { - dialog.setUserResponse(Response.NO); + dialog.setUserResponse(response); dialog.close(); } }); - - dialog.showDialog(); - - return dialog.getUserResponse(); } private static Dialog buildDialog(Stage owner, String title, Node content, Button ... buttons) { final HBox buttonsBox = new HBox(10); + buttonsBox.setAlignment(Pos.BASELINE_RIGHT); buttonsBox.getChildren().addAll(buttons); final VBox dialogContent = new VBox(10); diff --git a/src/main/java/com/twasyl/compilerfx/controllers/AddRepositoryController.java b/src/main/java/com/twasyl/compilerfx/controllers/AddRepositoryController.java index 87336e5..3f34151 100644 --- a/src/main/java/com/twasyl/compilerfx/controllers/AddRepositoryController.java +++ b/src/main/java/com/twasyl/compilerfx/controllers/AddRepositoryController.java @@ -3,6 +3,7 @@ import com.twasyl.compilerfx.beans.Configuration; import com.twasyl.compilerfx.beans.MavenRepository; import com.twasyl.compilerfx.beans.Workspace; +import com.twasyl.compilerfx.control.Dialog; import com.twasyl.compilerfx.enums.Status; import com.twasyl.compilerfx.utils.ConfigurationWorker; import com.twasyl.compilerfx.utils.UIUtils; @@ -58,7 +59,7 @@ public class AddRepositoryController implements Initializable { /** Perform some checks */ if(!repositoryFolder.exists()) { repositoryValid = false; - UIUtils.showErrorScreen(String.format("The repository '%1$s' does not exist", repositoryFolder.getAbsolutePath())); + Dialog.showErrorDialog(null, "Error", String.format("The repository '%1$s' does not exist", repositoryFolder.getAbsolutePath())); } if(repositoryValid) { @@ -66,11 +67,13 @@ public class AddRepositoryController implements Initializable { if(!pom.exists()) { repositoryValid = false; - UIUtils.showErrorScreen("Can not find pom.xml file in the repository"); + Dialog.showErrorDialog(null, "Error", "Can not find pom.xml file in the repository"); } } if(repositoryValid) { + this.repository.unbindAll(); + this.repository.setId((int) System.currentTimeMillis()); this.repository.setStatus(Status.READY); this.repository.postBuildCommandsProperty().unbind(); @@ -84,10 +87,8 @@ public class AddRepositoryController implements Initializable { this.repository.setPriority(ConfigurationWorker.getNextAvailablePriority()); } - this.repository.pathProperty().unbind(); this.repository.setPath(this.repository.getPath().replaceAll("\\\\", "/")); - this.repository.workspaceProperty().unbind(); this.repository.getWorkspace().getRepositories().add(this.repository); Configuration.getInstance().getRepositories().add(this.repository); diff --git a/src/main/java/com/twasyl/compilerfx/controllers/AddWorkspaceController.java b/src/main/java/com/twasyl/compilerfx/controllers/AddWorkspaceController.java index 2e55606..f59088f 100644 --- a/src/main/java/com/twasyl/compilerfx/controllers/AddWorkspaceController.java +++ b/src/main/java/com/twasyl/compilerfx/controllers/AddWorkspaceController.java @@ -2,6 +2,7 @@ import com.twasyl.compilerfx.beans.Configuration; import com.twasyl.compilerfx.beans.Workspace; +import com.twasyl.compilerfx.control.Dialog; import com.twasyl.compilerfx.utils.ConfigurationWorker; import com.twasyl.compilerfx.utils.UIUtils; import javafx.beans.property.ObjectProperty; @@ -12,6 +13,8 @@ import javafx.fxml.Initializable; import javafx.scene.Parent; import javafx.scene.control.TextField; +import javafx.scene.input.KeyCode; +import javafx.scene.input.KeyEvent; import javafx.stage.Stage; import java.io.IOException; @@ -26,12 +29,30 @@ public class AddWorkspaceController implements Initializable { @FXML private TextField name; @FXML private void add(ActionEvent event) { + addWorkspace(); + } + + @FXML private void keyPressedOnName(KeyEvent event) { + if(event.getCode().equals(KeyCode.ENTER)) addWorkspace(); + } + + @FXML private void cancel(ActionEvent event) { + try { + Parent parent = FXMLLoader.load(getClass().getResource("/com/twasyl/compilerfx/fxml/MavenRepositories.fxml")); + CompilerFXController.getCurrentInstance().switchScreen(parent); + } catch (IOException e) { + } + } + + private void addWorkspace() { if(this.workspace.getName().trim().isEmpty()) { - UIUtils.showErrorScreen("The name of the workspace can not be empty"); + Dialog.showErrorDialog(null, "Error", "The name of the workspace can not be empty"); } else { this.workspace.setId(System.currentTimeMillis()); this.workspace.setActive(false); + this.workspace.unbindAll(); + Configuration.getInstance().getWorkspaces().add(this.workspace); ConfigurationWorker.save(); @@ -43,14 +64,6 @@ public class AddWorkspaceController implements Initializable { } } - @FXML private void cancel(ActionEvent event) { - try { - Parent parent = FXMLLoader.load(getClass().getResource("/com/twasyl/compilerfx/fxml/MavenRepositories.fxml")); - CompilerFXController.getCurrentInstance().switchScreen(parent); - } catch (IOException e) { - } - } - @Override public void initialize(URL url, ResourceBundle resourceBundle) { this.workspace = new Workspace(); diff --git a/src/main/java/com/twasyl/compilerfx/controllers/CompilerFXController.java b/src/main/java/com/twasyl/compilerfx/controllers/CompilerFXController.java index a47bfa4..d0578bd 100644 --- a/src/main/java/com/twasyl/compilerfx/controllers/CompilerFXController.java +++ b/src/main/java/com/twasyl/compilerfx/controllers/CompilerFXController.java @@ -12,14 +12,18 @@ import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; import javafx.fxml.Initializable; +import javafx.geometry.BoundingBox; import javafx.geometry.Pos; import javafx.scene.Node; import javafx.scene.Parent; import javafx.scene.Scene; import javafx.scene.control.Label; +import javafx.scene.control.ScrollPane; +import javafx.scene.control.TextArea; import javafx.scene.layout.AnchorPane; import javafx.scene.layout.BorderPane; import javafx.scene.layout.VBox; +import javafx.scene.text.Text; import javafx.scene.web.WebView; import javafx.stage.Stage; import javafx.stage.StageStyle; @@ -75,12 +79,33 @@ public class CompilerFXController implements Initializable { } @FXML private void showAbout(ActionEvent event) { + final StringBuilder changeLog = new StringBuilder(); + changeLog.append("Change logs:\n\n"); + changeLog.append("version 0.2.0\n\n"); + changeLog.append(" - Abort feature for the current workspace and for all\n"); + changeLog.append(" - Fix bug that blocked workspace's renaming when the workspace was freshly added\n"); + changeLog.append(" - Use dialogs in the whole application, even for error messages\n"); + changeLog.append(" - Ensure properties of workspaces and repositories are unbind when adding/editing them\n"); + changeLog.append(" - Correction of the label of the button for adding a repository (present in the toolbar)\n"); + changeLog.append(" - Buttons in dialogs are now positioned on the right of the dialog\n"); + changeLog.append(" - Possibility to use ENTER to add a workspace in the add screen\n"); + changeLog.append(" - Add change logs in About screen"); + + final TextArea changeLogText = new TextArea(changeLog.toString()); + changeLogText.setStyle("-fx-text-fill: white; -fx-background-color: transparent;"); + changeLogText.setWrapText(true); + changeLogText.setPrefSize(500, 300); + changeLogText.setMaxSize(500, 300); + changeLogText.setMinSize(500, 300); + + final VBox helpContent = new VBox(10); helpContent.setAlignment(Pos.CENTER); helpContent.getChildren().addAll( new Label("CompilerFX"), new Label("version " + CompilerFXApp.version), - new Label("Author: Thierry Wasylczenko") + new Label("Author: Thierry Wasylczenko"), + changeLogText ); Dialog.showDialog(null, "About", helpContent); diff --git a/src/main/java/com/twasyl/compilerfx/controllers/EditRepositoryController.java b/src/main/java/com/twasyl/compilerfx/controllers/EditRepositoryController.java index b33d93a..e087057 100644 --- a/src/main/java/com/twasyl/compilerfx/controllers/EditRepositoryController.java +++ b/src/main/java/com/twasyl/compilerfx/controllers/EditRepositoryController.java @@ -3,6 +3,7 @@ import com.twasyl.compilerfx.beans.Configuration; import com.twasyl.compilerfx.beans.MavenRepository; import com.twasyl.compilerfx.beans.Workspace; +import com.twasyl.compilerfx.control.Dialog; import com.twasyl.compilerfx.utils.ConfigurationWorker; import com.twasyl.compilerfx.utils.UIUtils; import javafx.application.Platform; @@ -64,7 +65,7 @@ public class EditRepositoryController implements Initializable { /** Perform some checks */ if(!repositoryFolder.exists()) { repositoryValid = false; - UIUtils.showErrorScreen(String.format("The originalRepository '%1$s' does not exist", repositoryFolder.getAbsolutePath())); + Dialog.showErrorDialog(null, "Error", String.format("The originalRepository '%1$s' does not exist", repositoryFolder.getAbsolutePath())); } if(repositoryValid) { @@ -72,17 +73,15 @@ public class EditRepositoryController implements Initializable { if(!pom.exists()) { repositoryValid = false; - UIUtils.showErrorScreen("Can not find pom.xml file in the originalRepository"); + Dialog.showErrorDialog(null, "Error", "Can not find pom.xml file in the originalRepository"); } } if(repositoryValid) { - this.editedRepository.get().workspaceProperty().unbind(); + this.editedRepository.get().unbindAll(); - this.editedRepository.get().pathProperty().unbind(); this.editedRepository.get().setPath(this.editedRepository.get().getPath().replaceAll("\\\\", "/")); - this.editedRepository.get().postBuildCommandsProperty().unbind(); if(this.editedRepository.get().getPostBuildCommands() != null) this.editedRepository.get().setPostBuildCommands(this.editedRepository.get().getPostBuildCommands().replaceAll("\n", "")); diff --git a/src/main/java/com/twasyl/compilerfx/controllers/MavenRepositoriesController.java b/src/main/java/com/twasyl/compilerfx/controllers/MavenRepositoriesController.java index afdb726..ee19e9c 100644 --- a/src/main/java/com/twasyl/compilerfx/controllers/MavenRepositoriesController.java +++ b/src/main/java/com/twasyl/compilerfx/controllers/MavenRepositoriesController.java @@ -15,18 +15,21 @@ import javafx.fxml.FXMLLoader; import javafx.fxml.Initializable; import javafx.scene.Parent; +import javafx.scene.control.SplitMenuButton; import javafx.scene.control.Tab; import javafx.scene.control.TabPane; import java.io.IOException; import java.net.URL; import java.util.ArrayList; +import java.util.Iterator; import java.util.List; import java.util.ResourceBundle; public class MavenRepositoriesController implements Initializable { @FXML private TabPane workspaces; + @FXML private SplitMenuButton abortAll; @FXML private void compileSelection(ActionEvent event) { compileSelection(false); @@ -69,6 +72,39 @@ public class MavenRepositoriesController implements Initializable { } } + @FXML private void abortWorkspaceBuilds(ActionEvent event) { + Workspace workspace = ((WorkspaceTab) this.workspaces.getSelectionModel().getSelectedItem()).getWorkspace(); + Iterator builds = Configuration.getInstance().getCurrentBuilds().iterator(); + MavenRepository repository; + + while(builds.hasNext()) { + repository = builds.next(); + + synchronized (repository) { + if(repository.getWorkspace().getId() == workspace.getId() && repository.getActiveProcess() != null) { + repository.setStatus(Status.ABORTED); + repository.getActiveProcess().destroy(); + } + } + } + } + + @FXML private void abortAllWorkspacesBuilds(ActionEvent event) { + Iterator builds = Configuration.getInstance().getCurrentBuilds().iterator(); + MavenRepository repository; + + while(builds.hasNext()) { + repository = builds.next(); + + synchronized (repository) { + if(repository.getActiveProcess() != null) { + repository.setStatus(Status.ABORTED); + repository.getActiveProcess().destroy(); + } + } + } + } + private void compileSelection(final boolean executePostBuildCommands) { WorkspaceTab selectedTab = (WorkspaceTab) this.workspaces.getSelectionModel().getSelectedItem(); ObservableList repos = FXCollections.observableArrayList(); @@ -149,5 +185,7 @@ public void onChanged(Change change) { @Override public void initialize(URL url, ResourceBundle resourceBundle) { initUI(); + + abortAll.disableProperty().bind(Configuration.getInstance().currentBuildsProperty().emptyProperty()); } } diff --git a/src/main/java/com/twasyl/compilerfx/controllers/WorkspaceController.java b/src/main/java/com/twasyl/compilerfx/controllers/WorkspaceController.java index 4a4359e..187bec1 100644 --- a/src/main/java/com/twasyl/compilerfx/controllers/WorkspaceController.java +++ b/src/main/java/com/twasyl/compilerfx/controllers/WorkspaceController.java @@ -2,6 +2,7 @@ import com.twasyl.compilerfx.beans.MavenRepository; import com.twasyl.compilerfx.beans.Workspace; +import com.twasyl.compilerfx.control.Dialog; import com.twasyl.compilerfx.utils.ConfigurationWorker; import com.twasyl.compilerfx.utils.UIUtils; import javafx.beans.property.ObjectProperty; @@ -81,17 +82,17 @@ public void changed(ObservableValue observableValue, Boolean /** Perform some checks */ if(!repositoryFolder.exists()) { repositoryValid = false; - UIUtils.showErrorScreen(String.format("The repository '%1$s' does not exist", repositoryFolder.getAbsolutePath())); + Dialog.showErrorDialog(null, "Error", String.format("The repository '%1$s' does not exist", repositoryFolder.getAbsolutePath())); } if(repositoryValid && repositoryFolder.isFile()) { repositoryValid = false; - UIUtils.showErrorScreen("The repository must be a folder"); + Dialog.showErrorDialog(null, "Error", "The repository must be a folder"); } if(repositoryValid && !(new File(repositoryFolder, "pom.xml")).exists()) { repositoryValid = false; - UIUtils.showErrorScreen("Can not find pom.xml file in the repository"); + Dialog.showErrorDialog(null, "Error", "Can not find pom.xml file in the repository"); } if(repositoryValid) { diff --git a/src/main/java/com/twasyl/compilerfx/utils/MavenExecutor.java b/src/main/java/com/twasyl/compilerfx/utils/MavenExecutor.java index d53b15d..f17f099 100644 --- a/src/main/java/com/twasyl/compilerfx/utils/MavenExecutor.java +++ b/src/main/java/com/twasyl/compilerfx/utils/MavenExecutor.java @@ -2,6 +2,7 @@ import com.twasyl.compilerfx.beans.Configuration; import com.twasyl.compilerfx.beans.MavenRepository; +import com.twasyl.compilerfx.control.Dialog; import com.twasyl.compilerfx.enums.Status; import javafx.beans.property.BooleanProperty; import javafx.beans.property.StringProperty; @@ -55,7 +56,7 @@ public static void execute(final ObservableList repositories, f } if(!commandValid) { - UIUtils.showErrorScreen(message); + Dialog.showErrorDialog(null, "Error", message); } else { Runnable run = new Runnable() { @Override @@ -72,7 +73,7 @@ public void run() { repositoryDirectory = new File(repository.getPath()); if(!repositoryDirectory.exists()) { - UIUtils.showErrorScreen(String.format("Can not compile repository '%1$s' because it does not exist", repository.getRepositoryName())); + Dialog.showErrorDialog(null, "Error", String.format("Can not compile repository '%1$s' because it does not exist", repository.getRepositoryName())); if(stopIfFailure) break; } else { repository.setLastExecutionStack(null); @@ -193,7 +194,7 @@ public void run() { repositoryDirectory = new File(repository.getPath()); if(!repositoryDirectory.exists()) { - UIUtils.showErrorScreen(String.format("Can not compile repository '%1$s' because it does not exist", repository.getRepositoryName())); + Dialog.showErrorDialog(null, "Error", String.format("Can not compile repository '%1$s' because it does not exist", repository.getRepositoryName())); if(stopIfFailure) break; } else { try { diff --git a/src/main/java/com/twasyl/compilerfx/utils/UIUtils.java b/src/main/java/com/twasyl/compilerfx/utils/UIUtils.java index 57cb0c4..ced4e44 100644 --- a/src/main/java/com/twasyl/compilerfx/utils/UIUtils.java +++ b/src/main/java/com/twasyl/compilerfx/utils/UIUtils.java @@ -1,19 +1,9 @@ package com.twasyl.compilerfx.utils; -import javafx.application.Platform; import javafx.beans.property.SimpleStringProperty; import javafx.beans.property.StringProperty; -import javafx.geometry.Insets; -import javafx.scene.Node; import javafx.scene.Parent; import javafx.scene.Scene; -import javafx.scene.image.Image; -import javafx.scene.image.ImageView; -import javafx.scene.layout.HBox; -import javafx.scene.text.Text; -import javafx.stage.Modality; -import javafx.stage.Stage; -import javafx.stage.StageStyle; public class UIUtils { @@ -23,39 +13,6 @@ public class UIUtils { public static String getStyleSheet() { return styleSheetProperty().get(); } public static void setStyleSheet(String styleSheet) { styleSheetProperty().set(styleSheet); } - public static void showErrorScreen(String message) { - - final Text textMessage = new Text(message); - textMessage.setStyle("-fx-fill: white; -fx-font-size: 15pt;"); - - final ImageView image = new ImageView(new Image(UIUtils.class.getResource("/com/twasyl/compilerfx/images/error_white.png").toExternalForm())); - - final HBox root = new HBox(10); - root.setPadding(new Insets(10)); - root.getChildren().addAll(textMessage, image); - - if(!Platform.isFxApplicationThread()) { - Platform.runLater(new Runnable() { - @Override - public void run() { - final Scene scene = createScene(root); - - Stage stage = new Stage(); - stage.setScene(scene); - stage.setTitle("Error"); - stage.show(); - } - }); - } else { - final Scene scene = createScene(root); - - Stage stage = new Stage(); - stage.setScene(scene); - stage.setTitle("Error"); - stage.show(); - } - } - public static Scene createScene(Parent parent) { final Scene scene = new Scene(parent); scene.getStylesheets().add(getStyleSheet()); diff --git a/src/main/resources/com/twasyl/compilerfx/fxml/AddWorkspace.fxml b/src/main/resources/com/twasyl/compilerfx/fxml/AddWorkspace.fxml index 49b9bc8..e6c6373 100644 --- a/src/main/resources/com/twasyl/compilerfx/fxml/AddWorkspace.fxml +++ b/src/main/resources/com/twasyl/compilerfx/fxml/AddWorkspace.fxml @@ -17,7 +17,7 @@ diff --git a/src/main/resources/com/twasyl/compilerfx/fxml/MavenRepositories.fxml b/src/main/resources/com/twasyl/compilerfx/fxml/MavenRepositories.fxml index 235d172..57e3d06 100644 --- a/src/main/resources/com/twasyl/compilerfx/fxml/MavenRepositories.fxml +++ b/src/main/resources/com/twasyl/compilerfx/fxml/MavenRepositories.fxml @@ -13,6 +13,7 @@ + @@ -20,7 +21,7 @@