Skip to content

Commit

Permalink
Release v0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
twasyl committed Oct 6, 2013
1 parent d474677 commit 426da9f
Show file tree
Hide file tree
Showing 16 changed files with 202 additions and 98 deletions.
9 changes: 6 additions & 3 deletions src/main/java/com/twasyl/compilerfx/app/CompilerFXApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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();
Expand Down
23 changes: 22 additions & 1 deletion src/main/java/com/twasyl/compilerfx/beans/MavenRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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<StringProperty, BooleanProperty> 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();
}
}
5 changes: 5 additions & 0 deletions src/main/java/com/twasyl/compilerfx/beans/PropertyBean.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.twasyl.compilerfx.beans;

public interface PropertyBean {
void unbindAll();
}
12 changes: 9 additions & 3 deletions src/main/java/com/twasyl/compilerfx/beans/Workspace.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -50,4 +48,12 @@ public void onChanged(Change<? extends MavenRepository> 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();
}
}
59 changes: 38 additions & 21 deletions src/main/java/com/twasyl/compilerfx/control/Dialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<ActionEvent>() {
@Override
public void handle(ActionEvent actionEvent) {
dialog.setUserResponse(Response.OK);
dialog.close();
}
});
setButtonAction(okButton, Response.OK, dialog);

dialog.showDialog();

Expand All @@ -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<ActionEvent>() {
@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<ActionEvent>() {
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<ActionEvent>() {
@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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -58,19 +59,21 @@ 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) {
File pom = new File(repositoryFolder, "pom.xml");

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();
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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();

Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -64,25 +65,23 @@ 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) {
File pom = new File(repositoryFolder, "pom.xml");

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", ""));

Expand Down
Loading

0 comments on commit 426da9f

Please sign in to comment.