Skip to content

Commit

Permalink
Merge pull request #15 from airavata-courses/karan_develop
Browse files Browse the repository at this point in the history
Karan develop
  • Loading branch information
karankotz authored Sep 18, 2018
2 parents 439e19a + 3dfa6b1 commit 78677d6
Show file tree
Hide file tree
Showing 6 changed files with 259 additions and 1 deletion.
Binary file added screenshots/Jenkins_Test_Develop_Branch.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
import org.seagrid.desktop.ui.home.model.ExperimentListModel;
import org.seagrid.desktop.ui.home.model.ProjectTreeModel;
import org.seagrid.desktop.ui.home.model.TreeModel;
import org.seagrid.desktop.ui.prestageupload.PrestageUploadWindow;
import org.seagrid.desktop.ui.project.ProjectWindow;
import org.seagrid.desktop.ui.storage.MassStorageBrowserWindow;
import org.seagrid.desktop.util.SEAGridConfig;
Expand Down Expand Up @@ -112,6 +113,9 @@ public class HomeController {
@FXML
private Button createExperimentButton;

@FXML
private Button uploadInputFilesButton;

@FXML
private TreeView<TreeModel> projectsTreeView;

Expand Down Expand Up @@ -218,7 +222,7 @@ public void initialize() {
notificationLabel.setStyle("-fx-border-color: white;");
notificationLabel.setMaxWidth(Double.MAX_VALUE);
try{
java.util.List<Notification> messages = AiravataManager.getInstance().getNotifications();
List<Notification> messages = AiravataManager.getInstance().getNotifications();
final Index index = new Index();
index.index = 0;
if (messages != null && messages.size() > 0) {
Expand Down Expand Up @@ -295,6 +299,13 @@ public void initMenuBar() {
"Failed to open Storage Browser");
}
});
uploadInputFilesButton.setOnMouseClicked(event -> {
try {
PrestageUploadWindow.displayUploadFiles();
} catch (IOException e) {
e.printStackTrace();
}
});
nanocadBtn.setOnAction(event ->
SwingUtilities.invokeLater(new Runnable() {
@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.seagrid.desktop.ui.prestageupload;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Modality;
import javafx.stage.Stage;
import org.seagrid.desktop.ui.experiment.create.ExperimentCreateWindow;
import org.seagrid.desktop.ui.prestageupload.controller.PrestageUploadController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;

public class PrestageUploadWindow extends Application{
private final static Logger logger = LoggerFactory.getLogger(PrestageUploadWindow.class);

private static Stage createPrimaryStage;

@Override
public void start(Stage primaryStage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("/views/prestageupload/upload-files.fxml"));
primaryStage.setTitle("SEAGrid Desktop Client - Prestage Upload");
primaryStage.setScene(new Scene(root, 400, 150));
primaryStage.show();
}

public static void displayUploadFiles() throws IOException {
if(createPrimaryStage == null || !createPrimaryStage.isShowing()) {
createPrimaryStage = new Stage();
FXMLLoader loader = new FXMLLoader(ExperimentCreateWindow.class.getResource(
"/views/prestageupload/upload-files.fxml"));
Parent root = loader.load();
createPrimaryStage.setTitle("SEAGrid Desktop Client - Prestage Upload");
createPrimaryStage.setScene(new Scene(root, 400, 150));
createPrimaryStage.initModality(Modality.WINDOW_MODAL);
createPrimaryStage.show();
}
createPrimaryStage.requestFocus();
}

public static void main(String[] args) {
launch(args);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.seagrid.desktop.ui.prestageupload.controller;

import javafx.concurrent.Service;
import javafx.concurrent.Task;
import javafx.concurrent.WorkerStateEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Alert;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.GridPane;
import javafx.stage.FileChooser;
import org.seagrid.desktop.connectors.NextcloudStorage.NextcloudFileUploadTask;
import org.seagrid.desktop.ui.commons.SEAGridDialogHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.util.HashMap;
import java.util.Map;

public class PrestageUploadController {
private final static Logger logger = LoggerFactory.getLogger(PrestageUploadController.class);

@FXML
private Button pickFile;

@FXML
private Button saveButton;

private FileChooser fileChooser;

@FXML
public GridPane preuploadGridPane;

@FXML
public Label chosenFile;

Map<String,File> uploadFiles = new HashMap<>();

@FXML
public void initialize() {
chosenFile.setTranslateX(85);
chosenFile.setTranslateY(3);
pickFile.setOnAction(event -> {
try {
fileChooser = new FileChooser();
fileChooser.setTitle("Open Resource File");
File file = fileChooser.showOpenDialog(null);
if (file != null) {
String fileAsString = file.getName();
String remotePath = "/Documents/InputFiles/" + fileAsString;
String filePath = file.toString();
chosenFile.setText(fileAsString);
uploadFiles.put(remotePath, file);
} else {
chosenFile.setText(null);
}

} catch (Exception ex) {
SEAGridDialogHelper.showExceptionDialog(ex, "Caught Exception", null, "Unable to select file");
}
});

saveButton.setOnAction(event -> {
try {
if (uploadFiles.size() > 0)
{
Service<Boolean> fileUploadService = getPreFileUploadService(uploadFiles);
fileUploadService.setOnSucceeded(event2 -> {
Alert alert = new Alert(Alert.AlertType.INFORMATION);
alert.setTitle("File Upload Status");
alert.setContentText("File Upload Completed");
alert.showAndWait();
});
fileUploadService.start();
}
} catch (Exception e) {

}
});

}

public Service<Boolean> getPreFileUploadService(Map<String, File> uploadFiles) {
Service<Boolean> service = new Service<Boolean>() {
@Override
protected Task<Boolean> createTask() {
try {
return new NextcloudFileUploadTask(uploadFiles);
} catch (Exception e) {
e.printStackTrace();
SEAGridDialogHelper.showExceptionDialogAndWait(e, "Exception Dialog", chosenFile.getScene().getWindow(),
"Unable To Connect To File Server !");
}
return null;
}
};
SEAGridDialogHelper.showProgressDialog(service,"Progress Dialog",chosenFile.getScene().getWindow(),
"Uploading Experiment Input Files");
service.setOnFailed((WorkerStateEvent t) -> {
SEAGridDialogHelper.showExceptionDialogAndWait(service.getException(), "Exception Dialog",
chosenFile.getScene().getWindow(), "File Upload Failed");
});
return service;
}

}
5 changes: 5 additions & 0 deletions src/main/resources/views/home/home.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,11 @@
</HBox.margin>
</Button>
<Button fx:id="browseMassStorageBtn" mnemonicParsing="false" text="Storage" HBox.margin="$x5" />
<Button fx:id="uploadInputFilesButton" mnemonicParsing="false" text="Upload Input Files">
<HBox.margin>
<Insets bottom="3.0" right="3.0" top="3.0" fx:id="x5" />
</HBox.margin>
</Button>
<Button id="browseMassStorageBtn" fx:id="nanocadBtn" mnemonicParsing="false" text="Nanocad" visible="false" HBox.margin="$x5" />
<Button id="browseMassStorageBtn" fx:id="jamberooBtn" mnemonicParsing="false" text="Jamberoo" visible="false">
<HBox.margin>
Expand Down
49 changes: 49 additions & 0 deletions src/main/resources/views/prestageupload/upload-files.fxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.layout.StackPane?>
<?import javafx.scene.layout.VBox?>

<StackPane prefWidth="350.0" xmlns="http://javafx.com/javafx/8.0.121" xmlns:fx="http://javafx.com/fxml/1" fx:controller="org.seagrid.desktop.ui.prestageupload.controller.PrestageUploadController">
<children>
<StackPane>
<children>
<VBox spacing="10.0">
<children>
<GridPane fx:id="preuploadGridPane" prefHeight="120.0" prefWidth="250.0">
<children>
<Label fx:id="chosenFile" maxHeight="25.0" prefHeight="25.0" prefWidth="788.0" text="" wrapText="false" GridPane.columnIndex="1" VBox.vgrow="NEVER">
</Label>
<Label text="Select File" GridPane.columnIndex="0" GridPane.rowIndex="0" />
<Button fx:id="pickFile" mnemonicParsing="false" onAction="#initialize" text="Upload" GridPane.columnIndex="1" GridPane.rowIndex="0">

</Button>
</children>
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="148.0" minWidth="10.0" prefWidth="109.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="228.0" minWidth="10.0" prefWidth="189.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
</GridPane>
<StackPane prefHeight="-1.0" prefWidth="-1.0">
<children>
<Button fx:id="saveButton" alignment="BOTTOM_LEFT" defaultButton="true" mnemonicParsing="false" text="Save" StackPane.alignment="BOTTOM_LEFT" />
</children>
</StackPane>
</children>
</VBox>
</children>
</StackPane>
</children>
<padding>
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
</padding>
</StackPane>

0 comments on commit 78677d6

Please sign in to comment.