Half of features implemented #2
			
				
			
		
		
		
	| 
						 | 
					@ -8,9 +8,7 @@ import java.io.IOException;
 | 
				
			||||||
 * Represents the action archive all repositories with a certain substring in their name.
 | 
					 * Represents the action archive all repositories with a certain substring in their name.
 | 
				
			||||||
 * It takes the following arguments:
 | 
					 * It takes the following arguments:
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * 1. Organization name
 | 
					 * 1. Repo substring to archive by
 | 
				
			||||||
 * 2. Access Token
 | 
					 | 
				
			||||||
 * 3. Repo substring to archive by
 | 
					 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
public class ArchiveRepos extends GithubExecutable {
 | 
					public class ArchiveRepos extends GithubExecutable {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -10,6 +10,10 @@ import java.util.List;
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Execute this class to read students from a supplied filename and teamsize, and store their
 | 
					 * Execute this class to read students from a supplied filename and teamsize, and store their
 | 
				
			||||||
 * information in the database.
 | 
					 * information in the database.
 | 
				
			||||||
 | 
					 * Requires the following arguments:
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * 1. filename
 | 
				
			||||||
 | 
					 * 2. teamsize
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
public class ReadStudentsFileToDB implements Executable {
 | 
					public class ReadStudentsFileToDB implements Executable {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,30 @@
 | 
				
			||||||
 | 
					package nl.andrewlalis.ui.control.listeners;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import nl.andrewlalis.ui.control.command.CommandExecutor;
 | 
				
			||||||
 | 
					import nl.andrewlalis.ui.view.InitializerApp;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import javax.swing.*;
 | 
				
			||||||
 | 
					import java.awt.event.ActionEvent;
 | 
				
			||||||
 | 
					import java.awt.event.ActionListener;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class ArchiveAllListener extends ExecutableListener {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    InitializerApp app;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public ArchiveAllListener(CommandExecutor executor, InitializerApp app) {
 | 
				
			||||||
 | 
					        super(executor);
 | 
				
			||||||
 | 
					        this.app = app;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void actionPerformed(ActionEvent actionEvent) {
 | 
				
			||||||
 | 
					        String response = JOptionPane.showInputDialog(null, "Enter a substring to archive repositories by.", "Enter a substring", JOptionPane.QUESTION_MESSAGE);
 | 
				
			||||||
 | 
					        if (response != null) {
 | 
				
			||||||
 | 
					            this.executor.executeCommand("archiveall", new String[]{
 | 
				
			||||||
 | 
					                    this.app.getOrganizationName(),
 | 
				
			||||||
 | 
					                    this.app.getAccessToken(),
 | 
				
			||||||
 | 
					                    response
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,19 @@
 | 
				
			||||||
 | 
					package nl.andrewlalis.ui.control.listeners;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import nl.andrewlalis.ui.control.command.CommandExecutor;
 | 
				
			||||||
 | 
					import nl.andrewlalis.ui.control.command.Executable;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.awt.event.ActionEvent;
 | 
				
			||||||
 | 
					import java.awt.event.ActionListener;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * An action listener which is pre-set to execute an executable once an action is performed.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					public abstract class ExecutableListener implements ActionListener {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    protected CommandExecutor executor;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public ExecutableListener(CommandExecutor executor) {
 | 
				
			||||||
 | 
					        this.executor = executor;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -1,8 +1,10 @@
 | 
				
			||||||
package nl.andrewlalis.ui.view;
 | 
					package nl.andrewlalis.ui.view;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import nl.andrewlalis.ui.control.command.CommandExecutor;
 | 
					 | 
				
			||||||
import nl.andrewlalis.ui.control.listeners.CommandFieldKeyListener;
 | 
					 | 
				
			||||||
import nl.andrewlalis.ui.control.OutputTextHandler;
 | 
					import nl.andrewlalis.ui.control.OutputTextHandler;
 | 
				
			||||||
 | 
					import nl.andrewlalis.ui.control.command.CommandExecutor;
 | 
				
			||||||
 | 
					import nl.andrewlalis.ui.control.command.executables.ArchiveRepos;
 | 
				
			||||||
 | 
					import nl.andrewlalis.ui.control.listeners.ArchiveAllListener;
 | 
				
			||||||
 | 
					import nl.andrewlalis.ui.control.listeners.CommandFieldKeyListener;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import javax.swing.*;
 | 
					import javax.swing.*;
 | 
				
			||||||
import java.awt.*;
 | 
					import java.awt.*;
 | 
				
			||||||
| 
						 | 
					@ -111,6 +113,30 @@ public class InitializerApp extends JFrame {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        githubManagerPanel.add(infoInputPanel, BorderLayout.NORTH);
 | 
					        githubManagerPanel.add(infoInputPanel, BorderLayout.NORTH);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Common actions panel.
 | 
				
			||||||
 | 
					        JPanel commonActionsPanel = new JPanel();
 | 
				
			||||||
 | 
					        commonActionsPanel.setLayout(new BoxLayout(commonActionsPanel, BoxLayout.PAGE_AXIS));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        JButton archiveAllButton = new JButton("Archive All");
 | 
				
			||||||
 | 
					        archiveAllButton.addActionListener(new ArchiveAllListener(this.executor, this));
 | 
				
			||||||
 | 
					        commonActionsPanel.add(archiveAllButton);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        JButton generateStudentTeamsButton = new JButton("Read teams from file");
 | 
				
			||||||
 | 
					        generateStudentTeamsButton.addActionListener(actionEvent -> {
 | 
				
			||||||
 | 
					            JFileChooser chooser = new JFileChooser();
 | 
				
			||||||
 | 
					            int returnValue = chooser.showOpenDialog(null);
 | 
				
			||||||
 | 
					            if (returnValue == JFileChooser.APPROVE_OPTION) {
 | 
				
			||||||
 | 
					                this.executor.executeCommand("readstudents", new String[]{
 | 
				
			||||||
 | 
					                        chooser.getSelectedFile().getName(),
 | 
				
			||||||
 | 
					                        teamSizeField.getText()
 | 
				
			||||||
 | 
					                });
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					        commonActionsPanel.add(generateStudentTeamsButton);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        githubManagerPanel.add(commonActionsPanel, BorderLayout.CENTER);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return githubManagerPanel;
 | 
					        return githubManagerPanel;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -165,4 +191,20 @@ public class InitializerApp extends JFrame {
 | 
				
			||||||
        return newPanel;
 | 
					        return newPanel;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Gets the organization name entered in the relevant field.
 | 
				
			||||||
 | 
					     * @return The organization name the user has entered.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public String getOrganizationName() {
 | 
				
			||||||
 | 
					        return this.organizationField.getText().trim();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Gets the oauth access token entered in the relevant field.
 | 
				
			||||||
 | 
					     * @return The access token the user has entered.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public String getAccessToken() {
 | 
				
			||||||
 | 
					        return this.accessTokenField.getText().trim();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue