Skip to content

Commit

Permalink
Merge pull request #48 from cm090/builder-tool-improvements
Browse files Browse the repository at this point in the history
Builder tool improvements
  • Loading branch information
cm090 authored Dec 6, 2024
2 parents 711cacb + 64c7bee commit d935c36
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 6 deletions.
9 changes: 9 additions & 0 deletions builder/src/main/java/rhit/domain/BuilderData.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,13 @@ public static void parseConfigFile() {
public static Set<String> getTemplateFiles() {
return new HashSet<>(templateFiles);
}

public static void clear() {
templateFiles.clear();
templateDir = null;
outputDir = null;
starterCodeDir = null;
templateType = TemplateType.AUTO;
configOptions = null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@

public class AutograderBuilder {
public static void main(String[] args) {
new AutograderBuilder().initialize();
}

public void initialize() {
JFrame frame = new JFrame(PropertiesLoader.get("windowTitle"));
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
InterfaceUtils.setFrame(frame);
Expand Down
18 changes: 16 additions & 2 deletions builder/src/main/java/rhit/presentation/BuildProgress.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
package rhit.presentation;

import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.GridLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import rhit.domain.BuildRunner;
import rhit.domain.BuilderData;
import rhit.domain.PropertiesLoader;

public class BuildProgress extends SwingGui {
private static final int FRAME_WIDTH = 300;
private static final int FRAME_HEIGHT = 300;
private static final int NUM_ROWS = 1;
private static final int NUM_COLS = 2;

private final JFrame frame;

Expand All @@ -29,13 +35,19 @@ void show() {
scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);

JButton continueButton = new JButton(PropertiesLoader.get("continueButton"));
JButton continueButton = new JButton(PropertiesLoader.get("regenerateButton"));
continueButton.addActionListener(e -> handleContinue());

JButton closeButton = new JButton(PropertiesLoader.get("closeButton"));
closeButton.addActionListener(e -> frame.dispose());

frame.setLayout(new BorderLayout());
frame.add(scrollPane, BorderLayout.CENTER);
frame.add(continueButton, BorderLayout.SOUTH);

JPanel buttonPanel = new JPanel(new GridLayout(NUM_ROWS, NUM_COLS));
buttonPanel.add(continueButton);
buttonPanel.add(closeButton);
frame.add(buttonPanel, BorderLayout.SOUTH);

frame.setSize(FRAME_WIDTH, FRAME_HEIGHT);
frame.setLocationRelativeTo(null);
Expand All @@ -47,5 +59,7 @@ void show() {

protected void handleContinue() {
frame.dispose();
BuilderData.clear();
EventQueue.invokeLater(() -> new AutograderBuilder().initialize());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ private void handleSelectTemplate() {
startDir = new File(".");
}
fileChooser.setCurrentDirectory(startDir);
fileChooser.setDialogTitle(PropertiesLoader.get("selectButtonHint"));
fileChooser.setDialogTitle(PropertiesLoader.get("templateDirPrompt"));
fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
fileChooser.setAcceptAllFileFilterUsed(false);
if (fileChooser.showOpenDialog(frame) == JFileChooser.APPROVE_OPTION) {
Expand All @@ -105,7 +105,7 @@ private void handleSelectOutput() {
InterfaceUtils.hideFrame(panel);
JFileChooser fileChooser = new JFileChooser();
fileChooser.setCurrentDirectory(new File("."));
fileChooser.setDialogTitle(String.format("%s (%s)", PropertiesLoader.get("selectButtonHint"),
fileChooser.setDialogTitle(String.format("%s (%s)", PropertiesLoader.get("outputDirPrompt"),
String.format(PropertiesLoader.get("outputDirHint"),
PropertiesLoader.get("outputActualDir"))));
fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ private void handleSelectStartingDirectory() {
startDir = new File(".");
}
fileChooser.setCurrentDirectory(startDir);
fileChooser.setDialogTitle(PropertiesLoader.get("selectButtonHint"));
fileChooser.setDialogTitle(PropertiesLoader.get("starterCodeDirPrompt"));
fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
fileChooser.setAcceptAllFileFilterUsed(false);
if (fileChooser.showOpenDialog(frame) == JFileChooser.APPROVE_OPTION) {
Expand Down
4 changes: 3 additions & 1 deletion builder/src/main/resources/Strings.properties
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,6 @@ configUpdated=Updated config file
compressionError=Error compressing output: %s
compressionSuccess=Compressed output to %s
closeWindowReminder=You may now close this window
maxDepthExceededError=Maximum directory depth exceeded for this operation
maxDepthExceededError=Maximum directory depth exceeded for this operation
regenerateButton=Start Over
closeButton=Close

0 comments on commit d935c36

Please sign in to comment.