Skip to content

Commit

Permalink
Jdeps dialog now supports File Chooser to select main jar
Browse files Browse the repository at this point in the history
  • Loading branch information
SergeMerzliakov committed Dec 20, 2019
1 parent b88cf81 commit 841ca01
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,20 @@ package org.installmation.ui.dialog
import javafx.collections.FXCollections
import javafx.collections.ObservableList
import javafx.fxml.FXML
import javafx.scene.control.ComboBox
import javafx.scene.control.ListView
import javafx.scene.control.TextArea
import javafx.scene.control.TextField
import javafx.scene.control.*
import javafx.stage.DirectoryChooser
import javafx.stage.FileChooser
import javafx.stage.Stage
import org.apache.logging.log4j.LogManager
import org.apache.logging.log4j.Logger
import org.installmation.configuration.UserHistory
import org.installmation.core.CollectionUtils
import org.installmation.model.NamedDirectory
import org.installmation.model.binary.JDK
import org.installmation.model.binary.JDepsExecutable
import org.installmation.model.binary.ModuleDependenciesGenerator
import java.io.File
import kotlin.random.Random

class JdepsDialogController(private val jdkList: Collection<JDK>, private val javaFXLibs: File?, private val mainJarFile: File?, classPathFiles: Collection<File>?, private val userHistory: UserHistory) {

Expand All @@ -39,15 +40,16 @@ class JdepsDialogController(private val jdkList: Collection<JDK>, private val ja
const val NO_DEPENDENCIES_MESSAGE = "<No module dependencies>"
}

@FXML lateinit var mainJar: TextField
@FXML lateinit var mainJarText: TextField
@FXML lateinit var generatedCommandText: TextArea
@FXML lateinit var classPathListView: ListView<String>
@FXML lateinit var modulePathListView: ListView<String>
@FXML lateinit var jdkComboBox: ComboBox<JDK>
@FXML lateinit var processOutputView: ListView<String>
@FXML lateinit var dependencyListView: ListView<String>
@FXML lateinit var dependencyTextArea: TextArea

@FXML private lateinit var configureMainJarButton: Button

// model
private val classPath: ObservableList<String> = FXCollections.observableArrayList()
private val modulePath: ObservableList<String> = FXCollections.observableArrayList()
Expand All @@ -65,7 +67,7 @@ class JdepsDialogController(private val jdkList: Collection<JDK>, private val ja

@FXML
fun initialize() {
mainJar.text = mainJarFile?.path
mainJarText.text = mainJarFile?.path
classPathListView.items = classPath.sorted()
modulePathListView.items = modulePath.sorted()
dependencyListView.items = moduleOutput.sorted()
Expand All @@ -81,7 +83,7 @@ class JdepsDialogController(private val jdkList: Collection<JDK>, private val ja
val classPathString = CollectionUtils.toPathList(classPath)

if (javaFXLibs != null) {
val mdg = ModuleDependenciesGenerator(jdeps, classPathString, javaFXLibs, mainJar.text)
val mdg = ModuleDependenciesGenerator(jdeps, classPathString, javaFXLibs, mainJarText.text)
val moduleDependencies = mdg.generate()
displayResults(jdeps, mdg, moduleDependencies)
}
Expand Down Expand Up @@ -155,4 +157,12 @@ class JdepsDialogController(private val jdkList: Collection<JDK>, private val ja
return
modulePath.remove(modulePathListView.selectionModel.selectedItem)
}

@FXML
fun configureMainJar() {
val result = ChooseFileDialog.showAndWait(mainJarText.scene.window as Stage, "Select Main Application Jar File", userHistory, InstallmationExtensionFilters.jarFilter())
if (result.ok) {
mainJarText.text = result.data!!.path
}
}
}
7 changes: 4 additions & 3 deletions src/main/resources/fxml/dialog/jdepsDialog.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.RowConstraints?>

<GridPane fx:id="jdepsDialog" hgap="5.0" prefHeight="400.0" prefWidth="600.0" vgap="5.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1">
<GridPane fx:id="jdepsDialog" hgap="5.0" prefHeight="400.0" prefWidth="600.0" vgap="5.0" xmlns="http://javafx.com/javafx/13" xmlns:fx="http://javafx.com/fxml/1">
<rowConstraints>
<RowConstraints maxHeight="42.0" minHeight="42.0" prefHeight="42.0" />
<RowConstraints maxHeight="36.0" minHeight="36.0" prefHeight="36.0" />
Expand All @@ -34,7 +34,7 @@
<ColumnConstraints halignment="RIGHT" hgrow="ALWAYS" maxWidth="90.0" minWidth="90.0" prefWidth="90.0" />
<ColumnConstraints hgrow="ALWAYS" minWidth="50.0" prefWidth="100.0" />
<ColumnConstraints hgrow="NEVER" maxWidth="70.0" minWidth="70.0" prefWidth="70.0" />
<ColumnConstraints hgrow="NEVER" maxWidth="86.0" minWidth="86.0" prefWidth="86.0" />
<ColumnConstraints hgrow="NEVER" maxWidth="100.0" minWidth="100.0" prefWidth="100.0" />
</columnConstraints>
<children>
<Label text="Main Jar" GridPane.rowIndex="1">
Expand All @@ -59,7 +59,7 @@
</ContextMenu>
</contextMenu>
</ListView>
<TextField fx:id="mainJar" GridPane.columnIndex="1" GridPane.columnSpan="2" GridPane.rowIndex="1">
<TextField fx:id="mainJarText" GridPane.columnIndex="1" GridPane.columnSpan="2" GridPane.rowIndex="1">
<GridPane.margin>
<Insets />
</GridPane.margin>
Expand Down Expand Up @@ -147,6 +147,7 @@
<Insets left="5.0" right="5.0" />
</GridPane.margin>
</TextArea>
<Button fx:id="configureMainJarButton" mnemonicParsing="false" onAction="#configureMainJar" text="Configure" GridPane.columnIndex="3" GridPane.rowIndex="1" />
</children>
<stylesheets>
<URL value="@../../css/bootstrap3.css" />
Expand Down
4 changes: 2 additions & 2 deletions src/test/kotlin/org/installmation/javafx/test/FXID.kt
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,7 @@ object FXID {
const val DIALOG_JDEPS = "#jdepsDialog"
const val BUTTON_JDEPS_DLG_RUN = "#runButton"
const val BUTTON_JDEPS_DLG_CLOSE = "#closeButton"
const val TEXT_JDEPS_DLG_MAINJAR = "#mainJar"
const val TEXT_JDEPS_DLG_MAINCLASS = "#mainClass"
const val TEXT_JDEPS_DLG_MAINJAR = "#mainJarText"
const val COMBO_JDEPS_DLG_JDK = "#jdkComboBox"
const val LISTVIEW_JDEPS_DLG_CLASSPATH = "#classPathListView"
const val LISTVIEW_JDEPS_DLG_MODULEPATH = "#modulePathListView"
Expand All @@ -134,4 +133,5 @@ object FXID {
const val TAB_JDEPS_DLG_OUTPUT = "#outputTab"
const val TAB_JDEPS_DLG_LIST = "#listTab"
const val TAB_JDEPS_DLG_TEXT = "#textTab"
const val BUTTON_JDEPS_MAIN_JAR = "#configureMainJarButton"
}

0 comments on commit 841ca01

Please sign in to comment.