You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hop.apache.org by mc...@apache.org on 2021/12/02 09:52:55 UTC

[incubator-hop] branch master updated: HOP-3520 Project's dialog allows empty configuration file reference HOP-3522 Project dialog: ask user to create project's home if it doesn't exists

This is an automated email from the ASF dual-hosted git repository.

mcasters pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-hop.git


The following commit(s) were added to refs/heads/master by this push:
     new e21e775  HOP-3520 Project's dialog allows empty configuration file reference HOP-3522 Project dialog: ask user to create project's home if it doesn't exists
     new 5be5969  Merge pull request #1205 from sramazzina/HOP-3520
e21e775 is described below

commit e21e77547769ce9f165ac9d4eeeef594d6566084
Author: Sergio Ramazzina <se...@serasoft.it>
AuthorDate: Tue Nov 30 17:52:51 2021 +0100

    HOP-3520 Project's dialog allows empty configuration file reference
    HOP-3522 Project dialog: ask user to create project's home if it doesn't exists
---
 .../apache/hop/projects/project/ProjectDialog.java | 39 ++++++++++++++++++----
 .../project/messages/messages_en_US.properties     |  4 +++
 .../project/messages/messages_it_IT.properties     |  3 ++
 3 files changed, 40 insertions(+), 6 deletions(-)

diff --git a/plugins/misc/projects/src/main/java/org/apache/hop/projects/project/ProjectDialog.java b/plugins/misc/projects/src/main/java/org/apache/hop/projects/project/ProjectDialog.java
index 886c0ca..ad5c714 100644
--- a/plugins/misc/projects/src/main/java/org/apache/hop/projects/project/ProjectDialog.java
+++ b/plugins/misc/projects/src/main/java/org/apache/hop/projects/project/ProjectDialog.java
@@ -23,6 +23,7 @@ import org.apache.hop.core.Const;
 import org.apache.hop.core.config.DescribedVariable;
 import org.apache.hop.core.exception.HopException;
 import org.apache.hop.core.logging.LogChannel;
+import org.apache.hop.core.util.Utils;
 import org.apache.hop.core.variables.IVariables;
 import org.apache.hop.core.variables.Variables;
 import org.apache.hop.core.vfs.HopVfs;
@@ -499,24 +500,50 @@ public class ProjectDialog extends Dialog {
     try {
       // Do some extra validations to prevent bad data ending up in the projects configuration
       //
+
       String homeFolder = wHome.getText();
       if (StringUtils.isEmpty(variables.resolve(homeFolder))) {
         throw new HopException("Please specify a home folder for your project");
       }
+
+      // If the home folder doesn't exists and project is new aks if want it created
+      if (!HopVfs.getFileObject(variables.resolve(homeFolder)).exists() && !this.editMode) {
+        MessageBox box =
+            new MessageBox(HopGui.getInstance().getShell(), SWT.YES | SWT.NO | SWT.ICON_QUESTION);
+        box.setText(BaseMessages.getString(PKG, "ProjectDialog.CreateHome.Dialog.Header"));
+        box.setMessage(
+            BaseMessages.getString(PKG, "ProjectDialog.CreateHome.Dialog.Message", homeFolder));
+        int anwser = box.open();
+        if ((anwser & SWT.YES) != 0) {
+          HopVfs.getFileObject(homeFolder).createFolder();
+        }
+      }
+
+      // Definitely check if home folder exists or not
       if (!HopVfs.getFileObject(variables.resolve(homeFolder)).exists()) {
-        throw new HopException(
-            "Please specify an existing home folder for your project. Folder '"
-                + homeFolder
-                + "' doesn't seem to exist.");
+        String msgPre = "Please specify an existing home folder for your project. Folder '";
+        String msgPost = "' doesn't seem to exist.";
+        if (this.editMode) {
+          msgPre = "Project '" + wName.getText() + " is already existing. Changing its home directory to '";
+          msgPost = "' is not supported!";
+        }
+        throw new HopException(msgPre + homeFolder + msgPost);
       }
 
-      // Renaming the project is not supported.
-      //
+      // Renaming the project is not supported
       String projectName = wName.getText();
       if (StringUtils.isEmpty(projectName)) {
         throw new HopException("Please give your new project a name");
       }
 
+      if (Utils.isEmpty(wHome.getText())) {
+        throw new HopException("Please specify project's home directory path!");
+      }
+
+      if (Utils.isEmpty(wConfigFile.getText())) {
+        throw new HopException("Please specify project's configuration file relative path!");
+      }
+
       if (wParentProject.getText() != null
           && wParentProject.getText().length() > 0
           && projectName.equals(wParentProject.getText())) {
diff --git a/plugins/misc/projects/src/main/resources/org/apache/hop/projects/project/messages/messages_en_US.properties b/plugins/misc/projects/src/main/resources/org/apache/hop/projects/project/messages/messages_en_US.properties
index a78d941..8fd9d9f 100644
--- a/plugins/misc/projects/src/main/resources/org/apache/hop/projects/project/messages/messages_en_US.properties
+++ b/plugins/misc/projects/src/main/resources/org/apache/hop/projects/project/messages/messages_en_US.properties
@@ -42,4 +42,8 @@ ProjectGuiPlugin.WrongConfigPath.Dialog.Header=Wrong project''s root
 ProjectGuiPlugin.WrongConfigPath.Dialog.Message=The path to selected project-config.json is outside the boundaries of this project and that is not permitted!
 ProjectDialog.FileList.PrjFiles.Text=Project Config File (*.json)
 ProjectDialog.FileList.AllFiles.Text=All Files (*.*)
+ProjectDialog.CreateHome.Dialog.Header=Create project''s home?
+ProjectDialog.CreateHome.Dialog.Message=The project''s home folder ''{0}'' does not exists! Do you want to create it?
+
+
 
diff --git a/plugins/misc/projects/src/main/resources/org/apache/hop/projects/project/messages/messages_it_IT.properties b/plugins/misc/projects/src/main/resources/org/apache/hop/projects/project/messages/messages_it_IT.properties
index d56cafe..36010ab 100644
--- a/plugins/misc/projects/src/main/resources/org/apache/hop/projects/project/messages/messages_it_IT.properties
+++ b/plugins/misc/projects/src/main/resources/org/apache/hop/projects/project/messages/messages_it_IT.properties
@@ -42,3 +42,6 @@ ProjectDialog.FileList.PrjFiles.Text=Files di configurazione di progetto (*.json
 ProjectDialog.FileList.AllFiles.Text=Tutti i files (*.*)
 ProjectGuiPlugin.WrongConfigPath.Dialog.Header=Riferimento alla radice del progetto sbagliata
 ProjectGuiPlugin.WrongConfigPath.Dialog.Message=Il percorso al file project-config.json selezionato \u00E8 al di fuori del perimetro del progetto. Questo non \u00E8 permesso!
+ProjectDialog.CreateHome.Dialog.Header=Creo la home del progetto?
+ProjectDialog.CreateHome.Dialog.Message=La cartella home del progetto ''{0}'' non esiste! La vuoi creare?
+