Initial commit
This commit is contained in:
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
# Project exclude paths
|
||||||
|
/.gradle/
|
||||||
|
/build/
|
||||||
|
/build/classes/java/main/
|
||||||
8
.idea/.gitignore
generated
vendored
Normal file
8
.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
|
# Editor-based HTTP Client requests
|
||||||
|
/httpRequests/
|
||||||
|
# Datasource local storage ignored files
|
||||||
|
/dataSources/
|
||||||
|
/dataSources.local.xml
|
||||||
6
.idea/compiler.xml
generated
Normal file
6
.idea/compiler.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="CompilerConfiguration">
|
||||||
|
<bytecodeTargetLevel target="17" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
16
.idea/gradle.xml
generated
Normal file
16
.idea/gradle.xml
generated
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="GradleSettings">
|
||||||
|
<option name="linkedExternalProjectsSettings">
|
||||||
|
<GradleProjectSettings>
|
||||||
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
|
<option name="gradleJvm" value="#JAVA_HOME" />
|
||||||
|
<option name="modules">
|
||||||
|
<set>
|
||||||
|
<option value="$PROJECT_DIR$" />
|
||||||
|
</set>
|
||||||
|
</option>
|
||||||
|
</GradleProjectSettings>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
20
.idea/jarRepositories.xml
generated
Normal file
20
.idea/jarRepositories.xml
generated
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="RemoteRepositoriesConfiguration">
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="central" />
|
||||||
|
<option name="name" value="Maven Central repository" />
|
||||||
|
<option name="url" value="https://repo1.maven.org/maven2" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="jboss.community" />
|
||||||
|
<option name="name" value="JBoss Community repository" />
|
||||||
|
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="MavenRepo" />
|
||||||
|
<option name="name" value="MavenRepo" />
|
||||||
|
<option name="url" value="https://repo.maven.apache.org/maven2/" />
|
||||||
|
</remote-repository>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
8
.idea/misc.xml
generated
Normal file
8
.idea/misc.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
|
<component name="FrameworkDetectionExcludesConfiguration">
|
||||||
|
<file type="web" url="file://$PROJECT_DIR$" />
|
||||||
|
</component>
|
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="temurin-17" project-jdk-type="JavaSDK" />
|
||||||
|
</project>
|
||||||
19
build.gradle.kts
Normal file
19
build.gradle.kts
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
plugins {
|
||||||
|
id("java")
|
||||||
|
}
|
||||||
|
|
||||||
|
group = "org.lumijiez"
|
||||||
|
version = "1.0-SNAPSHOT"
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
testImplementation(platform("org.junit:junit-bom:5.9.1"))
|
||||||
|
testImplementation("org.junit.jupiter:junit-jupiter")
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.test {
|
||||||
|
useJUnitPlatform()
|
||||||
|
}
|
||||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
Binary file not shown.
7
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
7
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
distributionBase=GRADLE_USER_HOME
|
||||||
|
distributionPath=wrapper/dists
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
|
||||||
|
networkTimeout=10000
|
||||||
|
validateDistributionUrl=true
|
||||||
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
zipStorePath=wrapper/dists
|
||||||
248
gradlew
vendored
Normal file
248
gradlew
vendored
Normal file
@@ -0,0 +1,248 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright © 2015-2021 the original authors.
|
||||||
|
#
|
||||||
|
# Licensed 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
|
||||||
|
#
|
||||||
|
# https://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.
|
||||||
|
#
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
#
|
||||||
|
# Gradle start up script for POSIX generated by Gradle.
|
||||||
|
#
|
||||||
|
# Important for running:
|
||||||
|
#
|
||||||
|
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||||
|
# noncompliant, but you have some other compliant shell such as ksh or
|
||||||
|
# bash, then to run this script, type that shell name before the whole
|
||||||
|
# command line, like:
|
||||||
|
#
|
||||||
|
# ksh Gradle
|
||||||
|
#
|
||||||
|
# Busybox and similar reduced shells will NOT work, because this script
|
||||||
|
# requires all of these POSIX shell features:
|
||||||
|
# * functions;
|
||||||
|
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||||
|
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||||
|
# * compound commands having a testable exit status, especially «case»;
|
||||||
|
# * various built-in commands including «command», «set», and «ulimit».
|
||||||
|
#
|
||||||
|
# Important for patching:
|
||||||
|
#
|
||||||
|
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||||
|
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||||
|
#
|
||||||
|
# The "traditional" practice of packing multiple parameters into a
|
||||||
|
# space-separated string is a well documented source of bugs and security
|
||||||
|
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||||
|
# options in "$@", and eventually passing that to Java.
|
||||||
|
#
|
||||||
|
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||||
|
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||||
|
# see the in-line comments for details.
|
||||||
|
#
|
||||||
|
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||||
|
# Darwin, MinGW, and NonStop.
|
||||||
|
#
|
||||||
|
# (3) This script is generated from the Groovy template
|
||||||
|
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||||
|
# within the Gradle project.
|
||||||
|
#
|
||||||
|
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||||
|
#
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
# Attempt to set APP_HOME
|
||||||
|
|
||||||
|
# Resolve links: $0 may be a link
|
||||||
|
app_path=$0
|
||||||
|
|
||||||
|
# Need this for daisy-chained symlinks.
|
||||||
|
while
|
||||||
|
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||||
|
[ -h "$app_path" ]
|
||||||
|
do
|
||||||
|
ls=$( ls -ld "$app_path" )
|
||||||
|
link=${ls#*' -> '}
|
||||||
|
case $link in #(
|
||||||
|
/*) app_path=$link ;; #(
|
||||||
|
*) app_path=$APP_HOME$link ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# This is normally unused
|
||||||
|
# shellcheck disable=SC2034
|
||||||
|
APP_BASE_NAME=${0##*/}
|
||||||
|
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||||
|
|
||||||
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
|
MAX_FD=maximum
|
||||||
|
|
||||||
|
warn () {
|
||||||
|
echo "$*"
|
||||||
|
} >&2
|
||||||
|
|
||||||
|
die () {
|
||||||
|
echo
|
||||||
|
echo "$*"
|
||||||
|
echo
|
||||||
|
exit 1
|
||||||
|
} >&2
|
||||||
|
|
||||||
|
# OS specific support (must be 'true' or 'false').
|
||||||
|
cygwin=false
|
||||||
|
msys=false
|
||||||
|
darwin=false
|
||||||
|
nonstop=false
|
||||||
|
case "$( uname )" in #(
|
||||||
|
CYGWIN* ) cygwin=true ;; #(
|
||||||
|
Darwin* ) darwin=true ;; #(
|
||||||
|
MSYS* | MINGW* ) msys=true ;; #(
|
||||||
|
NONSTOP* ) nonstop=true ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
|
# Determine the Java command to use to start the JVM.
|
||||||
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
|
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||||
|
else
|
||||||
|
JAVACMD=$JAVA_HOME/bin/java
|
||||||
|
fi
|
||||||
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
|
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
JAVACMD=java
|
||||||
|
if ! command -v java >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Increase the maximum file descriptors if we can.
|
||||||
|
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||||
|
case $MAX_FD in #(
|
||||||
|
max*)
|
||||||
|
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||||
|
# shellcheck disable=SC3045
|
||||||
|
MAX_FD=$( ulimit -H -n ) ||
|
||||||
|
warn "Could not query maximum file descriptor limit"
|
||||||
|
esac
|
||||||
|
case $MAX_FD in #(
|
||||||
|
'' | soft) :;; #(
|
||||||
|
*)
|
||||||
|
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||||
|
# shellcheck disable=SC3045
|
||||||
|
ulimit -n "$MAX_FD" ||
|
||||||
|
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Collect all arguments for the java command, stacking in reverse order:
|
||||||
|
# * args from the command line
|
||||||
|
# * the main class name
|
||||||
|
# * -classpath
|
||||||
|
# * -D...appname settings
|
||||||
|
# * --module-path (only if needed)
|
||||||
|
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||||
|
|
||||||
|
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||||
|
if "$cygwin" || "$msys" ; then
|
||||||
|
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||||
|
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||||
|
|
||||||
|
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||||
|
|
||||||
|
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||||
|
for arg do
|
||||||
|
if
|
||||||
|
case $arg in #(
|
||||||
|
-*) false ;; # don't mess with options #(
|
||||||
|
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||||
|
[ -e "$t" ] ;; #(
|
||||||
|
*) false ;;
|
||||||
|
esac
|
||||||
|
then
|
||||||
|
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||||
|
fi
|
||||||
|
# Roll the args list around exactly as many times as the number of
|
||||||
|
# args, so each arg winds up back in the position where it started, but
|
||||||
|
# possibly modified.
|
||||||
|
#
|
||||||
|
# NB: a `for` loop captures its iteration list before it begins, so
|
||||||
|
# changing the positional parameters here affects neither the number of
|
||||||
|
# iterations, nor the values presented in `arg`.
|
||||||
|
shift # remove old arg
|
||||||
|
set -- "$@" "$arg" # push replacement arg
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
|
|
||||||
|
# Collect all arguments for the java command;
|
||||||
|
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||||
|
# shell script including quotes and variable substitutions, so put them in
|
||||||
|
# double quotes to make sure that they get re-expanded; and
|
||||||
|
# * put everything else in single quotes, so that it's not re-expanded.
|
||||||
|
|
||||||
|
set -- \
|
||||||
|
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||||
|
-classpath "$CLASSPATH" \
|
||||||
|
org.gradle.wrapper.GradleWrapperMain \
|
||||||
|
"$@"
|
||||||
|
|
||||||
|
# Stop when "xargs" is not available.
|
||||||
|
if ! command -v xargs >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
die "xargs is not available"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Use "xargs" to parse quoted args.
|
||||||
|
#
|
||||||
|
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||||
|
#
|
||||||
|
# In Bash we could simply go:
|
||||||
|
#
|
||||||
|
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||||
|
# set -- "${ARGS[@]}" "$@"
|
||||||
|
#
|
||||||
|
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||||
|
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||||
|
# character that might be a shell metacharacter, then use eval to reverse
|
||||||
|
# that process (while maintaining the separation between arguments), and wrap
|
||||||
|
# the whole thing up as a single "set" statement.
|
||||||
|
#
|
||||||
|
# This will of course break if any of these variables contains a newline or
|
||||||
|
# an unmatched quote.
|
||||||
|
#
|
||||||
|
|
||||||
|
eval "set -- $(
|
||||||
|
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||||
|
xargs -n1 |
|
||||||
|
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||||
|
tr '\n' ' '
|
||||||
|
)" '"$@"'
|
||||||
|
|
||||||
|
exec "$JAVACMD" "$@"
|
||||||
92
gradlew.bat
vendored
Normal file
92
gradlew.bat
vendored
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
@rem
|
||||||
|
@rem Copyright 2015 the original author or authors.
|
||||||
|
@rem
|
||||||
|
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
@rem you may not use this file except in compliance with the License.
|
||||||
|
@rem You may obtain a copy of the License at
|
||||||
|
@rem
|
||||||
|
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
@rem
|
||||||
|
@rem Unless required by applicable law or agreed to in writing, software
|
||||||
|
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@rem See the License for the specific language governing permissions and
|
||||||
|
@rem limitations under the License.
|
||||||
|
@rem
|
||||||
|
|
||||||
|
@if "%DEBUG%"=="" @echo off
|
||||||
|
@rem ##########################################################################
|
||||||
|
@rem
|
||||||
|
@rem Gradle startup script for Windows
|
||||||
|
@rem
|
||||||
|
@rem ##########################################################################
|
||||||
|
|
||||||
|
@rem Set local scope for the variables with windows NT shell
|
||||||
|
if "%OS%"=="Windows_NT" setlocal
|
||||||
|
|
||||||
|
set DIRNAME=%~dp0
|
||||||
|
if "%DIRNAME%"=="" set DIRNAME=.
|
||||||
|
@rem This is normally unused
|
||||||
|
set APP_BASE_NAME=%~n0
|
||||||
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
|
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||||
|
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||||
|
|
||||||
|
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||||
|
|
||||||
|
@rem Find java.exe
|
||||||
|
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
|
|
||||||
|
set JAVA_EXE=java.exe
|
||||||
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
|
if %ERRORLEVEL% equ 0 goto execute
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
echo.
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
echo location of your Java installation.
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
:findJavaFromJavaHome
|
||||||
|
set JAVA_HOME=%JAVA_HOME:"=%
|
||||||
|
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||||
|
|
||||||
|
if exist "%JAVA_EXE%" goto execute
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||||
|
echo.
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
echo location of your Java installation.
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
:execute
|
||||||
|
@rem Setup the command line
|
||||||
|
|
||||||
|
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
|
@rem Execute Gradle
|
||||||
|
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||||
|
|
||||||
|
:end
|
||||||
|
@rem End local scope for the variables with windows NT shell
|
||||||
|
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||||
|
|
||||||
|
:fail
|
||||||
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||||
|
rem the _cmd.exe /c_ return code!
|
||||||
|
set EXIT_CODE=%ERRORLEVEL%
|
||||||
|
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||||
|
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||||
|
exit /b %EXIT_CODE%
|
||||||
|
|
||||||
|
:mainEnd
|
||||||
|
if "%OS%"=="Windows_NT" endlocal
|
||||||
|
|
||||||
|
:omega
|
||||||
BIN
manager.ser
Normal file
BIN
manager.ser
Normal file
Binary file not shown.
22
src/main/java/org/lumijiez/Main.java
Normal file
22
src/main/java/org/lumijiez/Main.java
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
package org.lumijiez;
|
||||||
|
|
||||||
|
import org.lumijiez.gui.StudentManagementGUI;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
|
public class Main {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
|
||||||
|
// Sets a Windows "Look and Feel", or at least tries to
|
||||||
|
try {
|
||||||
|
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
|
||||||
|
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) {
|
||||||
|
System.err.println("Windows LAF not found!");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Application entry point
|
||||||
|
EventQueue.invokeLater(() -> new StudentManagementGUI().setVisible(true));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
57
src/main/java/org/lumijiez/base/Faculty.java
Normal file
57
src/main/java/org/lumijiez/base/Faculty.java
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
package org.lumijiez.base;
|
||||||
|
|
||||||
|
import org.lumijiez.enums.StudyField;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class Faculty implements Serializable {
|
||||||
|
private String name;
|
||||||
|
private String abbreviation;
|
||||||
|
private StudyField field;
|
||||||
|
private final List<Group> groups = new ArrayList<>();
|
||||||
|
public Faculty(String name, String abbreviation, StudyField field) {
|
||||||
|
this.name = name;
|
||||||
|
this.abbreviation = abbreviation;
|
||||||
|
this.field = field;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addGroup(Group group) {
|
||||||
|
groups.add(group);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAbbreviation() {
|
||||||
|
return abbreviation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAbbreviation(String abbreviation) {
|
||||||
|
this.abbreviation = abbreviation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Group> getGroups() {
|
||||||
|
return groups;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StudyField getField() {
|
||||||
|
return field;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setField(StudyField field) {
|
||||||
|
this.field = field;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
24
src/main/java/org/lumijiez/base/Grade.java
Normal file
24
src/main/java/org/lumijiez/base/Grade.java
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
package org.lumijiez.base;
|
||||||
|
|
||||||
|
import org.lumijiez.enums.Subjects;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
public class Grade implements Serializable {
|
||||||
|
private final Subjects subject;
|
||||||
|
private final int grade;
|
||||||
|
|
||||||
|
public Grade(Subjects subject, int grade) {
|
||||||
|
this.subject = subject;
|
||||||
|
this.grade = grade;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Subjects getSubject() {
|
||||||
|
return subject;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getGrade() {
|
||||||
|
return grade;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
50
src/main/java/org/lumijiez/base/Group.java
Normal file
50
src/main/java/org/lumijiez/base/Group.java
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
package org.lumijiez.base;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class Group implements Serializable {
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
private Faculty faculty;
|
||||||
|
private final List<Student> students = new ArrayList<>();
|
||||||
|
|
||||||
|
public Group(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Faculty getFaculty() {
|
||||||
|
return faculty;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFaculty(Faculty faculty) {
|
||||||
|
this.faculty = faculty;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addStudent(Student st) {
|
||||||
|
students.add(st);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteStudent(Student st) {
|
||||||
|
students.remove(st);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Student> getStudents() {
|
||||||
|
return students;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
119
src/main/java/org/lumijiez/base/Student.java
Normal file
119
src/main/java/org/lumijiez/base/Student.java
Normal file
@@ -0,0 +1,119 @@
|
|||||||
|
package org.lumijiez.base;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class Student implements Serializable {
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
private String surname;
|
||||||
|
private String fullname;
|
||||||
|
private String email;
|
||||||
|
private Date enrollmentDate;
|
||||||
|
private Date dateOfBirth;
|
||||||
|
private Faculty faculty;
|
||||||
|
private Group group;
|
||||||
|
private boolean graduated = false;
|
||||||
|
private final List<Grade> grades = new ArrayList<>();
|
||||||
|
|
||||||
|
public Student(String name, String surname, String email, Group group, Faculty faculty, Date birth, Date enrol) {
|
||||||
|
this.name = name;
|
||||||
|
this.surname = surname;
|
||||||
|
this.fullname = name + " " + surname;
|
||||||
|
this.email = email;
|
||||||
|
this.group = group;
|
||||||
|
this.faculty = faculty;
|
||||||
|
this.dateOfBirth = birth;
|
||||||
|
this.enrollmentDate = enrol;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Faculty getFaculty() {
|
||||||
|
return faculty;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFaculty(Faculty faculty) {
|
||||||
|
this.faculty = faculty;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Grade> getGrades() {
|
||||||
|
return grades;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addGrade(Grade grade) {
|
||||||
|
grades.add(grade);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSurname() {
|
||||||
|
return surname;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSurname(String surname) {
|
||||||
|
this.surname = surname;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFullname() {
|
||||||
|
return fullname;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFullname(String fullname) {
|
||||||
|
this.fullname = fullname;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEmail() {
|
||||||
|
return email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEmail(String email) {
|
||||||
|
this.email = email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getEnrollmentDate() {
|
||||||
|
return enrollmentDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEnrollmentDate(Date enrollmentDate) {
|
||||||
|
this.enrollmentDate = enrollmentDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getDateOfBirth() {
|
||||||
|
return dateOfBirth;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDateOfBirth(Date dateOfBirth) {
|
||||||
|
this.dateOfBirth = dateOfBirth;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Group getGroup() {
|
||||||
|
return group;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGroup(Group gr) {
|
||||||
|
this.group.deleteStudent(this);
|
||||||
|
this.group = gr;
|
||||||
|
gr.addStudent(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isGraduated() {
|
||||||
|
return this.graduated;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGraduated(boolean graduated) {
|
||||||
|
this.graduated = graduated;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return fullname + " | " + group.getName() + " | " + faculty.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
26
src/main/java/org/lumijiez/data/DataDeserializer.java
Normal file
26
src/main/java/org/lumijiez/data/DataDeserializer.java
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
package org.lumijiez.data;
|
||||||
|
|
||||||
|
import org.lumijiez.managers.Supervisor;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.ObjectInputStream;
|
||||||
|
|
||||||
|
public class DataDeserializer {
|
||||||
|
public static Supervisor deserialize() {
|
||||||
|
File serializedFile = new File("manager.ser");
|
||||||
|
Supervisor manager = new Supervisor();
|
||||||
|
if (serializedFile.exists()) {
|
||||||
|
try (ObjectInputStream ois = new ObjectInputStream(new FileInputStream(serializedFile))) {
|
||||||
|
manager = (Supervisor) ois.readObject();
|
||||||
|
System.out.println("Supervisor object deserialized successfully.");
|
||||||
|
} catch (ClassNotFoundException | IOException e) {
|
||||||
|
System.err.println(e.getMessage());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
System.out.println("Serialized file 'manager.ser' does not exist.");
|
||||||
|
}
|
||||||
|
return manager;
|
||||||
|
}
|
||||||
|
}
|
||||||
18
src/main/java/org/lumijiez/data/DataSerializer.java
Normal file
18
src/main/java/org/lumijiez/data/DataSerializer.java
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
package org.lumijiez.data;
|
||||||
|
|
||||||
|
import org.lumijiez.managers.Supervisor;
|
||||||
|
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.ObjectOutputStream;
|
||||||
|
|
||||||
|
public class DataSerializer {
|
||||||
|
public static void serialize(Supervisor manager) {
|
||||||
|
try (ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("manager.ser"))) {
|
||||||
|
oos.writeObject(manager);
|
||||||
|
System.out.println("Supervisor object serialized successfully.");
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.err.println(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
69
src/main/java/org/lumijiez/data/graduate.txt
Normal file
69
src/main/java/org/lumijiez/data/graduate.txt
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
name: Alice
|
||||||
|
surname: Johnson
|
||||||
|
email: alice.johnson@example.com
|
||||||
|
group: FAF-224
|
||||||
|
faculty: FCEX
|
||||||
|
specialty: Mechanical Engineering
|
||||||
|
|
||||||
|
name: David
|
||||||
|
surname: Smith
|
||||||
|
email: david.smith@example.com
|
||||||
|
group: FAF-221
|
||||||
|
faculty: FCBT
|
||||||
|
specialty: Software Engineering
|
||||||
|
|
||||||
|
name: Sarah
|
||||||
|
surname: Anderson
|
||||||
|
email: sarah.anderson@example.com
|
||||||
|
group: FAF-225
|
||||||
|
faculty: FCNS
|
||||||
|
specialty: Food Technology
|
||||||
|
|
||||||
|
name: Michael
|
||||||
|
surname: Williams
|
||||||
|
email: michael.williams@example.com
|
||||||
|
group: FAF-223
|
||||||
|
faculty: FCGT
|
||||||
|
specialty: Urbanism and Architecture
|
||||||
|
|
||||||
|
name: Emily
|
||||||
|
surname: Davis
|
||||||
|
email: emily.davis@example.com
|
||||||
|
group: FAF-222
|
||||||
|
faculty: FCMP
|
||||||
|
specialty: Veterinary Medicine
|
||||||
|
|
||||||
|
name: James
|
||||||
|
surname: Martinez
|
||||||
|
email: james.martinez@example.com
|
||||||
|
group: FAF-226
|
||||||
|
faculty: FCOE
|
||||||
|
specialty: Mechanical Engineering
|
||||||
|
|
||||||
|
name: Olivia
|
||||||
|
surname: Brown
|
||||||
|
email: olivia.brown@example.com
|
||||||
|
group: FAF-224
|
||||||
|
faculty: FCTI
|
||||||
|
specialty: Software Engineering
|
||||||
|
|
||||||
|
name: Ethan
|
||||||
|
surname: Taylor
|
||||||
|
email: ethan.taylor@example.com
|
||||||
|
group: FAF-222
|
||||||
|
faculty: FCES
|
||||||
|
specialty: Food Technology
|
||||||
|
|
||||||
|
name: Sophia
|
||||||
|
surname: Clark
|
||||||
|
email: sophia.clark@example.com
|
||||||
|
group: FAF-226
|
||||||
|
faculty: FCPH
|
||||||
|
specialty: Urbanism and Architecture
|
||||||
|
|
||||||
|
name: Daniel
|
||||||
|
surname: White
|
||||||
|
email: daniel.white@example.com
|
||||||
|
group: FAF-225
|
||||||
|
faculty: FCAR
|
||||||
|
specialty: Veterinary Medicine
|
||||||
89
src/main/java/org/lumijiez/data/student.txt
Normal file
89
src/main/java/org/lumijiez/data/student.txt
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
name: Alice
|
||||||
|
surname: Johnson
|
||||||
|
email: alice.johnson@example.com
|
||||||
|
group: FAF-224
|
||||||
|
faculty: FCEX
|
||||||
|
birthdate: 1997-08-20
|
||||||
|
enroldate: 2016-09-01
|
||||||
|
specialty: Mechanical Engineering
|
||||||
|
|
||||||
|
name: David
|
||||||
|
surname: Smith
|
||||||
|
email: david.smith@example.com
|
||||||
|
group: FAF-221
|
||||||
|
faculty: FCBT
|
||||||
|
birthdate: 1999-04-10
|
||||||
|
enroldate: 2018-09-01
|
||||||
|
specialty: Software Engineering
|
||||||
|
|
||||||
|
name: Sarah
|
||||||
|
surname: Anderson
|
||||||
|
email: sarah.anderson@example.com
|
||||||
|
group: FAF-225
|
||||||
|
faculty: FCNS
|
||||||
|
birthdate: 1995-11-28
|
||||||
|
enroldate: 2017-09-01
|
||||||
|
specialty: Food Technology
|
||||||
|
|
||||||
|
name: Michael
|
||||||
|
surname: Williams
|
||||||
|
email: michael.williams@example.com
|
||||||
|
group: FAF-223
|
||||||
|
faculty: FCGT
|
||||||
|
birthdate: 1996-07-15
|
||||||
|
enroldate: 2016-09-01
|
||||||
|
specialty: Urbanism and Architecture
|
||||||
|
|
||||||
|
name: Emily
|
||||||
|
surname: Davis
|
||||||
|
email: emily.davis@example.com
|
||||||
|
group: FAF-222
|
||||||
|
faculty: FCMP
|
||||||
|
birthdate: 1998-02-03
|
||||||
|
enroldate: 2019-09-01
|
||||||
|
specialty: Veterinary Medicine
|
||||||
|
|
||||||
|
name: James
|
||||||
|
surname: Martinez
|
||||||
|
email: james.martinez@example.com
|
||||||
|
group: FAF-226
|
||||||
|
faculty: FCOE
|
||||||
|
birthdate: 1994-10-12
|
||||||
|
enroldate: 2015-09-01
|
||||||
|
specialty: Mechanical Engineering
|
||||||
|
|
||||||
|
name: Olivia
|
||||||
|
surname: Brown
|
||||||
|
email: olivia.brown@example.com
|
||||||
|
group: FAF-224
|
||||||
|
faculty: FCTI
|
||||||
|
birthdate: 1997-03-25
|
||||||
|
enroldate: 2016-09-01
|
||||||
|
specialty: Software Engineering
|
||||||
|
|
||||||
|
name: Ethan
|
||||||
|
surname: Taylor
|
||||||
|
email: ethan.taylor@example.com
|
||||||
|
group: FAF-222
|
||||||
|
faculty: FCES
|
||||||
|
birthdate: 1999-01-17
|
||||||
|
enroldate: 2018-09-01
|
||||||
|
specialty: Food Technology
|
||||||
|
|
||||||
|
name: Sophia
|
||||||
|
surname: Clark
|
||||||
|
email: sophia.clark@example.com
|
||||||
|
group: FAF-226
|
||||||
|
faculty: FCPH
|
||||||
|
birthdate: 1996-12-05
|
||||||
|
enroldate: 2017-09-01
|
||||||
|
specialty: Urbanism and Architecture
|
||||||
|
|
||||||
|
name: Daniel
|
||||||
|
surname: White
|
||||||
|
email: daniel.white@example.com
|
||||||
|
group: FAF-225
|
||||||
|
faculty: FCAR
|
||||||
|
birthdate: 1993-09-08
|
||||||
|
enroldate: 2015-09-01
|
||||||
|
specialty: Veterinary Medicine
|
||||||
53
src/main/java/org/lumijiez/enums/StudyField.java
Normal file
53
src/main/java/org/lumijiez/enums/StudyField.java
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
package org.lumijiez.enums;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public enum StudyField implements Serializable {
|
||||||
|
DEFAULT_UNASSIGNED("Unassigned", "None"),
|
||||||
|
MECHANICAL_ENGINEERING("Mechanical Engineering", "ME"),
|
||||||
|
SOFTWARE_ENGINEERING("Software Engineering", "FAF"),
|
||||||
|
FOOD_TECHNOLOGY("Food Technology", "FT"),
|
||||||
|
URBANISM_ARCHITECTURE("Urbanism and Architecture", "UA"),
|
||||||
|
VETERINARY_MEDICINE("Veterinary Medicine", "VE");
|
||||||
|
|
||||||
|
private final String name;
|
||||||
|
private final String abbreviation;
|
||||||
|
|
||||||
|
StudyField(String name, String abbreviation) {
|
||||||
|
this.name = name;
|
||||||
|
this.abbreviation = abbreviation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getAbbrevFromString(String str) {
|
||||||
|
for (StudyField st : values()) {
|
||||||
|
if (st.name.equals(str)) return st.abbreviation;
|
||||||
|
}
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static StudyField getEnum(String str) {
|
||||||
|
for (StudyField st : values()) {
|
||||||
|
if (st.name.equals(str)) return st;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<StudyField> getAllEnums() {
|
||||||
|
return Arrays.asList(values());
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAbbreviation() {
|
||||||
|
return abbreviation;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return getName();
|
||||||
|
}
|
||||||
|
}
|
||||||
36
src/main/java/org/lumijiez/enums/Subjects.java
Normal file
36
src/main/java/org/lumijiez/enums/Subjects.java
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
package org.lumijiez.enums;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
public enum Subjects implements Serializable {
|
||||||
|
ENGLISH("English Language"),
|
||||||
|
LINEAR_ALGEBRA("Linear Algebra"),
|
||||||
|
OBJECT_ORIENTED_PROGRAMMING("Object Oriented Programming"),
|
||||||
|
DATABASES("Databases"),
|
||||||
|
MATHEMATICAL_ANALYSIS("Mathematical Analysis"),
|
||||||
|
DISCRETE_MATH("Discrete Math"),
|
||||||
|
PROBABILITY_AND_STATISTICS("Probability and Statistics"),
|
||||||
|
PHYSICS("Physics");
|
||||||
|
|
||||||
|
private final String name;
|
||||||
|
|
||||||
|
Subjects(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Subjects getEnum(String str) {
|
||||||
|
for (Subjects st : values()) {
|
||||||
|
if (st.name.equals(str)) return st;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return getName();
|
||||||
|
}
|
||||||
|
}
|
||||||
387
src/main/java/org/lumijiez/gui/StudentManagementGUI.java
Normal file
387
src/main/java/org/lumijiez/gui/StudentManagementGUI.java
Normal file
@@ -0,0 +1,387 @@
|
|||||||
|
package org.lumijiez.gui;
|
||||||
|
|
||||||
|
import org.lumijiez.data.DataDeserializer;
|
||||||
|
import org.lumijiez.data.DataSerializer;
|
||||||
|
import org.lumijiez.gui.forms.faculty.*;
|
||||||
|
import org.lumijiez.gui.forms.group.AddGroupForm;
|
||||||
|
import org.lumijiez.gui.forms.group.DeleteGroupForm;
|
||||||
|
import org.lumijiez.gui.forms.group.EditGroupForm;
|
||||||
|
import org.lumijiez.gui.forms.group.ShowGroupForm;
|
||||||
|
import org.lumijiez.gui.forms.student.*;
|
||||||
|
import org.lumijiez.gui.loader.BatchGraduater;
|
||||||
|
import org.lumijiez.gui.loader.BatchLoader;
|
||||||
|
import org.lumijiez.gui.util.DisplayHandler;
|
||||||
|
import org.lumijiez.managers.Supervisor;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.WindowAdapter;
|
||||||
|
import java.awt.event.WindowEvent;
|
||||||
|
|
||||||
|
public class StudentManagementGUI extends JFrame {
|
||||||
|
private final JMenu fileMenu = new JMenu();
|
||||||
|
private final JMenu studentMenu = new JMenu();
|
||||||
|
private final JMenu groupMenu = new JMenu();
|
||||||
|
private final JMenu facultyMenu = new JMenu();
|
||||||
|
private final JMenuBar menuBar = new JMenuBar();
|
||||||
|
private static final JTextPane mainTextPane = new JTextPane();
|
||||||
|
private static Supervisor sv;
|
||||||
|
private final JScrollPane mainScrollPane = new JScrollPane();
|
||||||
|
|
||||||
|
public StudentManagementGUI() {
|
||||||
|
sv = (DataDeserializer.deserialize());
|
||||||
|
this.setSize(650, 720);
|
||||||
|
this.setTitle("Student Management System");
|
||||||
|
initComponents();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initComponents() {
|
||||||
|
|
||||||
|
JMenuItem loadBatchOption = new JMenuItem("Load as Batch", UIManager.getIcon("FileView.directoryIcon"));
|
||||||
|
JMenuItem graduateBatchOption = new JMenuItem("Graduate as Batch", UIManager.getIcon("FileView.directoryIcon"));
|
||||||
|
JMenuItem saveAsOption = new JMenuItem("Save As (WIP)", UIManager.getIcon("FileView.directoryIcon"));
|
||||||
|
JMenuItem saveAndExitOption = new JMenuItem("Save and Exit", UIManager.getIcon("FileView.directoryIcon"));
|
||||||
|
JMenuItem settingsOption = new JMenuItem("Settings (WIP)", UIManager.getIcon("FileView.directoryIcon"));
|
||||||
|
JMenuItem showAllStudentsOption = new JMenuItem("Show all Students", UIManager.getIcon("FileView.directoryIcon"));
|
||||||
|
JMenuItem showParticularStudentOption = new JMenuItem("Show a Student", UIManager.getIcon("FileView.directoryIcon"));
|
||||||
|
JMenuItem showStudentGrade = new JMenuItem("Show Student Grades", UIManager.getIcon("FileView.directoryIcon"));
|
||||||
|
JMenuItem graduateStudent = new JMenuItem("Graduate Student", UIManager.getIcon("FileView.directoryIcon"));
|
||||||
|
JMenuItem showGraduates = new JMenuItem("Show Graduates", UIManager.getIcon("FileView.directoryIcon"));
|
||||||
|
JMenuItem showEnrolled = new JMenuItem("Show Enrolled", UIManager.getIcon("FileView.directoryIcon"));
|
||||||
|
JMenuItem gradeStudentOption = new JMenuItem("Grade a Student", UIManager.getIcon("FileView.directoryIcon"));
|
||||||
|
JMenuItem addStudentOption = new JMenuItem("Add a Student", UIManager.getIcon("FileView.directoryIcon"));
|
||||||
|
JMenuItem editStudentOption = new JMenuItem("Edit a Student", UIManager.getIcon("FileView.directoryIcon"));
|
||||||
|
JMenuItem deleteStudentOption = new JMenuItem("Delete a Student", UIManager.getIcon("FileView.directoryIcon"));
|
||||||
|
JMenuItem showAllGroupsOption = new JMenuItem("Show all Groups", UIManager.getIcon("FileView.directoryIcon"));
|
||||||
|
JMenuItem showParticularGroupOption = new JMenuItem("Show a Group", UIManager.getIcon("FileView.directoryIcon"));
|
||||||
|
JMenuItem addGroupOption = new JMenuItem("Add a Group", UIManager.getIcon("FileView.directoryIcon"));
|
||||||
|
JMenuItem editGroupOption = new JMenuItem("Edit a Group", UIManager.getIcon("FileView.directoryIcon"));
|
||||||
|
JMenuItem deleteGroupOption = new JMenuItem("Delete a Group", UIManager.getIcon("FileView.directoryIcon"));
|
||||||
|
JMenuItem showAllFacultiesOption = new JMenuItem("Show all Faculties", UIManager.getIcon("FileView.directoryIcon"));
|
||||||
|
JMenuItem showFacultyBySpecialtyOption = new JMenuItem("Show Faculty by Specialty", UIManager.getIcon("FileView.directoryIcon"));
|
||||||
|
JMenuItem showParticularFacultyOption = new JMenuItem("Show a Faculty", UIManager.getIcon("FileView.directoryIcon"));
|
||||||
|
JMenuItem addFacultyOption = new JMenuItem("Add a Faculty", UIManager.getIcon("FileView.directoryIcon"));
|
||||||
|
JMenuItem editFacultyOption = new JMenuItem("Edit a Faculty", UIManager.getIcon("FileView.directoryIcon"));
|
||||||
|
JMenuItem removeFacultyOption = new JMenuItem("Remove Faculty", UIManager.getIcon("FileView.directoryIcon"));
|
||||||
|
|
||||||
|
JPopupMenu.Separator studentSeparator = new JPopupMenu.Separator();
|
||||||
|
JPopupMenu.Separator groupSeparator = new JPopupMenu.Separator();
|
||||||
|
JPopupMenu.Separator facultySeparator = new JPopupMenu.Separator();
|
||||||
|
|
||||||
|
fileMenu.setText("File");
|
||||||
|
studentMenu.setText("Student Options");
|
||||||
|
groupMenu.setText("Group Options");
|
||||||
|
facultyMenu.setText("Faculty Options");
|
||||||
|
|
||||||
|
mainTextPane.setEditable(false);
|
||||||
|
mainTextPane.setContentType("text/html");
|
||||||
|
mainTextPane.setFont(new Font("Segoe UI", Font.PLAIN, 14));
|
||||||
|
mainScrollPane.setViewportView(mainTextPane);
|
||||||
|
|
||||||
|
setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
|
||||||
|
|
||||||
|
this.addWindowListener(new WindowAdapter() {
|
||||||
|
@Override
|
||||||
|
public void windowClosing(WindowEvent e) {
|
||||||
|
int result = JOptionPane.showConfirmDialog(
|
||||||
|
StudentManagementGUI.this,
|
||||||
|
"Are you sure you want to exit?",
|
||||||
|
"Confirmation",
|
||||||
|
JOptionPane.YES_NO_OPTION);
|
||||||
|
|
||||||
|
if (result == JOptionPane.YES_OPTION) {
|
||||||
|
DataSerializer.serialize(sv);
|
||||||
|
dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
loadBatchOption.addActionListener(this::loadBatchEvent);
|
||||||
|
graduateBatchOption.addActionListener(this::graduateBatchEvent);
|
||||||
|
saveAsOption.addActionListener(this::saveAsEvent);
|
||||||
|
saveAndExitOption.addActionListener(this::saveExitEvent);
|
||||||
|
|
||||||
|
fileMenu.add(loadBatchOption);
|
||||||
|
fileMenu.add(graduateBatchOption);
|
||||||
|
fileMenu.add(saveAsOption);
|
||||||
|
fileMenu.add(saveAndExitOption);
|
||||||
|
fileMenu.add(settingsOption);
|
||||||
|
|
||||||
|
menuBar.add(fileMenu);
|
||||||
|
|
||||||
|
showAllStudentsOption.addActionListener(this::showAllStudentsEvent);
|
||||||
|
showParticularStudentOption.addActionListener(this::showStudentEvent);
|
||||||
|
showStudentGrade.addActionListener(this::showGradeEvent);
|
||||||
|
gradeStudentOption.addActionListener(this::gradeStudentEvent);
|
||||||
|
addStudentOption.addActionListener(this::addStudentEvent);
|
||||||
|
editStudentOption.addActionListener(this::editStudentEvent);
|
||||||
|
deleteStudentOption.addActionListener(this::deleteStudentEvent);
|
||||||
|
graduateStudent.addActionListener(this::graduateStudentEvent);
|
||||||
|
showEnrolled.addActionListener(this::showEnrolledEvent);
|
||||||
|
showGraduates.addActionListener(this::showGraduatesEvent);
|
||||||
|
|
||||||
|
studentMenu.add(showAllStudentsOption);
|
||||||
|
studentMenu.add(showParticularStudentOption);
|
||||||
|
studentMenu.add(showStudentGrade);
|
||||||
|
studentMenu.add(showEnrolled);
|
||||||
|
studentMenu.add(showGraduates);
|
||||||
|
studentMenu.add(studentSeparator);
|
||||||
|
studentMenu.add(graduateStudent);
|
||||||
|
studentMenu.add(gradeStudentOption);
|
||||||
|
studentMenu.add(addStudentOption);
|
||||||
|
studentMenu.add(editStudentOption);
|
||||||
|
studentMenu.add(deleteStudentOption);
|
||||||
|
|
||||||
|
menuBar.add(studentMenu);
|
||||||
|
|
||||||
|
showAllGroupsOption.addActionListener(this::showAllGroupsEvent);
|
||||||
|
showParticularGroupOption.addActionListener(this::showGroupEvent);
|
||||||
|
addGroupOption.addActionListener(this::addGroupEvent);
|
||||||
|
editGroupOption.addActionListener(this::editGroupEvent);
|
||||||
|
deleteGroupOption.addActionListener(this::deleteGroupEvent);
|
||||||
|
|
||||||
|
groupMenu.add(showAllGroupsOption);
|
||||||
|
groupMenu.add(showParticularGroupOption);
|
||||||
|
groupMenu.add(groupSeparator);
|
||||||
|
groupMenu.add(addGroupOption);
|
||||||
|
groupMenu.add(editGroupOption);
|
||||||
|
groupMenu.add(deleteGroupOption);
|
||||||
|
|
||||||
|
menuBar.add(groupMenu);
|
||||||
|
|
||||||
|
showAllFacultiesOption.addActionListener(this::showAllFacultiesEvent);
|
||||||
|
showParticularFacultyOption.addActionListener(this::showFacultyEvent);
|
||||||
|
showFacultyBySpecialtyOption.addActionListener(this::showFacultySpecEvent);
|
||||||
|
addFacultyOption.addActionListener(this::addFacultyEvent);
|
||||||
|
editFacultyOption.addActionListener(this::editFacultyEvent);
|
||||||
|
removeFacultyOption.addActionListener(this::deleteFacultyEvent);
|
||||||
|
|
||||||
|
facultyMenu.add(showAllFacultiesOption);
|
||||||
|
facultyMenu.add(showParticularFacultyOption);
|
||||||
|
facultyMenu.add(showFacultyBySpecialtyOption);
|
||||||
|
facultyMenu.add(facultySeparator);
|
||||||
|
facultyMenu.add(addFacultyOption);
|
||||||
|
facultyMenu.add(editFacultyOption);
|
||||||
|
facultyMenu.add(removeFacultyOption);
|
||||||
|
|
||||||
|
menuBar.add(facultyMenu);
|
||||||
|
|
||||||
|
setJMenuBar(menuBar);
|
||||||
|
|
||||||
|
DisplayHandler.displayStudents();
|
||||||
|
|
||||||
|
GroupLayout layout = new GroupLayout(getContentPane());
|
||||||
|
getContentPane().setLayout(layout);
|
||||||
|
layout.setHorizontalGroup(
|
||||||
|
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addComponent(mainScrollPane, GroupLayout.DEFAULT_SIZE, 650, Short.MAX_VALUE));
|
||||||
|
layout.setVerticalGroup(
|
||||||
|
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addComponent(mainScrollPane, GroupLayout.DEFAULT_SIZE, 697, Short.MAX_VALUE));
|
||||||
|
pack();
|
||||||
|
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
|
||||||
|
int x = (screenSize.width - this.getWidth()) / 2;
|
||||||
|
int y = (screenSize.height - this.getHeight()) / 2;
|
||||||
|
this.setLocation(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showFacultySpecEvent(ActionEvent actionEvent) {
|
||||||
|
ShowSpecialtyFacultyForm form = new ShowSpecialtyFacultyForm(sv, mainTextPane);
|
||||||
|
form.setVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void graduateBatchEvent(ActionEvent actionEvent) {
|
||||||
|
BatchGraduater picker = new BatchGraduater(sv);
|
||||||
|
picker.setVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showGraduatesEvent(ActionEvent actionEvent) {
|
||||||
|
if (checkStudent() && checkGroup() && checkFaculty()) {
|
||||||
|
DisplayHandler.displayGraduates();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showEnrolledEvent(ActionEvent actionEvent) {
|
||||||
|
if (checkStudent() && checkGroup() && checkFaculty()) {
|
||||||
|
DisplayHandler.displayEnrolled();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void graduateStudentEvent(ActionEvent actionEvent) {
|
||||||
|
if (checkStudent() && checkGroup() && checkFaculty()) {
|
||||||
|
GraduateStudentForm form = new GraduateStudentForm(sv);
|
||||||
|
form.setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showAllStudentsEvent(ActionEvent actionEvent) {
|
||||||
|
if (checkStudent() && checkGroup() && checkFaculty()) {
|
||||||
|
DisplayHandler.displayStudents();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showAllGroupsEvent(ActionEvent actionEvent) {
|
||||||
|
if (checkGroup() && checkFaculty()) {
|
||||||
|
DisplayHandler.displayGroups();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void deleteGroupEvent(ActionEvent actionEvent) {
|
||||||
|
if (checkGroup() && checkFaculty()) {
|
||||||
|
DeleteGroupForm form = new DeleteGroupForm(sv);
|
||||||
|
form.setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadBatchEvent(ActionEvent evt) {
|
||||||
|
BatchLoader picker = new BatchLoader(sv);
|
||||||
|
picker.setVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void saveExitEvent(ActionEvent evt) {
|
||||||
|
int result = JOptionPane.showConfirmDialog(
|
||||||
|
StudentManagementGUI.this,
|
||||||
|
"Are you sure you want to exit?",
|
||||||
|
"Confirmation",
|
||||||
|
JOptionPane.YES_NO_OPTION);
|
||||||
|
|
||||||
|
if (result == JOptionPane.YES_OPTION) {
|
||||||
|
DataSerializer.serialize(sv);
|
||||||
|
sv.getLogger().logOperation("Died!");
|
||||||
|
sv.getLogger().close();
|
||||||
|
dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showAllFacultiesEvent(ActionEvent evt) {
|
||||||
|
if (checkFaculty()) {
|
||||||
|
DisplayHandler.displayFaculties();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void saveAsEvent(ActionEvent evt) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showGroupEvent(ActionEvent evt) {
|
||||||
|
if (checkGroup() && checkFaculty()) {
|
||||||
|
ShowGroupForm form = new ShowGroupForm(sv, mainTextPane);
|
||||||
|
form.setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addFacultyEvent(ActionEvent evt) {
|
||||||
|
AddFacultyForm form = new AddFacultyForm(sv);
|
||||||
|
form.setVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addStudentEvent(ActionEvent evt) {
|
||||||
|
if (checkGroup() && checkFaculty()) {
|
||||||
|
AddStudentForm form = new AddStudentForm(sv);
|
||||||
|
form.setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void gradeStudentEvent(ActionEvent evt) {
|
||||||
|
if (checkStudent() && checkGroup() && checkFaculty()) {
|
||||||
|
GradeStudentForm form = new GradeStudentForm(sv, mainTextPane);
|
||||||
|
form.setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void editStudentEvent(ActionEvent evt) {
|
||||||
|
if (checkStudent() && checkGroup() && checkFaculty()) {
|
||||||
|
EditStudentForm form = new EditStudentForm(sv);
|
||||||
|
form.setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void deleteStudentEvent(ActionEvent evt) {
|
||||||
|
if (checkStudent() && checkGroup() && checkFaculty()) {
|
||||||
|
DeleteStudentForm form = new DeleteStudentForm(sv);
|
||||||
|
form.setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showGradeEvent(ActionEvent evt) {
|
||||||
|
if (checkStudent() && checkGroup() && checkFaculty()) {
|
||||||
|
ShowStudentGradesForm form = new ShowStudentGradesForm(sv, mainTextPane);
|
||||||
|
form.setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showStudentEvent(ActionEvent evt) {
|
||||||
|
if (checkStudent() && checkGroup() && checkFaculty()) {
|
||||||
|
ShowStudentForm form = new ShowStudentForm(sv, mainTextPane);
|
||||||
|
form.setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addGroupEvent(ActionEvent evt) {
|
||||||
|
if (checkFaculty()) {
|
||||||
|
AddGroupForm form = new AddGroupForm(sv);
|
||||||
|
form.setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void editGroupEvent(ActionEvent evt) {
|
||||||
|
if (checkGroup() && checkFaculty()) {
|
||||||
|
EditGroupForm form = new EditGroupForm(sv);
|
||||||
|
form.setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showFacultyEvent(ActionEvent evt) {
|
||||||
|
if (checkFaculty()) {
|
||||||
|
ShowFacultyForm form = new ShowFacultyForm(sv, mainTextPane);
|
||||||
|
form.setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void editFacultyEvent(ActionEvent evt) {
|
||||||
|
if (checkFaculty()) {
|
||||||
|
EditFacultyForm form = new EditFacultyForm(sv);
|
||||||
|
form.setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void deleteFacultyEvent(ActionEvent evt) {
|
||||||
|
if (checkFaculty()) {
|
||||||
|
RemoveFacultyForm form = new RemoveFacultyForm(sv);
|
||||||
|
form.setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean checkFaculty() {
|
||||||
|
if (sv.facultyManager().getFaculties().isEmpty()) {
|
||||||
|
JOptionPane.showMessageDialog(null, "Configure a faculty!", "Warning!", JOptionPane.INFORMATION_MESSAGE, null);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean checkGroup() {
|
||||||
|
if (sv.groupManager().getGroups().isEmpty()) {
|
||||||
|
JOptionPane.showMessageDialog(null, "Configure a group!", "Warning!", JOptionPane.INFORMATION_MESSAGE, null);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean checkStudent() {
|
||||||
|
if (sv.studentManager().getStudents().isEmpty()) {
|
||||||
|
JOptionPane.showMessageDialog(null, "No students in database!", "Warning!", JOptionPane.INFORMATION_MESSAGE, null);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static JTextPane getMainPane() {
|
||||||
|
return mainTextPane;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Supervisor getSv() {
|
||||||
|
return sv;
|
||||||
|
}
|
||||||
|
}
|
||||||
129
src/main/java/org/lumijiez/gui/forms/faculty/AddFacultyForm.java
Normal file
129
src/main/java/org/lumijiez/gui/forms/faculty/AddFacultyForm.java
Normal file
@@ -0,0 +1,129 @@
|
|||||||
|
package org.lumijiez.gui.forms.faculty;
|
||||||
|
|
||||||
|
import org.lumijiez.base.Faculty;
|
||||||
|
import org.lumijiez.enums.StudyField;
|
||||||
|
import org.lumijiez.gui.util.ComboRenderer;
|
||||||
|
import org.lumijiez.gui.util.ComponentDecorator;
|
||||||
|
import org.lumijiez.gui.util.DisplayHandler;
|
||||||
|
import org.lumijiez.gui.util.WindowConfig;
|
||||||
|
import org.lumijiez.managers.Supervisor;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class AddFacultyForm extends JFrame {
|
||||||
|
private final JLabel titleLabel = new JLabel();
|
||||||
|
private final JLabel nameLabel = new JLabel();
|
||||||
|
private final JLabel abbreviationLabel = new JLabel();
|
||||||
|
private final JLabel specialtyLabel = new JLabel();
|
||||||
|
private final JButton submitButton = new JButton();
|
||||||
|
private final JButton cancelButton = new JButton();
|
||||||
|
private final JTextField nameField = new JTextField();
|
||||||
|
private final JTextField abbreviationField = new JTextField();
|
||||||
|
private final JComboBox<StudyField> specialtyCombo = new JComboBox<>();
|
||||||
|
private final Supervisor sv;
|
||||||
|
|
||||||
|
public AddFacultyForm(Supervisor sv) {
|
||||||
|
this.sv = sv;
|
||||||
|
initComponents();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initComponents() {
|
||||||
|
|
||||||
|
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||||
|
|
||||||
|
titleLabel.setFont(new Font("sansserif", Font.PLAIN, 18));
|
||||||
|
setTitle("Add a Faculty");
|
||||||
|
|
||||||
|
titleLabel.setText("Add a new faculty");
|
||||||
|
submitButton.setText("Submit");
|
||||||
|
cancelButton.setText("Cancel");
|
||||||
|
nameLabel.setText("Name:");
|
||||||
|
abbreviationLabel.setText("Abbreviation:");
|
||||||
|
specialtyLabel.setText("Specialty Field:");
|
||||||
|
|
||||||
|
ComponentDecorator.submitAndCancel(submitButton, cancelButton);
|
||||||
|
|
||||||
|
ComboRenderer.setRenderer(specialtyCombo, StudyField.getAllEnums().toArray(new StudyField[0]));
|
||||||
|
|
||||||
|
abbreviationField.setText(StudyField.getAbbrevFromString(Objects.requireNonNull(specialtyCombo.getSelectedItem()).toString()));
|
||||||
|
|
||||||
|
specialtyCombo.addActionListener(this::specialtyComboEvent);
|
||||||
|
submitButton.addActionListener(this::submitEvent);
|
||||||
|
cancelButton.addActionListener(this::cancelEvent);
|
||||||
|
|
||||||
|
GroupLayout layout = new GroupLayout(getContentPane());
|
||||||
|
getContentPane().setLayout(layout);
|
||||||
|
layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGap(25, 25, 25)
|
||||||
|
.addComponent(abbreviationLabel))
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGap(21, 21, 21)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
|
||||||
|
.addComponent(abbreviationField, GroupLayout.DEFAULT_SIZE, 178, Short.MAX_VALUE)
|
||||||
|
.addComponent(nameField)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGap(5, 5, 5)
|
||||||
|
.addComponent(nameLabel)))
|
||||||
|
.addGap(40, 40, 40)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addComponent(specialtyLabel)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addComponent(cancelButton)
|
||||||
|
.addGap(29, 29, 29)
|
||||||
|
.addComponent(submitButton))
|
||||||
|
.addComponent(specialtyCombo, GroupLayout.PREFERRED_SIZE, 173, GroupLayout.PREFERRED_SIZE))))
|
||||||
|
.addContainerGap(30, Short.MAX_VALUE))
|
||||||
|
.addGroup(GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||||
|
.addGap(0, 0, Short.MAX_VALUE)
|
||||||
|
.addComponent(titleLabel)
|
||||||
|
.addGap(149, 149, 149)));
|
||||||
|
layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGap(7, 7, 7)
|
||||||
|
.addComponent(titleLabel)
|
||||||
|
.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||||
|
.addComponent(nameLabel).addComponent(specialtyLabel))
|
||||||
|
.addGap(3, 3, 3)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||||
|
.addComponent(nameField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addComponent(specialtyCombo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
|
||||||
|
.addGap(11, 11, 11)
|
||||||
|
.addComponent(abbreviationLabel)
|
||||||
|
.addGap(5, 5, 5)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||||
|
.addComponent(abbreviationField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addComponent(cancelButton)
|
||||||
|
.addComponent(submitButton))
|
||||||
|
.addContainerGap(24, Short.MAX_VALUE)));
|
||||||
|
pack();
|
||||||
|
WindowConfig.center(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void submitEvent(ActionEvent evt) {
|
||||||
|
String name = nameField.getText();
|
||||||
|
String abbreviation = abbreviationField.getText();
|
||||||
|
StudyField specialty = StudyField.getEnum(Objects.requireNonNull(specialtyCombo.getSelectedItem()).toString());
|
||||||
|
if (!name.isEmpty()) {
|
||||||
|
Faculty newFaculty = new Faculty(name, abbreviation, specialty);
|
||||||
|
sv.addFaculty(newFaculty);
|
||||||
|
DisplayHandler.displayFaculties();
|
||||||
|
this.dispose();
|
||||||
|
} else JOptionPane.showMessageDialog(null, "Fill in all the fields!", "Warning!", JOptionPane.INFORMATION_MESSAGE, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void specialtyComboEvent(ActionEvent evt) {
|
||||||
|
abbreviationField.setText(StudyField.getAbbrevFromString(Objects.requireNonNull(specialtyCombo.getSelectedItem()).toString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void cancelEvent(ActionEvent evt) {
|
||||||
|
this.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,144 @@
|
|||||||
|
package org.lumijiez.gui.forms.faculty;
|
||||||
|
|
||||||
|
import org.lumijiez.base.Faculty;
|
||||||
|
import org.lumijiez.enums.StudyField;
|
||||||
|
import org.lumijiez.gui.util.ComboRenderer;
|
||||||
|
import org.lumijiez.gui.util.ComponentDecorator;
|
||||||
|
import org.lumijiez.gui.util.DisplayHandler;
|
||||||
|
import org.lumijiez.gui.util.WindowConfig;
|
||||||
|
import org.lumijiez.managers.Supervisor;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class EditFacultyForm extends JFrame {
|
||||||
|
private final JLabel abbreviationLabel = new JLabel();
|
||||||
|
private final JLabel facultyLabel = new JLabel();
|
||||||
|
private final JLabel nameLabel = new JLabel();
|
||||||
|
private final JLabel specialtyLabel = new JLabel();
|
||||||
|
private final JLabel titleLabel = new JLabel();
|
||||||
|
private final JButton cancelButton = new JButton();
|
||||||
|
private final JButton submitButton = new JButton();
|
||||||
|
private final JTextField abbreviationField = new JTextField();
|
||||||
|
private final JTextField nameField = new JTextField();
|
||||||
|
private final JComboBox<Faculty> facultyCombo = new JComboBox<>();
|
||||||
|
private final JComboBox<StudyField> specialtyCombo = new JComboBox<>();
|
||||||
|
private final Supervisor sv;
|
||||||
|
|
||||||
|
public EditFacultyForm(Supervisor sv) {
|
||||||
|
this.sv = sv;
|
||||||
|
initComponents();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initComponents() {
|
||||||
|
|
||||||
|
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||||
|
|
||||||
|
titleLabel.setFont(new Font("sansserif", Font.PLAIN, 18));
|
||||||
|
setTitle("Edit a Faculty");
|
||||||
|
|
||||||
|
titleLabel.setText("Edit a faculty");
|
||||||
|
submitButton.setText("Submit");
|
||||||
|
cancelButton.setText("Cancel");
|
||||||
|
nameLabel.setText("New name:");
|
||||||
|
facultyLabel.setText("Faculty:");
|
||||||
|
specialtyLabel.setText("New specialty:");
|
||||||
|
|
||||||
|
ComponentDecorator.submitAndCancel(submitButton, cancelButton);
|
||||||
|
|
||||||
|
cancelButton.addActionListener(this::cancelEvent);
|
||||||
|
submitButton.addActionListener(this::submitEvent);
|
||||||
|
specialtyCombo.addActionListener(this::specialtyComboEvent);
|
||||||
|
facultyCombo.addActionListener(this::facultyComboEvent);
|
||||||
|
|
||||||
|
ComboRenderer.setRenderer(facultyCombo, sv.facultyManager().getFaculties().toArray(new Faculty[0]));
|
||||||
|
ComboRenderer.setRenderer(specialtyCombo, StudyField.getAllEnums().toArray(new StudyField[0]));
|
||||||
|
|
||||||
|
specialtyCombo.setSelectedItem(((Faculty) Objects.requireNonNull(facultyCombo.getSelectedItem())).getField());
|
||||||
|
|
||||||
|
GroupLayout layout = new GroupLayout(getContentPane());
|
||||||
|
getContentPane().setLayout(layout);
|
||||||
|
layout.setHorizontalGroup(
|
||||||
|
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGap(120, 120, 120)
|
||||||
|
.addComponent(titleLabel))
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGap(25, 25, 25)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addComponent(facultyLabel)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
|
||||||
|
.addComponent(specialtyLabel)
|
||||||
|
.addComponent(facultyCombo, 0, 115, Short.MAX_VALUE)
|
||||||
|
.addComponent(specialtyCombo, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||||
|
.addGap(18, 18, 18)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addComponent(abbreviationLabel)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.TRAILING)
|
||||||
|
.addComponent(abbreviationField, GroupLayout.PREFERRED_SIZE, 178, GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addComponent(nameField, GroupLayout.PREFERRED_SIZE, 178, GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addComponent(cancelButton)
|
||||||
|
.addGap(18, 18, 18)
|
||||||
|
.addComponent(submitButton)))
|
||||||
|
.addComponent(nameLabel))))))
|
||||||
|
.addContainerGap(24, Short.MAX_VALUE)));
|
||||||
|
layout.setVerticalGroup(
|
||||||
|
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addContainerGap()
|
||||||
|
.addComponent(titleLabel)
|
||||||
|
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||||
|
.addComponent(nameLabel)
|
||||||
|
.addComponent(facultyLabel))
|
||||||
|
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addComponent(nameField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addComponent(facultyCombo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
|
||||||
|
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||||
|
.addComponent(abbreviationLabel)
|
||||||
|
.addComponent(specialtyLabel))
|
||||||
|
.addGap(5, 5, 5)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||||
|
.addComponent(abbreviationField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addComponent(specialtyCombo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
|
||||||
|
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 28, Short.MAX_VALUE)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||||
|
.addComponent(cancelButton)
|
||||||
|
.addComponent(submitButton))
|
||||||
|
.addGap(14, 14, 14)));
|
||||||
|
pack();
|
||||||
|
WindowConfig.center(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void facultyComboEvent(ActionEvent actionEvent) {
|
||||||
|
Faculty fac = ((Faculty) Objects.requireNonNull(facultyCombo.getSelectedItem()));
|
||||||
|
specialtyCombo.setSelectedItem(fac.getField());
|
||||||
|
nameField.setText(fac.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void specialtyComboEvent(ActionEvent actionEvent) {
|
||||||
|
abbreviationField.setText(((StudyField) Objects.requireNonNull(specialtyCombo.getSelectedItem())).getAbbreviation());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void submitEvent(ActionEvent evt) {
|
||||||
|
((Faculty) Objects.requireNonNull(facultyCombo.getSelectedItem())).setName(nameField.getText());
|
||||||
|
((Faculty) Objects.requireNonNull(facultyCombo.getSelectedItem())).setAbbreviation(abbreviationField.getText());
|
||||||
|
((Faculty) Objects.requireNonNull(facultyCombo.getSelectedItem())).setField(((StudyField) Objects.requireNonNull(specialtyCombo.getSelectedItem())));
|
||||||
|
DisplayHandler.displayFaculties();
|
||||||
|
sv.getLogger().logOperation("Faculty edited : " + ((Faculty) Objects.requireNonNull(facultyCombo.getSelectedItem())).getName());
|
||||||
|
this.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void cancelEvent(ActionEvent evt) {
|
||||||
|
this.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,93 @@
|
|||||||
|
package org.lumijiez.gui.forms.faculty;
|
||||||
|
|
||||||
|
import org.lumijiez.base.Faculty;
|
||||||
|
import org.lumijiez.gui.util.ComboRenderer;
|
||||||
|
import org.lumijiez.gui.util.ComponentDecorator;
|
||||||
|
import org.lumijiez.gui.util.DisplayHandler;
|
||||||
|
import org.lumijiez.gui.util.WindowConfig;
|
||||||
|
import org.lumijiez.managers.Supervisor;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
|
||||||
|
public class RemoveFacultyForm extends JFrame {
|
||||||
|
private final JLabel facultyLabel = new JLabel();
|
||||||
|
private final JLabel titleLabel = new JLabel();
|
||||||
|
private final JButton cancelButton = new JButton();
|
||||||
|
private final JButton submitButton = new JButton();
|
||||||
|
private final JComboBox<Faculty> facultyCombo = new JComboBox<>();
|
||||||
|
private final Supervisor sv;
|
||||||
|
|
||||||
|
public RemoveFacultyForm(Supervisor sv) {
|
||||||
|
this.sv = sv;
|
||||||
|
initComponents();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initComponents() {
|
||||||
|
|
||||||
|
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||||
|
|
||||||
|
titleLabel.setFont(new Font("sansserif", Font.PLAIN, 18));
|
||||||
|
setTitle("Remove a Faculty");
|
||||||
|
|
||||||
|
titleLabel.setText("Remove a faculty");
|
||||||
|
submitButton.setText("Submit");
|
||||||
|
cancelButton.setText("Cancel");
|
||||||
|
facultyLabel.setText("Faculty:");
|
||||||
|
|
||||||
|
ComponentDecorator.submitAndCancel(submitButton, cancelButton);
|
||||||
|
|
||||||
|
submitButton.addActionListener(this::submitEvent);
|
||||||
|
cancelButton.addActionListener(this::cancelEvent);
|
||||||
|
|
||||||
|
ComboRenderer.setRenderer(facultyCombo, sv.facultyManager().getFaculties().toArray(new Faculty[0]));
|
||||||
|
|
||||||
|
GroupLayout layout = new GroupLayout(getContentPane());
|
||||||
|
getContentPane().setLayout(layout);
|
||||||
|
layout.setHorizontalGroup(
|
||||||
|
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGap(22, 22, 22)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.TRAILING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addComponent(cancelButton)
|
||||||
|
.addGap(38, 38, 38)
|
||||||
|
.addComponent(submitButton))
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addComponent(facultyLabel)
|
||||||
|
.addComponent(facultyCombo, GroupLayout.PREFERRED_SIZE, 250, GroupLayout.PREFERRED_SIZE)))
|
||||||
|
.addContainerGap(32, Short.MAX_VALUE))
|
||||||
|
.addGroup(GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||||
|
.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
|
.addComponent(titleLabel)
|
||||||
|
.addGap(48, 48, 48)));
|
||||||
|
layout.setVerticalGroup(
|
||||||
|
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addContainerGap()
|
||||||
|
.addComponent(titleLabel)
|
||||||
|
.addGap(18, 18, 18)
|
||||||
|
.addComponent(facultyLabel)
|
||||||
|
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addComponent(facultyCombo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addGap(18, 18, 18)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||||
|
.addComponent(cancelButton)
|
||||||
|
.addComponent(submitButton))
|
||||||
|
.addContainerGap(21, Short.MAX_VALUE)));
|
||||||
|
pack();
|
||||||
|
WindowConfig.center(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void submitEvent(ActionEvent evt) {
|
||||||
|
sv.deleteFaculty(((Faculty) facultyCombo.getSelectedItem()));
|
||||||
|
DisplayHandler.displayFaculties();
|
||||||
|
this.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void cancelEvent(ActionEvent evt) {
|
||||||
|
this.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,107 @@
|
|||||||
|
package org.lumijiez.gui.forms.faculty;
|
||||||
|
|
||||||
|
import org.lumijiez.base.Faculty;
|
||||||
|
import org.lumijiez.base.Group;
|
||||||
|
import org.lumijiez.gui.util.ComboRenderer;
|
||||||
|
import org.lumijiez.gui.util.ComponentDecorator;
|
||||||
|
import org.lumijiez.gui.util.Settings;
|
||||||
|
import org.lumijiez.gui.util.WindowConfig;
|
||||||
|
import org.lumijiez.managers.Supervisor;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
|
||||||
|
public class ShowFacultyForm extends JFrame {
|
||||||
|
private final JLabel titleLabel = new JLabel();
|
||||||
|
private final JLabel facultyLabel = new JLabel();
|
||||||
|
private final JButton cancelButton = new JButton();
|
||||||
|
private final JButton submitButton = new JButton();
|
||||||
|
private final JComboBox<Faculty> facultyCombo = new JComboBox<>();
|
||||||
|
private final Supervisor sv;
|
||||||
|
private final JTextPane mainTextLabel;
|
||||||
|
|
||||||
|
public ShowFacultyForm(Supervisor sv, JTextPane mainTextLabel) {
|
||||||
|
this.sv = sv;
|
||||||
|
this.mainTextLabel = mainTextLabel;
|
||||||
|
initComponents();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initComponents() {
|
||||||
|
|
||||||
|
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||||
|
|
||||||
|
titleLabel.setFont(new Font("sansserif", Font.PLAIN, 18));
|
||||||
|
setTitle("Show a Faculty");
|
||||||
|
|
||||||
|
titleLabel.setText("Show a faculty");
|
||||||
|
submitButton.setText("Submit");
|
||||||
|
cancelButton.setText("Cancel");
|
||||||
|
facultyLabel.setText("Faculty:");
|
||||||
|
|
||||||
|
ComponentDecorator.submitAndCancel(submitButton, cancelButton);
|
||||||
|
|
||||||
|
submitButton.addActionListener(this::submitEvent);
|
||||||
|
cancelButton.addActionListener(this::cancelEvent);
|
||||||
|
|
||||||
|
ComboRenderer.setRenderer(facultyCombo, sv.facultyManager().getFaculties().toArray(new Faculty[0]));
|
||||||
|
|
||||||
|
GroupLayout layout = new GroupLayout(getContentPane());
|
||||||
|
getContentPane().setLayout(layout);
|
||||||
|
layout.setHorizontalGroup(
|
||||||
|
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGap(46, 46, 46)
|
||||||
|
.addComponent(titleLabel))
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGap(26, 26, 26)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addComponent(facultyLabel)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.TRAILING, false)
|
||||||
|
.addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
|
||||||
|
.addComponent(cancelButton)
|
||||||
|
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
|
.addComponent(submitButton))
|
||||||
|
.addComponent(facultyCombo, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 250, GroupLayout.PREFERRED_SIZE)))))
|
||||||
|
.addContainerGap(27, Short.MAX_VALUE)));
|
||||||
|
layout.setVerticalGroup(
|
||||||
|
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGap(13, 13, 13)
|
||||||
|
.addComponent(titleLabel)
|
||||||
|
.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
|
||||||
|
.addComponent(facultyLabel)
|
||||||
|
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addComponent(facultyCombo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addGap(18, 18, 18)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||||
|
.addComponent(cancelButton)
|
||||||
|
.addComponent(submitButton))
|
||||||
|
.addContainerGap(24, Short.MAX_VALUE)));
|
||||||
|
pack();
|
||||||
|
WindowConfig.center(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void submitEvent(ActionEvent evt) {
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
Faculty fac = (Faculty) facultyCombo.getSelectedItem();
|
||||||
|
assert fac != null;
|
||||||
|
builder.append("<font size='").append(Settings.FontSize).append("'><strong>===================== Faculty Info ========================</strong><br>");
|
||||||
|
builder.append("<b>Name: </b>").append(fac.getName()).append("<br>");
|
||||||
|
builder.append("<b>Specialty: </b>").append(fac.getField()).append("<br>");
|
||||||
|
builder.append("<b>Groups: </b>").append("<br>");
|
||||||
|
builder.append("<strong>==========</strong><br>");
|
||||||
|
for (Group gr : fac.getGroups())
|
||||||
|
builder.append(gr.getName()).append("<br>").append("<strong>==========</strong><br>");
|
||||||
|
builder.append("<strong>============================================================</strong>");
|
||||||
|
mainTextLabel.setText(builder.toString());
|
||||||
|
this.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void cancelEvent(ActionEvent evt) {
|
||||||
|
this.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,107 @@
|
|||||||
|
package org.lumijiez.gui.forms.faculty;
|
||||||
|
|
||||||
|
import org.lumijiez.base.Faculty;
|
||||||
|
import org.lumijiez.enums.StudyField;
|
||||||
|
import org.lumijiez.gui.util.ComboRenderer;
|
||||||
|
import org.lumijiez.gui.util.ComponentDecorator;
|
||||||
|
import org.lumijiez.gui.util.Settings;
|
||||||
|
import org.lumijiez.gui.util.WindowConfig;
|
||||||
|
import org.lumijiez.managers.Supervisor;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
|
||||||
|
public class ShowSpecialtyFacultyForm extends JFrame {
|
||||||
|
private final JLabel titleLabel = new JLabel();
|
||||||
|
private final JLabel facultyLabel = new JLabel();
|
||||||
|
private final JButton cancelButton = new JButton();
|
||||||
|
private final JButton submitButton = new JButton();
|
||||||
|
private final JComboBox<StudyField> specialtyCombo = new JComboBox<>();
|
||||||
|
private final Supervisor sv;
|
||||||
|
private final JTextPane mainTextLabel;
|
||||||
|
|
||||||
|
public ShowSpecialtyFacultyForm(Supervisor sv, JTextPane mainTextLabel) {
|
||||||
|
this.sv = sv;
|
||||||
|
this.mainTextLabel = mainTextLabel;
|
||||||
|
initComponents();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initComponents() {
|
||||||
|
|
||||||
|
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||||
|
|
||||||
|
titleLabel.setFont(new Font("sansserif", Font.PLAIN, 18));
|
||||||
|
setTitle("Show a Faculty by Specialty");
|
||||||
|
|
||||||
|
titleLabel.setText("Show a faculty");
|
||||||
|
submitButton.setText("Submit");
|
||||||
|
cancelButton.setText("Cancel");
|
||||||
|
facultyLabel.setText("Faculty:");
|
||||||
|
|
||||||
|
ComponentDecorator.submitAndCancel(submitButton, cancelButton);
|
||||||
|
|
||||||
|
submitButton.addActionListener(this::submitEvent);
|
||||||
|
cancelButton.addActionListener(this::cancelEvent);
|
||||||
|
|
||||||
|
ComboRenderer.setRenderer(specialtyCombo, StudyField.getAllEnums().toArray(new StudyField[0]));
|
||||||
|
|
||||||
|
GroupLayout layout = new GroupLayout(getContentPane());
|
||||||
|
getContentPane().setLayout(layout);
|
||||||
|
layout.setHorizontalGroup(
|
||||||
|
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGap(46, 46, 46)
|
||||||
|
.addComponent(titleLabel))
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGap(26, 26, 26)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addComponent(facultyLabel)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.TRAILING, false)
|
||||||
|
.addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
|
||||||
|
.addComponent(cancelButton)
|
||||||
|
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
|
.addComponent(submitButton))
|
||||||
|
.addComponent(specialtyCombo, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 250, GroupLayout.PREFERRED_SIZE)))))
|
||||||
|
.addContainerGap(27, Short.MAX_VALUE)));
|
||||||
|
layout.setVerticalGroup(
|
||||||
|
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGap(13, 13, 13)
|
||||||
|
.addComponent(titleLabel)
|
||||||
|
.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
|
||||||
|
.addComponent(facultyLabel)
|
||||||
|
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addComponent(specialtyCombo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addGap(18, 18, 18)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||||
|
.addComponent(cancelButton)
|
||||||
|
.addComponent(submitButton))
|
||||||
|
.addContainerGap(24, Short.MAX_VALUE)));
|
||||||
|
pack();
|
||||||
|
WindowConfig.center(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void submitEvent(ActionEvent evt) {
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
StudyField fac = (StudyField) specialtyCombo.getSelectedItem();
|
||||||
|
assert fac != null;
|
||||||
|
builder.append("<font size='").append(Settings.FontSize).append("'><strong>==================== Specialty Info =======================<strong><br>");
|
||||||
|
builder.append("<b>Specialty: </b>").append(fac.getName()).append("<br>");
|
||||||
|
builder.append("<strong>==========</strong><br>");
|
||||||
|
builder.append("<b>Faculties: </b>").append("<br>");
|
||||||
|
for (Faculty fc : sv.facultyManager().getFaculties())
|
||||||
|
if (fc.getField().equals(fac))
|
||||||
|
builder.append(fc.getName()).append("<br>").append("<strong>==========</strong><br>");
|
||||||
|
builder.append("<strong>============================================================</strong>");
|
||||||
|
mainTextLabel.setText(builder.toString());
|
||||||
|
this.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void cancelEvent(ActionEvent evt) {
|
||||||
|
this.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
110
src/main/java/org/lumijiez/gui/forms/group/AddGroupForm.java
Normal file
110
src/main/java/org/lumijiez/gui/forms/group/AddGroupForm.java
Normal file
@@ -0,0 +1,110 @@
|
|||||||
|
package org.lumijiez.gui.forms.group;
|
||||||
|
|
||||||
|
import org.lumijiez.base.Faculty;
|
||||||
|
import org.lumijiez.base.Group;
|
||||||
|
import org.lumijiez.gui.util.ComboRenderer;
|
||||||
|
import org.lumijiez.gui.util.ComponentDecorator;
|
||||||
|
import org.lumijiez.gui.util.DisplayHandler;
|
||||||
|
import org.lumijiez.gui.util.WindowConfig;
|
||||||
|
import org.lumijiez.managers.Supervisor;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class AddGroupForm extends JFrame {
|
||||||
|
private final JLabel titleLabel = new JLabel();
|
||||||
|
private final JLabel nameLabel = new JLabel();
|
||||||
|
private final JLabel facultyLabel = new JLabel();
|
||||||
|
private final JButton submitButton = new JButton();
|
||||||
|
private final JButton cancelButton = new JButton();
|
||||||
|
private final JTextField nameField = new JTextField();
|
||||||
|
private final JComboBox<Faculty> facultyCombo = new JComboBox<>();
|
||||||
|
private final Supervisor sv;
|
||||||
|
|
||||||
|
public AddGroupForm(Supervisor sv) {
|
||||||
|
this.sv = sv;
|
||||||
|
initComponents();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initComponents() {
|
||||||
|
|
||||||
|
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||||
|
|
||||||
|
titleLabel.setFont(new Font("sansserif", Font.PLAIN, 18));
|
||||||
|
setTitle("Add a Group");
|
||||||
|
|
||||||
|
titleLabel.setText("Add a new group");
|
||||||
|
submitButton.setText("Submit");
|
||||||
|
cancelButton.setText("Cancel");
|
||||||
|
nameLabel.setText("Name:");
|
||||||
|
facultyLabel.setText("Faculty:");
|
||||||
|
|
||||||
|
ComponentDecorator.submitAndCancel(submitButton, cancelButton);
|
||||||
|
|
||||||
|
submitButton.addActionListener(this::submitEvent);
|
||||||
|
cancelButton.addActionListener(this::cancelEvent);
|
||||||
|
|
||||||
|
ComboRenderer.setRenderer(facultyCombo, sv.facultyManager().getFaculties().toArray(new Faculty[0]));
|
||||||
|
|
||||||
|
GroupLayout layout = new GroupLayout(getContentPane());
|
||||||
|
getContentPane().setLayout(layout);
|
||||||
|
layout.setHorizontalGroup(
|
||||||
|
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGap(21, 21, 21)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
|
||||||
|
.addComponent(nameField, GroupLayout.DEFAULT_SIZE, 178, Short.MAX_VALUE)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGap(5, 5, 5)
|
||||||
|
.addComponent(nameLabel))
|
||||||
|
.addComponent(facultyLabel)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addComponent(cancelButton)
|
||||||
|
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
|
.addComponent(submitButton))
|
||||||
|
.addComponent(facultyCombo, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGap(38, 38, 38)
|
||||||
|
.addComponent(titleLabel)))
|
||||||
|
.addContainerGap(29, Short.MAX_VALUE)));
|
||||||
|
layout.setVerticalGroup(
|
||||||
|
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addContainerGap()
|
||||||
|
.addComponent(titleLabel)
|
||||||
|
.addGap(13, 13, 13)
|
||||||
|
.addComponent(nameLabel)
|
||||||
|
.addGap(3, 3, 3)
|
||||||
|
.addComponent(nameField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
|
||||||
|
.addComponent(facultyLabel)
|
||||||
|
.addGap(5, 5, 5)
|
||||||
|
.addComponent(facultyCombo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 34, Short.MAX_VALUE)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||||
|
.addComponent(cancelButton)
|
||||||
|
.addComponent(submitButton))
|
||||||
|
.addGap(15, 15, 15)));
|
||||||
|
pack();
|
||||||
|
WindowConfig.center(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void submitEvent(ActionEvent evt) {
|
||||||
|
if (!nameField.getText().isEmpty()) {
|
||||||
|
Group gr = new Group(nameField.getText());
|
||||||
|
Faculty fac = ((Faculty) Objects.requireNonNull(facultyCombo.getSelectedItem()));
|
||||||
|
sv.addGroup(gr, fac);
|
||||||
|
DisplayHandler.displayGroups();
|
||||||
|
this.dispose();
|
||||||
|
} else JOptionPane.showMessageDialog(null, "Fill in all the fields!", "Warning!", JOptionPane.INFORMATION_MESSAGE, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void cancelEvent(ActionEvent evt) {
|
||||||
|
this.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,93 @@
|
|||||||
|
package org.lumijiez.gui.forms.group;
|
||||||
|
|
||||||
|
import org.lumijiez.base.Group;
|
||||||
|
import org.lumijiez.gui.util.ComboRenderer;
|
||||||
|
import org.lumijiez.gui.util.ComponentDecorator;
|
||||||
|
import org.lumijiez.gui.util.DisplayHandler;
|
||||||
|
import org.lumijiez.gui.util.WindowConfig;
|
||||||
|
import org.lumijiez.managers.Supervisor;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
|
||||||
|
public class DeleteGroupForm extends JFrame {
|
||||||
|
private final JLabel groupLabel = new JLabel();
|
||||||
|
private final JLabel titleLabel = new JLabel();
|
||||||
|
private final JButton cancelButton = new JButton();
|
||||||
|
private final JButton submitButton = new JButton();
|
||||||
|
private final JComboBox<Group> groupCombo = new JComboBox<>();
|
||||||
|
private final Supervisor sv;
|
||||||
|
|
||||||
|
public DeleteGroupForm(Supervisor sv) {
|
||||||
|
this.sv = sv;
|
||||||
|
initComponents();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initComponents() {
|
||||||
|
|
||||||
|
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||||
|
|
||||||
|
titleLabel.setFont(new Font("sansserif", Font.PLAIN, 18));
|
||||||
|
setTitle("Delete a Group");
|
||||||
|
|
||||||
|
titleLabel.setText("Delete a group");
|
||||||
|
submitButton.setText("Submit");
|
||||||
|
cancelButton.setText("Cancel");
|
||||||
|
groupLabel.setText("Group:");
|
||||||
|
|
||||||
|
ComponentDecorator.submitAndCancel(submitButton, cancelButton);
|
||||||
|
|
||||||
|
submitButton.addActionListener(this::submitEvent);
|
||||||
|
cancelButton.addActionListener(this::cancelEvent);
|
||||||
|
|
||||||
|
ComboRenderer.setRenderer(groupCombo, sv.groupManager().getGroups().toArray(new Group[0]));
|
||||||
|
|
||||||
|
GroupLayout layout = new GroupLayout(getContentPane());
|
||||||
|
getContentPane().setLayout(layout);
|
||||||
|
layout.setHorizontalGroup(
|
||||||
|
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGap(23, 23, 23)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addComponent(groupLabel)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.TRAILING, false)
|
||||||
|
.addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
|
||||||
|
.addComponent(cancelButton)
|
||||||
|
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
|
.addComponent(submitButton))
|
||||||
|
.addComponent(groupCombo, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 250, GroupLayout.PREFERRED_SIZE))))
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGap(54, 54, 54)
|
||||||
|
.addComponent(titleLabel)))
|
||||||
|
.addContainerGap(29, Short.MAX_VALUE)));
|
||||||
|
layout.setVerticalGroup(
|
||||||
|
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addContainerGap()
|
||||||
|
.addComponent(titleLabel)
|
||||||
|
.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
|
||||||
|
.addComponent(groupLabel)
|
||||||
|
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addComponent(groupCombo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addGap(18, 18, 18)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||||
|
.addComponent(cancelButton)
|
||||||
|
.addComponent(submitButton))
|
||||||
|
.addContainerGap(18, Short.MAX_VALUE)));
|
||||||
|
pack();
|
||||||
|
WindowConfig.center(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void submitEvent(ActionEvent evt) {
|
||||||
|
sv.deleteGroup(((Group) groupCombo.getSelectedItem()));
|
||||||
|
DisplayHandler.displayGroups();
|
||||||
|
this.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void cancelEvent(ActionEvent evt) {
|
||||||
|
this.dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
124
src/main/java/org/lumijiez/gui/forms/group/EditGroupForm.java
Normal file
124
src/main/java/org/lumijiez/gui/forms/group/EditGroupForm.java
Normal file
@@ -0,0 +1,124 @@
|
|||||||
|
package org.lumijiez.gui.forms.group;
|
||||||
|
|
||||||
|
import org.lumijiez.base.Faculty;
|
||||||
|
import org.lumijiez.base.Group;
|
||||||
|
import org.lumijiez.gui.util.ComboRenderer;
|
||||||
|
import org.lumijiez.gui.util.ComponentDecorator;
|
||||||
|
import org.lumijiez.gui.util.DisplayHandler;
|
||||||
|
import org.lumijiez.gui.util.WindowConfig;
|
||||||
|
import org.lumijiez.managers.Supervisor;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class EditGroupForm extends JFrame {
|
||||||
|
private final JLabel titleLabel = new JLabel();
|
||||||
|
private final JLabel facultyLabel = new JLabel();
|
||||||
|
private final JLabel groupLabel = new JLabel();
|
||||||
|
private final JLabel nameLabel = new JLabel();
|
||||||
|
private final JButton cancelButton = new JButton();
|
||||||
|
private final JButton submitButton = new JButton();
|
||||||
|
private final JTextField nameField = new JTextField();
|
||||||
|
private final JComboBox<Faculty> facultyCombo = new JComboBox<>();
|
||||||
|
private final JComboBox<Group> groupCombo = new JComboBox<>();
|
||||||
|
private final Supervisor sv;
|
||||||
|
|
||||||
|
public EditGroupForm(Supervisor sv) {
|
||||||
|
this.sv = sv;
|
||||||
|
initComponents();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initComponents() {
|
||||||
|
|
||||||
|
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||||
|
|
||||||
|
titleLabel.setFont(new Font("sansserif", Font.PLAIN, 18));
|
||||||
|
setTitle("Edit a Group");
|
||||||
|
|
||||||
|
titleLabel.setText("Edit a group");
|
||||||
|
submitButton.setText("Submit");
|
||||||
|
cancelButton.setText("Cancel");
|
||||||
|
nameLabel.setText("New name:");
|
||||||
|
groupLabel.setText("Group:");
|
||||||
|
facultyLabel.setText("Faculty:");
|
||||||
|
|
||||||
|
ComponentDecorator.submitAndCancel(submitButton, cancelButton);
|
||||||
|
|
||||||
|
submitButton.addActionListener(this::submitEvent);
|
||||||
|
cancelButton.addActionListener(this::cancelEvent);
|
||||||
|
|
||||||
|
ComboRenderer.setRenderer(facultyCombo, sv.facultyManager().getFaculties().toArray(new Faculty[0]));
|
||||||
|
ComboRenderer.setRenderer(groupCombo, sv.groupManager().getGroups().toArray(new Group[0]));
|
||||||
|
|
||||||
|
GroupLayout layout = new GroupLayout(getContentPane());
|
||||||
|
getContentPane().setLayout(layout);
|
||||||
|
layout.setHorizontalGroup(
|
||||||
|
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGap(25, 25, 25)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGap(129, 129, 129)
|
||||||
|
.addComponent(titleLabel))
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.TRAILING)
|
||||||
|
.addComponent(cancelButton)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addComponent(groupCombo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addComponent(groupLabel))
|
||||||
|
.addGap(34, 34, 34)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addComponent(nameField, GroupLayout.PREFERRED_SIZE, 178, GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addComponent(nameLabel))))
|
||||||
|
.addGap(27, 27, 27)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addComponent(facultyLabel)
|
||||||
|
.addComponent(facultyCombo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addComponent(submitButton))))
|
||||||
|
.addContainerGap(34, Short.MAX_VALUE)));
|
||||||
|
layout.setVerticalGroup(
|
||||||
|
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGap(7, 7, 7)
|
||||||
|
.addComponent(titleLabel)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGap(35, 35, 35)
|
||||||
|
.addComponent(facultyCombo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGap(15, 15, 15)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||||
|
.addComponent(nameLabel)
|
||||||
|
.addComponent(groupLabel)
|
||||||
|
.addComponent(facultyLabel))
|
||||||
|
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||||
|
.addComponent(nameField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addComponent(groupCombo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))))
|
||||||
|
.addGap(31, 31, 31)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||||
|
.addComponent(cancelButton)
|
||||||
|
.addComponent(submitButton))
|
||||||
|
.addContainerGap(36, Short.MAX_VALUE)));
|
||||||
|
pack();
|
||||||
|
WindowConfig.center(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void submitEvent(ActionEvent evt) {
|
||||||
|
Faculty fac = ((Faculty) Objects.requireNonNull(facultyCombo.getSelectedItem()));
|
||||||
|
Group gr = (Group) Objects.requireNonNull(groupCombo.getSelectedItem());
|
||||||
|
if (!nameField.getText().isEmpty()) {
|
||||||
|
sv.editGroup(gr, nameField.getText(), fac);
|
||||||
|
DisplayHandler.displayGroups();
|
||||||
|
this.dispose();
|
||||||
|
} else JOptionPane.showMessageDialog(null, "Fill in all the fields!", "Warning!", JOptionPane.INFORMATION_MESSAGE, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void cancelEvent(ActionEvent evt) {
|
||||||
|
this.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
105
src/main/java/org/lumijiez/gui/forms/group/ShowGroupForm.java
Normal file
105
src/main/java/org/lumijiez/gui/forms/group/ShowGroupForm.java
Normal file
@@ -0,0 +1,105 @@
|
|||||||
|
package org.lumijiez.gui.forms.group;
|
||||||
|
|
||||||
|
import org.lumijiez.base.Group;
|
||||||
|
import org.lumijiez.base.Student;
|
||||||
|
import org.lumijiez.gui.util.ComboRenderer;
|
||||||
|
import org.lumijiez.gui.util.ComponentDecorator;
|
||||||
|
import org.lumijiez.gui.util.Settings;
|
||||||
|
import org.lumijiez.gui.util.WindowConfig;
|
||||||
|
import org.lumijiez.managers.Supervisor;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
|
||||||
|
public class ShowGroupForm extends JFrame {
|
||||||
|
private final JLabel titleLabel = new JLabel();
|
||||||
|
private final JLabel groupLabel = new JLabel();
|
||||||
|
private final JButton cancelButton = new JButton();
|
||||||
|
private final JButton submitButton = new JButton();
|
||||||
|
private final JComboBox<Group> groupCombo = new JComboBox<>();
|
||||||
|
private final Supervisor sv;
|
||||||
|
private final JTextPane mainTextLabel;
|
||||||
|
|
||||||
|
public ShowGroupForm(Supervisor sv, JTextPane mainTextLabel) {
|
||||||
|
this.sv = sv;
|
||||||
|
this.mainTextLabel = mainTextLabel;
|
||||||
|
initComponents();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initComponents() {
|
||||||
|
|
||||||
|
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||||
|
|
||||||
|
titleLabel.setFont(new Font("sansserif", Font.PLAIN, 18));
|
||||||
|
setTitle("Show a Group");
|
||||||
|
|
||||||
|
titleLabel.setText("Show a group");
|
||||||
|
groupLabel.setText("Group:");
|
||||||
|
cancelButton.setText("Cancel");
|
||||||
|
submitButton.setText("Submit");
|
||||||
|
|
||||||
|
ComponentDecorator.submitAndCancel(submitButton, cancelButton);
|
||||||
|
|
||||||
|
submitButton.addActionListener(this::submitEvent);
|
||||||
|
cancelButton.addActionListener(this::cancelEvent);
|
||||||
|
|
||||||
|
ComboRenderer.setRenderer(groupCombo, sv.groupManager().getGroups().toArray(new Group[0]));
|
||||||
|
|
||||||
|
GroupLayout layout = new GroupLayout(getContentPane());
|
||||||
|
getContentPane().setLayout(layout);
|
||||||
|
layout.setHorizontalGroup(
|
||||||
|
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGap(25, 25, 25)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addComponent(groupLabel)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.TRAILING, false)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addComponent(cancelButton)
|
||||||
|
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
|
.addComponent(submitButton))
|
||||||
|
.addComponent(groupCombo, GroupLayout.PREFERRED_SIZE, 250, GroupLayout.PREFERRED_SIZE))))
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGap(47, 47, 47)
|
||||||
|
.addComponent(titleLabel)))
|
||||||
|
.addContainerGap(24, Short.MAX_VALUE)));
|
||||||
|
layout.setVerticalGroup(
|
||||||
|
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addContainerGap()
|
||||||
|
.addComponent(titleLabel)
|
||||||
|
.addGap(15, 15, 15)
|
||||||
|
.addComponent(groupLabel)
|
||||||
|
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addComponent(groupCombo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addGap(18, 18, 18)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||||
|
.addComponent(cancelButton)
|
||||||
|
.addComponent(submitButton))
|
||||||
|
.addContainerGap(25, Short.MAX_VALUE)));
|
||||||
|
pack();
|
||||||
|
WindowConfig.center(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void submitEvent(ActionEvent evt) {
|
||||||
|
StringBuilder text = new StringBuilder();
|
||||||
|
Group gr = (Group) Objects.requireNonNull(groupCombo.getSelectedItem());
|
||||||
|
text.append("<font size='").append(Settings.FontSize).append("'><strong>=================== Group:</strong> ").append(gr.getName()).append("<strong>=====================</strong><br>");
|
||||||
|
for (Student student : gr.getStudents())
|
||||||
|
text.append("<b>Name:</b> ").append(student.getName())
|
||||||
|
.append("<br><b>Email: </b>").append(student.getEmail())
|
||||||
|
.append("<br><b>Enrol date: </b>").append(student.getEnrollmentDate())
|
||||||
|
.append("<br><strong>===============================================</strong><br>");
|
||||||
|
mainTextLabel.setText(text.toString());
|
||||||
|
this.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void cancelEvent(ActionEvent evt) {
|
||||||
|
this.dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
283
src/main/java/org/lumijiez/gui/forms/student/AddStudentForm.java
Normal file
283
src/main/java/org/lumijiez/gui/forms/student/AddStudentForm.java
Normal file
@@ -0,0 +1,283 @@
|
|||||||
|
package org.lumijiez.gui.forms.student;
|
||||||
|
|
||||||
|
import org.lumijiez.base.Faculty;
|
||||||
|
import org.lumijiez.base.Group;
|
||||||
|
import org.lumijiez.gui.util.ComboRenderer;
|
||||||
|
import org.lumijiez.gui.util.ComponentDecorator;
|
||||||
|
import org.lumijiez.gui.util.DisplayHandler;
|
||||||
|
import org.lumijiez.gui.util.WindowConfig;
|
||||||
|
import org.lumijiez.managers.Supervisor;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class AddStudentForm extends JFrame {
|
||||||
|
private final JLabel titleLabel = new JLabel();
|
||||||
|
private final JLabel nameLabel = new JLabel();
|
||||||
|
private final JLabel surnameLabel = new JLabel();
|
||||||
|
private final JLabel emailLabel = new JLabel();
|
||||||
|
private final JLabel groupLabel = new JLabel();
|
||||||
|
private final JLabel facultyLabel = new JLabel();
|
||||||
|
private final JLabel birthYearLabel = new JLabel();
|
||||||
|
private final JLabel birthDayLabel = new JLabel();
|
||||||
|
private final JLabel birthMonthLabel = new JLabel();
|
||||||
|
private final JLabel enrolDayLabel = new JLabel();
|
||||||
|
private final JLabel enrolMonthLabel = new JLabel();
|
||||||
|
private final JLabel enrolYearLabel = new JLabel();
|
||||||
|
private final JButton submitButton = new JButton();
|
||||||
|
private final JButton cancelButton = new JButton();
|
||||||
|
private final JTextField nameField = new JTextField();
|
||||||
|
private final JTextField surnameField = new JTextField();
|
||||||
|
private final JTextField emailField = new JTextField();
|
||||||
|
private final JComboBox<Group> groupCombo = new JComboBox<>();
|
||||||
|
private final JComboBox<Faculty> facultyCombo = new JComboBox<>();
|
||||||
|
private final JComboBox<Integer> birthYearField = new JComboBox<>();
|
||||||
|
private final JComboBox<Integer> birthDayField = new JComboBox<>();
|
||||||
|
private final JComboBox<Integer> birthMonthField = new JComboBox<>();
|
||||||
|
private final JComboBox<Integer> enrolDayField = new JComboBox<>();
|
||||||
|
private final JComboBox<Integer> enrolMonthField = new JComboBox<>();
|
||||||
|
private final JComboBox<Integer> enrolYearField = new JComboBox<>();
|
||||||
|
private final Supervisor sv;
|
||||||
|
|
||||||
|
public AddStudentForm(Supervisor sv) {
|
||||||
|
this.sv = sv;
|
||||||
|
|
||||||
|
Integer[] days = new Integer[31];
|
||||||
|
for (int i = 0; i < 31; i++) {
|
||||||
|
days[i] = i + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
Integer[] months = new Integer[12];
|
||||||
|
for (int i = 0; i < 12; i++) {
|
||||||
|
months[i] = i + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
Integer[] years = new Integer[100];
|
||||||
|
for (int i = 0; i < 100; i++) {
|
||||||
|
years[i] = 1970 + i;
|
||||||
|
}
|
||||||
|
|
||||||
|
birthDayField.setModel(new DefaultComboBoxModel<>(days));
|
||||||
|
birthMonthField.setModel(new DefaultComboBoxModel<>(months));
|
||||||
|
birthYearField.setModel(new DefaultComboBoxModel<>(years));
|
||||||
|
|
||||||
|
enrolDayField.setModel(new DefaultComboBoxModel<>(days));
|
||||||
|
enrolMonthField.setModel(new DefaultComboBoxModel<>(months));
|
||||||
|
enrolYearField.setModel(new DefaultComboBoxModel<>(years));
|
||||||
|
|
||||||
|
initComponents();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void initComponents() {
|
||||||
|
|
||||||
|
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||||
|
|
||||||
|
titleLabel.setFont(new Font("sansserif", Font.PLAIN, 18));
|
||||||
|
setTitle("Add a Student");
|
||||||
|
|
||||||
|
titleLabel.setText("Add a new student");
|
||||||
|
submitButton.setText("Submit");
|
||||||
|
cancelButton.setText("Cancel");
|
||||||
|
nameLabel.setText("Name:");
|
||||||
|
surnameLabel.setText("Surname:");
|
||||||
|
emailLabel.setText("Email:");
|
||||||
|
groupLabel.setText("Group:");
|
||||||
|
facultyLabel.setText("Faculty:");
|
||||||
|
birthYearLabel.setText("Year of Birth:");
|
||||||
|
birthDayLabel.setText("Day of Birth:");
|
||||||
|
birthMonthLabel.setText("Month of Birth:");
|
||||||
|
enrolDayLabel.setText("Day of Enrollment:");
|
||||||
|
enrolMonthLabel.setText("Month of Enrollment:");
|
||||||
|
enrolYearLabel.setText("Year of Enrollment:");
|
||||||
|
|
||||||
|
ComponentDecorator.submitAndCancel(submitButton, cancelButton);
|
||||||
|
|
||||||
|
submitButton.addActionListener(this::submitEvent);
|
||||||
|
cancelButton.addActionListener(this::cancelEvent);
|
||||||
|
|
||||||
|
ComboRenderer.setRenderer(facultyCombo, sv.facultyManager().getFaculties().toArray(new Faculty[0]));
|
||||||
|
ComboRenderer.setRenderer(groupCombo, sv.groupManager().getGroups().toArray(new Group[0]));
|
||||||
|
|
||||||
|
GroupLayout layout = new GroupLayout(getContentPane());
|
||||||
|
getContentPane().setLayout(layout);
|
||||||
|
layout.setHorizontalGroup(
|
||||||
|
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGap(132, 132, 132)
|
||||||
|
.addComponent(titleLabel))
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGap(25, 25, 25)
|
||||||
|
.addComponent(surnameLabel)
|
||||||
|
.addGap(142, 142, 142)
|
||||||
|
.addComponent(emailLabel)))
|
||||||
|
.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGap(21, 21, 21)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
|
||||||
|
.addComponent(surnameField, GroupLayout.DEFAULT_SIZE, 184, Short.MAX_VALUE)
|
||||||
|
.addComponent(nameField)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGap(5, 5, 5)
|
||||||
|
.addComponent(nameLabel))
|
||||||
|
.addGroup(GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addComponent(birthDayField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addComponent(birthDayLabel))
|
||||||
|
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
|
||||||
|
.addComponent(birthMonthLabel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
|
.addComponent(birthMonthField))))
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||||
|
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
|
.addComponent(groupLabel)
|
||||||
|
.addGap(67, 67, 67)
|
||||||
|
.addComponent(facultyLabel)
|
||||||
|
.addGap(51, 51, 51))
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGap(18, 18, 18)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addComponent(groupCombo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addGap(34, 34, 34)
|
||||||
|
.addComponent(facultyCombo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
|
||||||
|
.addComponent(emailField, GroupLayout.PREFERRED_SIZE, 178, GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addComponent(cancelButton)
|
||||||
|
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
|
.addComponent(submitButton))))
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGap(32, 32, 32)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addComponent(birthYearLabel)
|
||||||
|
.addComponent(birthYearField, GroupLayout.PREFERRED_SIZE, 94, GroupLayout.PREFERRED_SIZE))))
|
||||||
|
.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
|
||||||
|
.addComponent(enrolDayLabel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
|
.addComponent(enrolDayField))
|
||||||
|
.addGap(29, 29, 29)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addComponent(enrolMonthLabel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
|
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED))
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addComponent(enrolMonthField, GroupLayout.DEFAULT_SIZE, 91, Short.MAX_VALUE)
|
||||||
|
.addGap(55, 55, 55)))
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addComponent(enrolYearField, GroupLayout.DEFAULT_SIZE, 91, Short.MAX_VALUE)
|
||||||
|
.addGap(43, 43, 43))
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addComponent(enrolYearLabel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
|
.addContainerGap()))))));
|
||||||
|
layout.setVerticalGroup(
|
||||||
|
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addContainerGap()
|
||||||
|
.addComponent(titleLabel)
|
||||||
|
.addGap(13, 13, 13)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||||
|
.addComponent(nameLabel)
|
||||||
|
.addComponent(groupLabel)
|
||||||
|
.addComponent(facultyLabel))
|
||||||
|
.addGap(3, 3, 3)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||||
|
.addComponent(nameField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addComponent(groupCombo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addComponent(facultyCombo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGap(11, 11, 11)
|
||||||
|
.addComponent(surnameLabel)
|
||||||
|
.addGap(5, 5, 5))
|
||||||
|
.addGroup(GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||||
|
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addComponent(emailLabel)
|
||||||
|
.addGap(4, 4, 4)))
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||||
|
.addComponent(surnameField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addComponent(emailField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
|
||||||
|
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 11, Short.MAX_VALUE)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||||
|
.addComponent(birthDayLabel)
|
||||||
|
.addComponent(birthMonthLabel)
|
||||||
|
.addComponent(birthYearLabel))
|
||||||
|
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||||
|
.addComponent(birthDayField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addComponent(birthMonthField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addComponent(birthYearField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
|
||||||
|
.addGap(18, 18, 18)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||||
|
.addComponent(enrolDayLabel)
|
||||||
|
.addComponent(enrolMonthLabel)
|
||||||
|
.addComponent(enrolYearLabel))
|
||||||
|
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||||
|
.addComponent(enrolDayField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addComponent(enrolMonthField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addComponent(enrolYearField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
|
||||||
|
.addGap(36, 36, 36)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||||
|
.addComponent(cancelButton)
|
||||||
|
.addComponent(submitButton))
|
||||||
|
.addGap(21, 21, 21)));
|
||||||
|
pack();
|
||||||
|
WindowConfig.center(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void cancelEvent(ActionEvent actionEvent) {
|
||||||
|
this.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void submitEvent(ActionEvent evt) {
|
||||||
|
String name = nameField.getText();
|
||||||
|
String surname = surnameField.getText();
|
||||||
|
String email = emailField.getText();
|
||||||
|
Group group = getSelectedGroup();
|
||||||
|
Faculty faculty = getSelectedFaculty();
|
||||||
|
Date birthDate = getDateFromFields(birthYearField, birthMonthField, birthDayField);
|
||||||
|
Date enrolDate = getDateFromFields(enrolYearField, enrolMonthField, enrolDayField);
|
||||||
|
|
||||||
|
if (!name.isEmpty() && !surname.isEmpty() && !email.isEmpty()) {
|
||||||
|
sv.addStudent(name, surname, email, group, faculty, birthDate, enrolDate);
|
||||||
|
DisplayHandler.displayStudents();
|
||||||
|
this.dispose();
|
||||||
|
} else JOptionPane.showMessageDialog(null, "Fill in all the fields!", "Warning!", JOptionPane.INFORMATION_MESSAGE, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Group getSelectedGroup() {
|
||||||
|
return (Group) Objects.requireNonNull(groupCombo.getSelectedItem());
|
||||||
|
}
|
||||||
|
|
||||||
|
private Faculty getSelectedFaculty() {
|
||||||
|
return (Faculty) Objects.requireNonNull(facultyCombo.getSelectedItem());
|
||||||
|
}
|
||||||
|
|
||||||
|
private Date getDateFromFields(JComboBox<Integer> yearField, JComboBox<Integer> monthField, JComboBox<Integer> dayField) {
|
||||||
|
int year = (Integer) Objects.requireNonNull(yearField.getSelectedItem());
|
||||||
|
int month = (Integer) Objects.requireNonNull(monthField.getSelectedItem()) - 1;
|
||||||
|
int day = (Integer) Objects.requireNonNull(dayField.getSelectedItem());
|
||||||
|
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
calendar.set(Calendar.YEAR, year);
|
||||||
|
calendar.set(Calendar.MONTH, month);
|
||||||
|
calendar.set(Calendar.DAY_OF_MONTH, day);
|
||||||
|
|
||||||
|
return calendar.getTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,95 @@
|
|||||||
|
package org.lumijiez.gui.forms.student;
|
||||||
|
|
||||||
|
import org.lumijiez.base.Student;
|
||||||
|
import org.lumijiez.gui.util.ComboRenderer;
|
||||||
|
import org.lumijiez.gui.util.ComponentDecorator;
|
||||||
|
import org.lumijiez.gui.util.DisplayHandler;
|
||||||
|
import org.lumijiez.gui.util.WindowConfig;
|
||||||
|
import org.lumijiez.managers.Supervisor;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class DeleteStudentForm extends JFrame {
|
||||||
|
private final JLabel titleLabel = new JLabel();
|
||||||
|
private final JLabel studentLabel = new JLabel();
|
||||||
|
private final JButton cancelButton = new JButton();
|
||||||
|
private final JButton submitButton = new JButton();
|
||||||
|
private final JComboBox<Student> studentCombo = new JComboBox<>();
|
||||||
|
private final Supervisor sv;
|
||||||
|
|
||||||
|
public DeleteStudentForm(Supervisor sv) {
|
||||||
|
this.sv = sv;
|
||||||
|
initComponents();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initComponents() {
|
||||||
|
|
||||||
|
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||||
|
|
||||||
|
titleLabel.setFont(new Font("sansserif", Font.PLAIN, 18));
|
||||||
|
setTitle("Delete a Student");
|
||||||
|
|
||||||
|
ComboRenderer.setRenderer(studentCombo, sv.studentManager().getStudents().toArray(new Student[0]));
|
||||||
|
|
||||||
|
ComponentDecorator.submitAndCancel(submitButton, cancelButton);
|
||||||
|
|
||||||
|
cancelButton.setText("Cancel");
|
||||||
|
titleLabel.setText("Delete Student");
|
||||||
|
submitButton.setText("Submit");
|
||||||
|
studentLabel.setText("Student:");
|
||||||
|
|
||||||
|
submitButton.addActionListener(this::submitEvent);
|
||||||
|
cancelButton.addActionListener(this::cancelEvent);
|
||||||
|
|
||||||
|
GroupLayout layout = new GroupLayout(getContentPane());
|
||||||
|
getContentPane().setLayout(layout);
|
||||||
|
layout.setHorizontalGroup(
|
||||||
|
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGap(21, 21, 21)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addComponent(cancelButton)
|
||||||
|
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
|
.addComponent(submitButton))
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGap(5, 5, 5)
|
||||||
|
.addComponent(studentLabel))
|
||||||
|
.addComponent(studentCombo, GroupLayout.PREFERRED_SIZE, 250, GroupLayout.PREFERRED_SIZE))
|
||||||
|
.addContainerGap(26, Short.MAX_VALUE))
|
||||||
|
.addGroup(GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||||
|
.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
|
.addComponent(titleLabel)
|
||||||
|
.addGap(51, 51, 51)));
|
||||||
|
layout.setVerticalGroup(
|
||||||
|
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGap(7, 7, 7)
|
||||||
|
.addComponent(titleLabel)
|
||||||
|
.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
|
||||||
|
.addComponent(studentLabel)
|
||||||
|
.addGap(3, 3, 3)
|
||||||
|
.addComponent(studentCombo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addGap(18, 18, 18)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||||
|
.addComponent(submitButton)
|
||||||
|
.addComponent(cancelButton))
|
||||||
|
.addContainerGap(26, Short.MAX_VALUE)));
|
||||||
|
pack();
|
||||||
|
WindowConfig.center(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void submitEvent(ActionEvent evt) {
|
||||||
|
Student student = ((Student) Objects.requireNonNull(studentCombo.getSelectedItem()));
|
||||||
|
sv.deleteStudent(student);
|
||||||
|
DisplayHandler.displayStudents();
|
||||||
|
this.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void cancelEvent(ActionEvent evt) {
|
||||||
|
this.dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,312 @@
|
|||||||
|
package org.lumijiez.gui.forms.student;
|
||||||
|
|
||||||
|
import org.lumijiez.base.Faculty;
|
||||||
|
import org.lumijiez.base.Group;
|
||||||
|
import org.lumijiez.base.Student;
|
||||||
|
import org.lumijiez.gui.util.ComboRenderer;
|
||||||
|
import org.lumijiez.gui.util.ComponentDecorator;
|
||||||
|
import org.lumijiez.gui.util.DisplayHandler;
|
||||||
|
import org.lumijiez.gui.util.WindowConfig;
|
||||||
|
import org.lumijiez.managers.Supervisor;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class EditStudentForm extends JFrame {
|
||||||
|
private final JLabel bdayLabel = new JLabel();
|
||||||
|
private final JLabel bmonthLabel = new JLabel();
|
||||||
|
private final JLabel byearLabel = new JLabel();
|
||||||
|
private final JLabel edayLabel = new JLabel();
|
||||||
|
private final JLabel emailLabel = new JLabel();
|
||||||
|
private final JLabel emonthLabel = new JLabel();
|
||||||
|
private final JLabel eyearLabel = new JLabel();
|
||||||
|
private final JLabel facultyLabel = new JLabel();
|
||||||
|
private final JLabel groupLabel = new JLabel();
|
||||||
|
private final JLabel nameLabel = new JLabel();
|
||||||
|
private final JLabel studentLabel = new JLabel();
|
||||||
|
private final JLabel surnameLabel = new JLabel();
|
||||||
|
private final JLabel titleLabel = new JLabel();
|
||||||
|
private final JButton cancelButton = new JButton();
|
||||||
|
private final JButton submitButton = new JButton();
|
||||||
|
private final JTextField nameField = new JTextField();
|
||||||
|
private final JTextField emailField = new JTextField();
|
||||||
|
private final JTextField surnameField = new JTextField();
|
||||||
|
private final JComboBox<Faculty> facultyCombo = new JComboBox<>();
|
||||||
|
private final JComboBox<Group> groupCombo = new JComboBox<>();
|
||||||
|
private final JComboBox<Student> studentCombo = new JComboBox<>();
|
||||||
|
private final JComboBox<Integer> birthdayCombo;
|
||||||
|
private final JComboBox<Integer> birthmonthCombo;
|
||||||
|
private final JComboBox<Integer> birthyearCombo;
|
||||||
|
private final JComboBox<Integer> enroldayCombo;
|
||||||
|
private final JComboBox<Integer> enrolmonthCombo;
|
||||||
|
private final JComboBox<Integer> enrolyearCombo;
|
||||||
|
private final Supervisor sv;
|
||||||
|
|
||||||
|
public EditStudentForm(Supervisor sv) {
|
||||||
|
this.sv = sv;
|
||||||
|
|
||||||
|
Integer[] days = new Integer[31];
|
||||||
|
for (int i = 0; i < 31; i++) {
|
||||||
|
days[i] = i + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
Integer[] months = new Integer[12];
|
||||||
|
for (int i = 0; i < 12; i++) {
|
||||||
|
months[i] = i + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
Integer[] years = new Integer[100];
|
||||||
|
for (int i = 0; i < 100; i++) {
|
||||||
|
years[i] = 1970 + i;
|
||||||
|
}
|
||||||
|
|
||||||
|
birthdayCombo = new JComboBox<>(days);
|
||||||
|
birthmonthCombo = new JComboBox<>(months);
|
||||||
|
birthyearCombo = new JComboBox<>(years);
|
||||||
|
enroldayCombo = new JComboBox<>(days);
|
||||||
|
enrolmonthCombo = new JComboBox<>(months);
|
||||||
|
enrolyearCombo = new JComboBox<>(years);
|
||||||
|
initComponents();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initComponents() {
|
||||||
|
|
||||||
|
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||||
|
|
||||||
|
titleLabel.setFont(new Font("sansserif", Font.PLAIN, 18));
|
||||||
|
setTitle("Edit a Student");
|
||||||
|
|
||||||
|
titleLabel.setText("Edit a student");
|
||||||
|
submitButton.setText("Submit");
|
||||||
|
surnameLabel.setText("New Surname:");
|
||||||
|
studentLabel.setText("Student:");
|
||||||
|
facultyLabel.setText("New faculty:");
|
||||||
|
groupLabel.setText("New Group:");
|
||||||
|
nameLabel.setText("New name:");
|
||||||
|
emailLabel.setText("New email:");
|
||||||
|
bdayLabel.setText("New birthday:");
|
||||||
|
bmonthLabel.setText("New birthmonth:");
|
||||||
|
byearLabel.setText("New birthyear:");
|
||||||
|
emonthLabel.setText("New enrol month:");
|
||||||
|
eyearLabel.setText("New enrol year:");
|
||||||
|
edayLabel.setText("New enrol day:");
|
||||||
|
cancelButton.setText("Cancel");
|
||||||
|
|
||||||
|
studentCombo.addActionListener(this::studentComboEvent);
|
||||||
|
submitButton.addActionListener(this::submitEvent);
|
||||||
|
cancelButton.addActionListener(this::cancelEvent);
|
||||||
|
|
||||||
|
ComponentDecorator.submitAndCancel(submitButton, cancelButton);
|
||||||
|
|
||||||
|
ComboRenderer.setRenderer(facultyCombo, sv.facultyManager().getFaculties().toArray(new Faculty[0]));
|
||||||
|
ComboRenderer.setRenderer(groupCombo, sv.groupManager().getGroups().toArray(new Group[0]));
|
||||||
|
ComboRenderer.setRenderer(studentCombo, sv.studentManager().getStudents().toArray(new Student[0]));
|
||||||
|
|
||||||
|
Student student = ((Student) Objects.requireNonNull(studentCombo.getSelectedItem()));
|
||||||
|
facultyCombo.setSelectedItem(student.getFaculty());
|
||||||
|
groupCombo.setSelectedItem(student.getGroup());
|
||||||
|
emailField.setText(student.getEmail());
|
||||||
|
nameField.setText(student.getName());
|
||||||
|
surnameField.setText(student.getSurname());
|
||||||
|
|
||||||
|
Calendar birthCalendar = Calendar.getInstance();
|
||||||
|
Calendar enrolCalendar = Calendar.getInstance();
|
||||||
|
|
||||||
|
birthCalendar.setTime(student.getDateOfBirth());
|
||||||
|
enrolCalendar.setTime(student.getEnrollmentDate());
|
||||||
|
|
||||||
|
birthdayCombo.setSelectedItem(birthCalendar.get(Calendar.DAY_OF_MONTH));
|
||||||
|
birthmonthCombo.setSelectedItem(birthCalendar.get(Calendar.MONTH) + 1);
|
||||||
|
birthyearCombo.setSelectedItem(birthCalendar.get(Calendar.YEAR));
|
||||||
|
|
||||||
|
enroldayCombo.setSelectedItem(enrolCalendar.get(Calendar.DAY_OF_MONTH));
|
||||||
|
enrolmonthCombo.setSelectedItem(enrolCalendar.get(Calendar.MONTH) + 1);
|
||||||
|
enrolyearCombo.setSelectedItem(enrolCalendar.get(Calendar.YEAR));
|
||||||
|
|
||||||
|
GroupLayout layout = new GroupLayout(getContentPane());
|
||||||
|
getContentPane().setLayout(layout);
|
||||||
|
layout.setHorizontalGroup(
|
||||||
|
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGap(25, 25, 25)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addComponent(enroldayCombo, GroupLayout.PREFERRED_SIZE, 115, GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addComponent(edayLabel))
|
||||||
|
.addGap(33, 33, 33)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addComponent(emonthLabel)
|
||||||
|
.addComponent(enrolmonthCombo, GroupLayout.PREFERRED_SIZE, 115, GroupLayout.PREFERRED_SIZE))
|
||||||
|
.addGap(40, 40, 40)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addComponent(enrolyearCombo, GroupLayout.PREFERRED_SIZE, 115, GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addComponent(eyearLabel)))
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addComponent(nameField, GroupLayout.PREFERRED_SIZE, 115, GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addComponent(nameLabel)
|
||||||
|
.addComponent(groupLabel)
|
||||||
|
.addComponent(groupCombo, GroupLayout.PREFERRED_SIZE, 115, GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addComponent(birthdayCombo, GroupLayout.PREFERRED_SIZE, 115, GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addComponent(bdayLabel)
|
||||||
|
.addComponent(studentLabel))
|
||||||
|
.addGap(33, 33, 33)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addComponent(titleLabel)
|
||||||
|
.addComponent(surnameLabel)
|
||||||
|
.addComponent(surnameField, GroupLayout.PREFERRED_SIZE, 115, GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addComponent(facultyLabel)
|
||||||
|
.addComponent(facultyCombo, GroupLayout.PREFERRED_SIZE, 115, GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addComponent(bmonthLabel)
|
||||||
|
.addComponent(birthmonthCombo, GroupLayout.PREFERRED_SIZE, 115, GroupLayout.PREFERRED_SIZE))
|
||||||
|
.addGap(40, 40, 40))
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addComponent(studentCombo, GroupLayout.PREFERRED_SIZE, 151, GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addGap(16, 16, 16)))
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addComponent(birthyearCombo, GroupLayout.PREFERRED_SIZE, 115, GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addComponent(byearLabel)
|
||||||
|
.addComponent(emailField, GroupLayout.PREFERRED_SIZE, 115, GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addComponent(emailLabel)))
|
||||||
|
.addGroup(GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||||
|
.addComponent(cancelButton)
|
||||||
|
.addGap(34, 34, 34)
|
||||||
|
.addComponent(submitButton)))
|
||||||
|
.addContainerGap(27, Short.MAX_VALUE)));
|
||||||
|
layout.setVerticalGroup(
|
||||||
|
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGap(36, 36, 36)
|
||||||
|
.addComponent(studentLabel))
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGap(14, 14, 14)
|
||||||
|
.addComponent(titleLabel)))
|
||||||
|
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addComponent(studentCombo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addGap(18, 18, 18)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||||
|
.addComponent(surnameLabel)
|
||||||
|
.addComponent(nameLabel)
|
||||||
|
.addComponent(emailLabel))
|
||||||
|
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||||
|
.addComponent(nameField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addComponent(surnameField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addComponent(emailField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
|
||||||
|
.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||||
|
.addComponent(groupLabel)
|
||||||
|
.addComponent(facultyLabel))
|
||||||
|
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||||
|
.addComponent(groupCombo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addComponent(facultyCombo, GroupLayout.PREFERRED_SIZE, 22, GroupLayout.PREFERRED_SIZE))
|
||||||
|
.addGap(7, 7, 7)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.TRAILING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.TRAILING)
|
||||||
|
.addComponent(bdayLabel)
|
||||||
|
.addComponent(bmonthLabel))
|
||||||
|
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||||
|
.addComponent(birthdayCombo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addComponent(birthmonthCombo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addComponent(byearLabel)
|
||||||
|
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addComponent(birthyearCombo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))
|
||||||
|
.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.TRAILING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.TRAILING)
|
||||||
|
.addComponent(edayLabel)
|
||||||
|
.addComponent(emonthLabel))
|
||||||
|
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||||
|
.addComponent(enroldayCombo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addComponent(enrolmonthCombo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addComponent(eyearLabel)
|
||||||
|
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addComponent(enrolyearCombo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))
|
||||||
|
.addGap(35, 35, 35)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||||
|
.addComponent(submitButton)
|
||||||
|
.addComponent(cancelButton))
|
||||||
|
.addContainerGap(25, Short.MAX_VALUE)));
|
||||||
|
pack();
|
||||||
|
WindowConfig.center(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void cancelEvent(ActionEvent actionEvent) {
|
||||||
|
this.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void submitEvent(ActionEvent evt) {
|
||||||
|
String name = nameField.getText();
|
||||||
|
String surname = surnameField.getText();
|
||||||
|
String email = emailField.getText();
|
||||||
|
Group group = (Group) Objects.requireNonNull(groupCombo.getSelectedItem());
|
||||||
|
Faculty faculty = ((Faculty) Objects.requireNonNull(facultyCombo.getSelectedItem()));
|
||||||
|
Student student = ((Student) Objects.requireNonNull(studentCombo.getSelectedItem()));
|
||||||
|
int birthYear = (Integer) Objects.requireNonNull(birthyearCombo.getSelectedItem());
|
||||||
|
int birthMonth = (Integer) Objects.requireNonNull(birthmonthCombo.getSelectedItem());
|
||||||
|
int birthDay = (Integer) Objects.requireNonNull(birthdayCombo.getSelectedItem());
|
||||||
|
int enrolYear = (Integer) Objects.requireNonNull(enrolyearCombo.getSelectedItem());
|
||||||
|
int enrolMonth = (Integer) Objects.requireNonNull(enrolmonthCombo.getSelectedItem());
|
||||||
|
int enrolDay = (Integer) Objects.requireNonNull(enroldayCombo.getSelectedItem());
|
||||||
|
|
||||||
|
Calendar birthCalendar = Calendar.getInstance();
|
||||||
|
Calendar enrolCalendar = Calendar.getInstance();
|
||||||
|
|
||||||
|
birthCalendar.set(Calendar.YEAR, birthYear);
|
||||||
|
birthCalendar.set(Calendar.MONTH, birthMonth - 1);
|
||||||
|
birthCalendar.set(Calendar.DAY_OF_MONTH, birthDay);
|
||||||
|
|
||||||
|
enrolCalendar.set(Calendar.YEAR, enrolYear);
|
||||||
|
enrolCalendar.set(Calendar.MONTH, enrolMonth - 1);
|
||||||
|
enrolCalendar.set(Calendar.DAY_OF_MONTH, enrolDay);
|
||||||
|
|
||||||
|
Date birthDate = birthCalendar.getTime();
|
||||||
|
Date enrolDate = enrolCalendar.getTime();
|
||||||
|
|
||||||
|
if (!name.isEmpty() && !surname.isEmpty() && !email.isEmpty())
|
||||||
|
sv.editStudent(student, name, surname, email, group, faculty, birthDate, enrolDate);
|
||||||
|
|
||||||
|
DisplayHandler.displayStudents();
|
||||||
|
this.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void studentComboEvent(ActionEvent evt) {
|
||||||
|
Student student = ((Student) Objects.requireNonNull(studentCombo.getSelectedItem()));
|
||||||
|
facultyCombo.setSelectedItem(student.getFaculty());
|
||||||
|
groupCombo.setSelectedItem(student.getGroup());
|
||||||
|
emailField.setText(student.getEmail());
|
||||||
|
nameField.setText(student.getName());
|
||||||
|
surnameField.setText(student.getSurname());
|
||||||
|
|
||||||
|
Calendar birthCalendar = Calendar.getInstance();
|
||||||
|
Calendar enrolCalendar = Calendar.getInstance();
|
||||||
|
|
||||||
|
birthCalendar.setTime(student.getDateOfBirth());
|
||||||
|
enrolCalendar.setTime(student.getEnrollmentDate());
|
||||||
|
|
||||||
|
birthdayCombo.setSelectedItem(birthCalendar.get(Calendar.DAY_OF_MONTH));
|
||||||
|
birthmonthCombo.setSelectedItem(birthCalendar.get(Calendar.MONTH) + 1);
|
||||||
|
birthyearCombo.setSelectedItem(birthCalendar.get(Calendar.YEAR));
|
||||||
|
|
||||||
|
enroldayCombo.setSelectedItem(enrolCalendar.get(Calendar.DAY_OF_MONTH));
|
||||||
|
enrolmonthCombo.setSelectedItem(enrolCalendar.get(Calendar.MONTH) + 1);
|
||||||
|
enrolyearCombo.setSelectedItem(enrolCalendar.get(Calendar.YEAR));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,137 @@
|
|||||||
|
package org.lumijiez.gui.forms.student;
|
||||||
|
|
||||||
|
import org.lumijiez.base.Grade;
|
||||||
|
import org.lumijiez.base.Student;
|
||||||
|
import org.lumijiez.enums.Subjects;
|
||||||
|
import org.lumijiez.gui.util.ComboRenderer;
|
||||||
|
import org.lumijiez.gui.util.ComponentDecorator;
|
||||||
|
import org.lumijiez.gui.util.Settings;
|
||||||
|
import org.lumijiez.gui.util.WindowConfig;
|
||||||
|
import org.lumijiez.managers.Supervisor;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class GradeStudentForm extends JFrame {
|
||||||
|
Integer[] grades = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
|
||||||
|
private final JLabel gradeLabel = new JLabel();
|
||||||
|
private final JLabel studentLabel = new JLabel();
|
||||||
|
private final JLabel subjectLabel = new JLabel();
|
||||||
|
private final JLabel titleLabel = new JLabel();
|
||||||
|
private final JButton cancelButton = new JButton();
|
||||||
|
private final JButton submitButton = new JButton();
|
||||||
|
private final JComboBox<Subjects> subjectCombo = new JComboBox<>();
|
||||||
|
private final JComboBox<Student> studentCombo = new JComboBox<>();
|
||||||
|
private final JComboBox<Integer> gradeCombo = new JComboBox<>(grades);
|
||||||
|
private final Supervisor sv;
|
||||||
|
private final JTextPane mainTextLabel;
|
||||||
|
|
||||||
|
public GradeStudentForm(Supervisor sv, JTextPane mainTextLabel) {
|
||||||
|
this.sv = sv;
|
||||||
|
this.mainTextLabel = mainTextLabel;
|
||||||
|
initComponents();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initComponents() {
|
||||||
|
|
||||||
|
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||||
|
|
||||||
|
titleLabel.setFont(new Font("sansserif", Font.PLAIN, 18));
|
||||||
|
setTitle("Grade A Student");
|
||||||
|
|
||||||
|
titleLabel.setText("Grade a student");
|
||||||
|
studentLabel.setText("Student:");
|
||||||
|
subjectLabel.setText("Subject:");
|
||||||
|
submitButton.setText("Submit");
|
||||||
|
gradeLabel.setText("Grade:");
|
||||||
|
cancelButton.setText("Cancel");
|
||||||
|
|
||||||
|
ComponentDecorator.submitAndCancel(submitButton, cancelButton);
|
||||||
|
|
||||||
|
submitButton.addActionListener(this::submitEvent);
|
||||||
|
cancelButton.addActionListener(this::cancelEvent);
|
||||||
|
|
||||||
|
ComboRenderer.setRenderer(subjectCombo, Subjects.values());
|
||||||
|
ComboRenderer.setRenderer(studentCombo, sv.studentManager().getStudents().toArray(new Student[0]));
|
||||||
|
|
||||||
|
GroupLayout layout = new GroupLayout(getContentPane());
|
||||||
|
getContentPane().setLayout(layout);
|
||||||
|
layout.setHorizontalGroup(
|
||||||
|
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGap(25, 25, 25)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addComponent(gradeLabel)
|
||||||
|
.addContainerGap())
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addComponent(studentCombo, GroupLayout.PREFERRED_SIZE, 147, GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addComponent(studentLabel)
|
||||||
|
.addComponent(gradeCombo, GroupLayout.PREFERRED_SIZE, 147, GroupLayout.PREFERRED_SIZE))
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 37, Short.MAX_VALUE)
|
||||||
|
.addComponent(subjectLabel)
|
||||||
|
.addGap(148, 148, 148))
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addComponent(cancelButton)
|
||||||
|
.addGap(18, 18, 18)
|
||||||
|
.addComponent(submitButton))
|
||||||
|
.addComponent(subjectCombo, GroupLayout.PREFERRED_SIZE, 160, GroupLayout.PREFERRED_SIZE))
|
||||||
|
.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))))
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGap(129, 129, 129)
|
||||||
|
.addComponent(titleLabel)
|
||||||
|
.addGap(0, 0, Short.MAX_VALUE)));
|
||||||
|
layout.setVerticalGroup(
|
||||||
|
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGap(7, 7, 7)
|
||||||
|
.addComponent(titleLabel)
|
||||||
|
.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||||
|
.addComponent(subjectLabel)
|
||||||
|
.addComponent(studentLabel))
|
||||||
|
.addGap(3, 3, 3)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||||
|
.addComponent(studentCombo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addComponent(subjectCombo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
|
||||||
|
.addGap(18, 18, 18)
|
||||||
|
.addComponent(gradeLabel)
|
||||||
|
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||||
|
.addComponent(gradeCombo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addComponent(cancelButton)
|
||||||
|
.addComponent(submitButton))
|
||||||
|
.addContainerGap(30, Short.MAX_VALUE)));
|
||||||
|
pack();
|
||||||
|
WindowConfig.center(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void submitEvent(ActionEvent evt) {
|
||||||
|
Student student = ((Student) Objects.requireNonNull(studentCombo.getSelectedItem()));
|
||||||
|
Subjects subject = Subjects.getEnum(Objects.requireNonNull(subjectCombo.getSelectedItem()).toString());
|
||||||
|
int intGrade = (Integer) Objects.requireNonNull(gradeCombo.getSelectedItem());
|
||||||
|
Grade grade = new Grade(subject, intGrade);
|
||||||
|
sv.addGrade(student, grade);
|
||||||
|
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
builder.append("<font size='").append(Settings.FontSize).append("'><strong>============================================================</strong><br>");
|
||||||
|
builder.append("<b>Grades for </b>").append(student.getFullname()).append(" <b>from</b> ").append(student.getGroup().getName()).append(":<br>");
|
||||||
|
for (Grade gr : student.getGrades()) builder.append(gr.getSubject()).append(": ").append(gr.getGrade()).append("<br>");
|
||||||
|
builder.append("<strong>============================================================</strong><br>");
|
||||||
|
mainTextLabel.setText(builder.toString());
|
||||||
|
this.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void cancelEvent(ActionEvent evt) {
|
||||||
|
this.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,95 @@
|
|||||||
|
package org.lumijiez.gui.forms.student;
|
||||||
|
|
||||||
|
import org.lumijiez.base.Student;
|
||||||
|
import org.lumijiez.gui.util.ComboRenderer;
|
||||||
|
import org.lumijiez.gui.util.ComponentDecorator;
|
||||||
|
import org.lumijiez.gui.util.DisplayHandler;
|
||||||
|
import org.lumijiez.gui.util.WindowConfig;
|
||||||
|
import org.lumijiez.managers.Supervisor;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class GraduateStudentForm extends JFrame {
|
||||||
|
private final JLabel studentLabel = new JLabel();
|
||||||
|
private final JLabel titleLabel = new JLabel();
|
||||||
|
private final JButton cancelButton = new JButton();
|
||||||
|
private final JButton submitButton = new JButton();
|
||||||
|
private final JComboBox<Student> studentCombo = new JComboBox<>();
|
||||||
|
private final Supervisor sv;
|
||||||
|
|
||||||
|
public GraduateStudentForm(Supervisor sv) {
|
||||||
|
this.sv = sv;
|
||||||
|
initComponents();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initComponents() {
|
||||||
|
|
||||||
|
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||||
|
|
||||||
|
titleLabel.setFont(new Font("sansserif", Font.PLAIN, 18));
|
||||||
|
setTitle("Graduate a Student");
|
||||||
|
|
||||||
|
ComboRenderer.setRenderer(studentCombo, sv.studentManager().getEnrolled().toArray(new Student[0]));
|
||||||
|
|
||||||
|
ComponentDecorator.submitAndCancel(submitButton, cancelButton);
|
||||||
|
|
||||||
|
submitButton.setText("Submit");
|
||||||
|
cancelButton.setText("Cancel");
|
||||||
|
titleLabel.setText("Graduate a Student");
|
||||||
|
studentLabel.setText("Student:");
|
||||||
|
|
||||||
|
submitButton.addActionListener(this::cancelEvent);
|
||||||
|
cancelButton.addActionListener(this::submitEvent);
|
||||||
|
|
||||||
|
GroupLayout layout = new GroupLayout(getContentPane());
|
||||||
|
getContentPane().setLayout(layout);
|
||||||
|
layout.setHorizontalGroup(
|
||||||
|
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGap(21, 21, 21)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addComponent(cancelButton)
|
||||||
|
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
|
.addComponent(submitButton))
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGap(5, 5, 5)
|
||||||
|
.addComponent(studentLabel))
|
||||||
|
.addComponent(studentCombo, GroupLayout.PREFERRED_SIZE, 250, GroupLayout.PREFERRED_SIZE))
|
||||||
|
.addContainerGap(26, Short.MAX_VALUE))
|
||||||
|
.addGroup(GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||||
|
.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
|
.addComponent(titleLabel)
|
||||||
|
.addGap(51, 51, 51)));
|
||||||
|
layout.setVerticalGroup(
|
||||||
|
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGap(7, 7, 7)
|
||||||
|
.addComponent(titleLabel)
|
||||||
|
.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
|
||||||
|
.addComponent(studentLabel)
|
||||||
|
.addGap(3, 3, 3)
|
||||||
|
.addComponent(studentCombo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addGap(18, 18, 18)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||||
|
.addComponent(submitButton)
|
||||||
|
.addComponent(cancelButton))
|
||||||
|
.addContainerGap(26, Short.MAX_VALUE)));
|
||||||
|
pack();
|
||||||
|
WindowConfig.center(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void cancelEvent(ActionEvent evt) {
|
||||||
|
Student student = ((Student) Objects.requireNonNull(studentCombo.getSelectedItem()));
|
||||||
|
student.setGraduated(true);
|
||||||
|
DisplayHandler.displayStudents();
|
||||||
|
this.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void submitEvent(ActionEvent evt) {
|
||||||
|
this.dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,111 @@
|
|||||||
|
package org.lumijiez.gui.forms.student;
|
||||||
|
|
||||||
|
import org.lumijiez.base.Student;
|
||||||
|
import org.lumijiez.gui.util.ComboRenderer;
|
||||||
|
import org.lumijiez.gui.util.ComponentDecorator;
|
||||||
|
import org.lumijiez.gui.util.Settings;
|
||||||
|
import org.lumijiez.gui.util.WindowConfig;
|
||||||
|
import org.lumijiez.managers.Supervisor;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class ShowStudentForm extends JFrame {
|
||||||
|
private final JLabel studentLabel = new JLabel();
|
||||||
|
private final JLabel titleLabel = new JLabel();
|
||||||
|
private final JButton cancelButton = new JButton();
|
||||||
|
private final JButton submitButton = new JButton();
|
||||||
|
private final JComboBox<Student> studentCombo = new JComboBox<>();
|
||||||
|
private final Supervisor sv;
|
||||||
|
private final JTextPane mainTextLabel;
|
||||||
|
|
||||||
|
public ShowStudentForm(Supervisor sv, JTextPane mainTextLabel) {
|
||||||
|
this.sv = sv;
|
||||||
|
this.mainTextLabel = mainTextLabel;
|
||||||
|
initComponents();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initComponents() {
|
||||||
|
|
||||||
|
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||||
|
|
||||||
|
titleLabel.setFont(new Font("sansserif", Font.PLAIN, 18));
|
||||||
|
setTitle("Show A Student");
|
||||||
|
|
||||||
|
titleLabel.setText("Show Student");
|
||||||
|
submitButton.setText("Submit");
|
||||||
|
studentLabel.setText("Student:");
|
||||||
|
cancelButton.setText("Cancel");
|
||||||
|
|
||||||
|
ComponentDecorator.submitAndCancel(submitButton, cancelButton);
|
||||||
|
|
||||||
|
ComboRenderer.setRenderer(studentCombo, sv.studentManager().getStudents().toArray(new Student[0]));
|
||||||
|
|
||||||
|
cancelButton.addActionListener(this::cancelEvent);
|
||||||
|
submitButton.addActionListener(this::submitEvent);
|
||||||
|
|
||||||
|
GroupLayout layout = new GroupLayout(getContentPane());
|
||||||
|
getContentPane().setLayout(layout);
|
||||||
|
layout.setHorizontalGroup(
|
||||||
|
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGap(21, 21, 21)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGap(5, 5, 5)
|
||||||
|
.addComponent(studentLabel))
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.TRAILING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addComponent(cancelButton)
|
||||||
|
.addGap(34, 34, 34)
|
||||||
|
.addComponent(submitButton))
|
||||||
|
.addComponent(studentCombo, GroupLayout.PREFERRED_SIZE, 250, GroupLayout.PREFERRED_SIZE))))
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGap(52, 52, 52)
|
||||||
|
.addComponent(titleLabel)))
|
||||||
|
.addContainerGap(23, Short.MAX_VALUE)));
|
||||||
|
layout.setVerticalGroup(
|
||||||
|
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addContainerGap()
|
||||||
|
.addComponent(titleLabel)
|
||||||
|
.addGap(13, 13, 13)
|
||||||
|
.addComponent(studentLabel)
|
||||||
|
.addGap(3, 3, 3)
|
||||||
|
.addComponent(studentCombo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addGap(18, 18, 18)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||||
|
.addComponent(cancelButton)
|
||||||
|
.addComponent(submitButton))
|
||||||
|
.addContainerGap(22, Short.MAX_VALUE)));
|
||||||
|
pack();
|
||||||
|
WindowConfig.center(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void submitEvent(ActionEvent evt) {
|
||||||
|
Student student = ((Student) Objects.requireNonNull(studentCombo.getSelectedItem()));
|
||||||
|
StringBuilder text = new StringBuilder();
|
||||||
|
|
||||||
|
text.append("<font size='").append(Settings.FontSize).append("'><strong>====================== Student Info ======================</strong><br>");
|
||||||
|
mainTextLabel.setText(text.toString());
|
||||||
|
text.append("<b>Name: </b>").append(student.getFullname()).append(" <br>")
|
||||||
|
.append("<b>Group:</b> ").append(student.getGroup().getName())
|
||||||
|
.append(" <br><b>Faculty:</b> ").append(student.getFaculty().getName())
|
||||||
|
.append(" <br><b>Email:</b> ").append(student.getEmail())
|
||||||
|
.append(" <br><b>Bday:</b> ").append(student.getDateOfBirth())
|
||||||
|
.append(" <br><b>Enrol date:</b> ").append(student.getEnrollmentDate())
|
||||||
|
.append(" <br><b>Graduated:</b> ").append(student.isGraduated() ? "<b color='green'>Yes</b>" : "<b color='red'>No</b>");
|
||||||
|
text.append("<br>=======================================================");
|
||||||
|
mainTextLabel.setText(text.toString());
|
||||||
|
this.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void cancelEvent(ActionEvent evt) {
|
||||||
|
this.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,106 @@
|
|||||||
|
package org.lumijiez.gui.forms.student;
|
||||||
|
|
||||||
|
import org.lumijiez.base.Grade;
|
||||||
|
import org.lumijiez.base.Student;
|
||||||
|
import org.lumijiez.gui.util.ComboRenderer;
|
||||||
|
import org.lumijiez.gui.util.ComponentDecorator;
|
||||||
|
import org.lumijiez.gui.util.Settings;
|
||||||
|
import org.lumijiez.gui.util.WindowConfig;
|
||||||
|
import org.lumijiez.managers.Supervisor;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class ShowStudentGradesForm extends JFrame {
|
||||||
|
private final JLabel studentLabel = new JLabel();
|
||||||
|
private final JLabel titleLabel = new JLabel();
|
||||||
|
private final JButton cancelButton = new JButton();
|
||||||
|
private final JButton submitButton = new JButton();
|
||||||
|
private final JComboBox<Student> studentCombo = new JComboBox<>();
|
||||||
|
private final Supervisor sv;
|
||||||
|
private final JTextPane mainTextLabel;
|
||||||
|
|
||||||
|
public ShowStudentGradesForm(Supervisor sv, JTextPane mainTextLabel) {
|
||||||
|
this.sv = sv;
|
||||||
|
this.mainTextLabel = mainTextLabel;
|
||||||
|
initComponents();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initComponents() {
|
||||||
|
|
||||||
|
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||||
|
|
||||||
|
titleLabel.setFont(new Font("sansserif", Font.PLAIN, 18));
|
||||||
|
setTitle("Show Student Grades");
|
||||||
|
|
||||||
|
titleLabel.setText("Show Grades");
|
||||||
|
studentLabel.setText("Student:");
|
||||||
|
submitButton.setText("Submit");
|
||||||
|
cancelButton.setText("Cancel");
|
||||||
|
|
||||||
|
ComponentDecorator.submitAndCancel(submitButton, cancelButton);
|
||||||
|
|
||||||
|
ComboRenderer.setRenderer(studentCombo, sv.studentManager().getStudents().toArray(new Student[0]));
|
||||||
|
|
||||||
|
cancelButton.addActionListener(this::cancelEvent);
|
||||||
|
submitButton.addActionListener(this::submitEvent);
|
||||||
|
|
||||||
|
GroupLayout layout = new GroupLayout(getContentPane());
|
||||||
|
getContentPane().setLayout(layout);
|
||||||
|
layout.setHorizontalGroup(
|
||||||
|
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGap(21, 21, 21)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGap(5, 5, 5)
|
||||||
|
.addComponent(studentLabel))
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.TRAILING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addComponent(cancelButton)
|
||||||
|
.addGap(34, 34, 34)
|
||||||
|
.addComponent(submitButton))
|
||||||
|
.addComponent(studentCombo, GroupLayout.PREFERRED_SIZE, 250, GroupLayout.PREFERRED_SIZE))))
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGap(50, 50, 50)
|
||||||
|
.addComponent(titleLabel)))
|
||||||
|
.addContainerGap(30, Short.MAX_VALUE)));
|
||||||
|
layout.setVerticalGroup(
|
||||||
|
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGap(7, 7, 7)
|
||||||
|
.addComponent(titleLabel)
|
||||||
|
.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
|
||||||
|
.addComponent(studentLabel)
|
||||||
|
.addGap(3, 3, 3)
|
||||||
|
.addComponent(studentCombo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addGap(18, 18, 18)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||||
|
.addComponent(cancelButton)
|
||||||
|
.addComponent(submitButton))
|
||||||
|
.addContainerGap(22, Short.MAX_VALUE)));
|
||||||
|
pack();
|
||||||
|
WindowConfig.center(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void submitEvent(ActionEvent evt) {
|
||||||
|
Student student = ((Student) Objects.requireNonNull(studentCombo.getSelectedItem()));
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
builder.append("<font size='").append(Settings.FontSize).append("'><strong>============================================================</strong><br>");
|
||||||
|
builder.append("<b>Grades for </b>").append(student.getFullname()).append(" <b>from</b> ").append(student.getGroup().getName()).append(":<br>");
|
||||||
|
for (Grade grade : student.getGrades())
|
||||||
|
builder.append(grade.getSubject()).append(": ").append(grade.getGrade()).append("<br>");
|
||||||
|
builder.append("<strong>============================================================<strong><br>");
|
||||||
|
mainTextLabel.setText(builder.toString());
|
||||||
|
this.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void cancelEvent(ActionEvent evt) {
|
||||||
|
this.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
171
src/main/java/org/lumijiez/gui/loader/BatchGraduater.java
Normal file
171
src/main/java/org/lumijiez/gui/loader/BatchGraduater.java
Normal file
@@ -0,0 +1,171 @@
|
|||||||
|
package org.lumijiez.gui.loader;
|
||||||
|
|
||||||
|
import org.lumijiez.base.Faculty;
|
||||||
|
import org.lumijiez.base.Group;
|
||||||
|
import org.lumijiez.base.Student;
|
||||||
|
import org.lumijiez.enums.StudyField;
|
||||||
|
import org.lumijiez.gui.util.ComponentDecorator;
|
||||||
|
import org.lumijiez.gui.util.DisplayHandler;
|
||||||
|
import org.lumijiez.gui.util.WindowConfig;
|
||||||
|
import org.lumijiez.managers.Supervisor;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.FileReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class BatchGraduater extends JFrame {
|
||||||
|
private final Supervisor sv;
|
||||||
|
private final JButton submitButton = new JButton();
|
||||||
|
private final JLabel titleLabel = new JLabel();
|
||||||
|
private final JButton browseButton = new JButton();
|
||||||
|
private final JLabel formatLabel = new JLabel();
|
||||||
|
private final JScrollPane exampleLabel = new JScrollPane();
|
||||||
|
private final JTextArea exampleText = new JTextArea();
|
||||||
|
private final JButton cancelButton = new JButton();
|
||||||
|
private final JTextPane filePane = new JTextPane();
|
||||||
|
|
||||||
|
public BatchGraduater(Supervisor sv) {
|
||||||
|
this.sv = sv;
|
||||||
|
initComponents();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initComponents() {
|
||||||
|
|
||||||
|
titleLabel.setFont(new Font("Segoe UI", Font.PLAIN, 24));
|
||||||
|
setTitle("Graduate a Batch of Students");
|
||||||
|
|
||||||
|
submitButton.addActionListener(this::submitEvent);
|
||||||
|
cancelButton.addActionListener(this::cancelEvent);
|
||||||
|
browseButton.addActionListener(this::browseEvent);
|
||||||
|
|
||||||
|
ComponentDecorator.submitAndCancel(submitButton, cancelButton);
|
||||||
|
|
||||||
|
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||||
|
|
||||||
|
titleLabel.setText("Pick a file to graduate a batch");
|
||||||
|
submitButton.setText("Submit");
|
||||||
|
browseButton.setText("Browse");
|
||||||
|
formatLabel.setText("File format example:");
|
||||||
|
cancelButton.setText("Cancel");
|
||||||
|
|
||||||
|
exampleText.setColumns(15);
|
||||||
|
exampleText.setRows(5);
|
||||||
|
exampleText.setEditable(false);
|
||||||
|
exampleText.setText("name: John\nsurname: Doe\nemail: john.doe@example.com\ngroup: FAF-223\nfaculty: FCIM\nspecialty: Mechanical Engineering");
|
||||||
|
exampleLabel.setViewportView(exampleText);
|
||||||
|
|
||||||
|
GroupLayout layout = new GroupLayout(getContentPane());
|
||||||
|
getContentPane().setLayout(layout);
|
||||||
|
layout.setHorizontalGroup(
|
||||||
|
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGap(25, 25, 25)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addComponent(filePane, GroupLayout.PREFERRED_SIZE, 215, GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addGap(18, 18, 18)
|
||||||
|
.addComponent(browseButton))
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGap(104, 104, 104)
|
||||||
|
.addComponent(cancelButton)
|
||||||
|
.addGap(18, 18, 18)
|
||||||
|
.addComponent(submitButton))
|
||||||
|
.addComponent(formatLabel)
|
||||||
|
.addComponent(exampleLabel, GroupLayout.PREFERRED_SIZE, 307, GroupLayout.PREFERRED_SIZE))
|
||||||
|
.addContainerGap(33, Short.MAX_VALUE))
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGap(41, 41, 41)
|
||||||
|
.addComponent(titleLabel)
|
||||||
|
.addGap(0, 0, Short.MAX_VALUE)));
|
||||||
|
layout.setVerticalGroup(
|
||||||
|
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGap(15, 15, 15)
|
||||||
|
.addComponent(titleLabel)
|
||||||
|
.addGap(7, 7, 7)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addComponent(filePane, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addComponent(browseButton))
|
||||||
|
.addGap(18, 18, 18)
|
||||||
|
.addComponent(formatLabel)
|
||||||
|
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addComponent(exampleLabel, GroupLayout.PREFERRED_SIZE, 208, GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 23, Short.MAX_VALUE)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||||
|
.addComponent(cancelButton)
|
||||||
|
.addComponent(submitButton))
|
||||||
|
.addGap(23, 23, 23)));
|
||||||
|
pack();
|
||||||
|
WindowConfig.center(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void cancelEvent(ActionEvent evt) {
|
||||||
|
this.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void browseEvent(ActionEvent evt) {
|
||||||
|
JFileChooser fileChooser = new JFileChooser();
|
||||||
|
int returnVal = fileChooser.showOpenDialog(this);
|
||||||
|
if (returnVal == JFileChooser.APPROVE_OPTION) {
|
||||||
|
java.io.File file = fileChooser.getSelectedFile();
|
||||||
|
filePane.setText(file.getAbsolutePath());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void submitEvent(ActionEvent evt) {
|
||||||
|
try (BufferedReader reader = new BufferedReader(new FileReader(filePane.getText()))) {
|
||||||
|
String line, name = "", surname = "", email = "", groupName = "", facultyName = "";
|
||||||
|
|
||||||
|
while ((line = reader.readLine()) != null) {
|
||||||
|
if (line.isEmpty()) continue;
|
||||||
|
|
||||||
|
String[] parts = line.split(": ", 2);
|
||||||
|
if (parts.length != 2) continue;
|
||||||
|
|
||||||
|
String field = parts[0], value = parts[1];
|
||||||
|
|
||||||
|
switch (field) {
|
||||||
|
case "name" -> name = value;
|
||||||
|
case "surname" -> surname = value;
|
||||||
|
case "email" -> email = value;
|
||||||
|
case "group" -> groupName = value;
|
||||||
|
case "faculty" -> facultyName = value;
|
||||||
|
case "specialty" -> handleStudentGraduation(name, surname, email, groupName, facultyName, value);
|
||||||
|
default -> System.err.println("Error reading file!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (IOException ex) {
|
||||||
|
throw new RuntimeException(ex);
|
||||||
|
}
|
||||||
|
DisplayHandler.displayStudents();
|
||||||
|
|
||||||
|
this.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleStudentGraduation(String name, String surname, String email, String groupName, String facultyName, String fieldName) {
|
||||||
|
StudyField specialty = (StudyField.getEnum(fieldName) == null) ? StudyField.DEFAULT_UNASSIGNED : StudyField.getEnum(fieldName);
|
||||||
|
|
||||||
|
Faculty faculty = sv.getFacultyByName(facultyName);
|
||||||
|
if (faculty == null) {
|
||||||
|
assert specialty != null;
|
||||||
|
faculty = new Faculty(facultyName, specialty.getAbbreviation(), specialty);
|
||||||
|
sv.addFaculty(faculty);
|
||||||
|
}
|
||||||
|
|
||||||
|
Group group = sv.getGroupByName(groupName, faculty);
|
||||||
|
if (group == null) {
|
||||||
|
group = new Group(groupName);
|
||||||
|
sv.addGroup(group, faculty);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Student st : group.getStudents()) {
|
||||||
|
if (st.getName().equals(name) && st.getSurname().equals(surname) && st.getEmail().equals(email)) {
|
||||||
|
st.setGraduated(true);
|
||||||
|
sv.getLogger().logOperation("Graduated student: " + st.getFullname() + " " + st.getGroup().getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
172
src/main/java/org/lumijiez/gui/loader/BatchLoader.java
Normal file
172
src/main/java/org/lumijiez/gui/loader/BatchLoader.java
Normal file
@@ -0,0 +1,172 @@
|
|||||||
|
package org.lumijiez.gui.loader;
|
||||||
|
|
||||||
|
import org.lumijiez.base.Faculty;
|
||||||
|
import org.lumijiez.base.Group;
|
||||||
|
import org.lumijiez.enums.StudyField;
|
||||||
|
import org.lumijiez.gui.util.ComponentDecorator;
|
||||||
|
import org.lumijiez.gui.util.DisplayHandler;
|
||||||
|
import org.lumijiez.gui.util.WindowConfig;
|
||||||
|
import org.lumijiez.managers.Supervisor;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.FileReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
public class BatchLoader extends JFrame {
|
||||||
|
private final Supervisor sv;
|
||||||
|
private final JButton submitButton = new JButton();
|
||||||
|
private final JLabel titleLabel = new JLabel();
|
||||||
|
private final JButton browseButton = new JButton();
|
||||||
|
private final JLabel formatLabel = new JLabel();
|
||||||
|
private final JScrollPane exampleLabel = new JScrollPane();
|
||||||
|
private final JTextArea exampleText = new JTextArea();
|
||||||
|
private final JButton cancelButton = new JButton();
|
||||||
|
private final JTextPane filePane = new JTextPane();
|
||||||
|
|
||||||
|
public BatchLoader(Supervisor sv) {
|
||||||
|
this.sv = sv;
|
||||||
|
initComponents();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initComponents() {
|
||||||
|
|
||||||
|
titleLabel.setFont(new java.awt.Font("Segoe UI", Font.PLAIN, 24));
|
||||||
|
setTitle("Load a Batch of Students");
|
||||||
|
|
||||||
|
submitButton.addActionListener(this::submitEvent);
|
||||||
|
cancelButton.addActionListener(this::cancelEvent);
|
||||||
|
browseButton.addActionListener(this::browseEvent);
|
||||||
|
|
||||||
|
ComponentDecorator.submitAndCancel(submitButton, cancelButton);
|
||||||
|
|
||||||
|
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||||
|
|
||||||
|
titleLabel.setText("Pick a file to load a batch");
|
||||||
|
submitButton.setText("Submit");
|
||||||
|
browseButton.setText("Browse");
|
||||||
|
formatLabel.setText("File format example:");
|
||||||
|
cancelButton.setText("Cancel");
|
||||||
|
|
||||||
|
exampleText.setColumns(15);
|
||||||
|
exampleText.setRows(5);
|
||||||
|
exampleText.setEditable(false);
|
||||||
|
exampleText.setText("name: John\nsurname: Doe\nemail: john.doe@example.com\ngroup: FAF-223\nfaculty: FCIM\nbirthdate: 1998-05-15\nenroldate: 2017-09-01\nspecialty: Mechanical Engineering");
|
||||||
|
exampleLabel.setViewportView(exampleText);
|
||||||
|
|
||||||
|
GroupLayout layout = new GroupLayout(getContentPane());
|
||||||
|
getContentPane().setLayout(layout);
|
||||||
|
layout.setHorizontalGroup(
|
||||||
|
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGap(25, 25, 25)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addComponent(filePane, GroupLayout.PREFERRED_SIZE, 215, GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addGap(18, 18, 18)
|
||||||
|
.addComponent(browseButton))
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGap(104, 104, 104)
|
||||||
|
.addComponent(cancelButton)
|
||||||
|
.addGap(18, 18, 18)
|
||||||
|
.addComponent(submitButton))
|
||||||
|
.addComponent(formatLabel)
|
||||||
|
.addComponent(exampleLabel, GroupLayout.PREFERRED_SIZE, 307, GroupLayout.PREFERRED_SIZE))
|
||||||
|
.addContainerGap(33, Short.MAX_VALUE))
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGap(41, 41, 41)
|
||||||
|
.addComponent(titleLabel)
|
||||||
|
.addGap(0, 0, Short.MAX_VALUE)));
|
||||||
|
layout.setVerticalGroup(
|
||||||
|
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGap(15, 15, 15)
|
||||||
|
.addComponent(titleLabel)
|
||||||
|
.addGap(7, 7, 7)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addComponent(filePane, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addComponent(browseButton))
|
||||||
|
.addGap(18, 18, 18)
|
||||||
|
.addComponent(formatLabel)
|
||||||
|
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addComponent(exampleLabel, GroupLayout.PREFERRED_SIZE, 208, GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 23, Short.MAX_VALUE)
|
||||||
|
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||||
|
.addComponent(cancelButton)
|
||||||
|
.addComponent(submitButton))
|
||||||
|
.addGap(23, 23, 23)));
|
||||||
|
pack();
|
||||||
|
WindowConfig.center(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void cancelEvent(ActionEvent evt) {
|
||||||
|
this.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void browseEvent(ActionEvent evt) {
|
||||||
|
JFileChooser fileChooser = new JFileChooser();
|
||||||
|
int returnVal = fileChooser.showOpenDialog(this);
|
||||||
|
if (returnVal == JFileChooser.APPROVE_OPTION) {
|
||||||
|
java.io.File file = fileChooser.getSelectedFile();
|
||||||
|
filePane.setText(file.getAbsolutePath());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void submitEvent(ActionEvent evt) {
|
||||||
|
try (BufferedReader reader = new BufferedReader(new FileReader(filePane.getText()))) {
|
||||||
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
String line, name = "", surname = "", email = "", groupName = "", facultyName = "";
|
||||||
|
Date birth = new Date(), enrol = new Date();
|
||||||
|
|
||||||
|
while ((line = reader.readLine()) != null) {
|
||||||
|
if (line.isEmpty()) continue;
|
||||||
|
|
||||||
|
String[] parts = line.split(": ", 2);
|
||||||
|
if (parts.length != 2) continue;
|
||||||
|
|
||||||
|
String field = parts[0], value = parts[1];
|
||||||
|
|
||||||
|
switch (field) {
|
||||||
|
case "name" -> name = value;
|
||||||
|
case "surname" -> surname = value;
|
||||||
|
case "email" -> email = value;
|
||||||
|
case "group" -> groupName = value;
|
||||||
|
case "faculty" -> facultyName = value;
|
||||||
|
case "birthdate" -> birth = dateFormat.parse(value);
|
||||||
|
case "enroldate" -> enrol = dateFormat.parse(value);
|
||||||
|
case "specialty" -> handleStudentAddition(name, surname, email, groupName, facultyName, birth, enrol, value);
|
||||||
|
default -> System.err.println("Error reading file!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (IOException | ParseException ex) {
|
||||||
|
throw new RuntimeException(ex);
|
||||||
|
}
|
||||||
|
DisplayHandler.displayStudents();
|
||||||
|
|
||||||
|
this.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleStudentAddition(String name, String surname, String email, String groupName, String facultyName, Date birth, Date enrol, String fieldName) {
|
||||||
|
StudyField specialty = (StudyField.getEnum(fieldName) == null) ? StudyField.DEFAULT_UNASSIGNED : StudyField.getEnum(fieldName);
|
||||||
|
|
||||||
|
Faculty faculty = sv.getFacultyByName(facultyName);
|
||||||
|
if (faculty == null) {
|
||||||
|
assert specialty != null;
|
||||||
|
faculty = new Faculty(facultyName, specialty.getAbbreviation(), specialty);
|
||||||
|
sv.addFaculty(faculty);
|
||||||
|
}
|
||||||
|
|
||||||
|
Group group = sv.getGroupByName(groupName, faculty);
|
||||||
|
if (group == null) {
|
||||||
|
group = new Group(groupName);
|
||||||
|
sv.addGroup(group, faculty);
|
||||||
|
}
|
||||||
|
|
||||||
|
sv.addStudent(name, surname, email, group, faculty, birth, enrol);
|
||||||
|
}
|
||||||
|
}
|
||||||
21
src/main/java/org/lumijiez/gui/util/ComboRenderer.java
Normal file
21
src/main/java/org/lumijiez/gui/util/ComboRenderer.java
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
package org.lumijiez.gui.util;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
|
// Generic function that takes a ComboBox with a <T> object and sets the DefaultListCellRenderer according to the object
|
||||||
|
public class ComboRenderer {
|
||||||
|
public static <T> void setRenderer(JComboBox<T> comboBox, T[] items) {
|
||||||
|
comboBox.setModel(new DefaultComboBoxModel<>(items));
|
||||||
|
comboBox.setRenderer(new DefaultListCellRenderer() {
|
||||||
|
@Override
|
||||||
|
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||||
|
if (value != null) {
|
||||||
|
setText(value.toString());
|
||||||
|
}
|
||||||
|
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
10
src/main/java/org/lumijiez/gui/util/ComponentDecorator.java
Normal file
10
src/main/java/org/lumijiez/gui/util/ComponentDecorator.java
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
package org.lumijiez.gui.util;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
|
||||||
|
public class ComponentDecorator {
|
||||||
|
public static void submitAndCancel(JButton buttonSubmit, JButton buttonCancel) {
|
||||||
|
buttonSubmit.setBackground(new java.awt.Color(204, 255, 204));
|
||||||
|
buttonCancel.setBackground(new java.awt.Color(255, 204, 204));
|
||||||
|
}
|
||||||
|
}
|
||||||
66
src/main/java/org/lumijiez/gui/util/DisplayHandler.java
Normal file
66
src/main/java/org/lumijiez/gui/util/DisplayHandler.java
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
package org.lumijiez.gui.util;
|
||||||
|
|
||||||
|
import org.lumijiez.base.Faculty;
|
||||||
|
import org.lumijiez.base.Group;
|
||||||
|
import org.lumijiez.base.Student;
|
||||||
|
import org.lumijiez.gui.StudentManagementGUI;
|
||||||
|
|
||||||
|
public class DisplayHandler {
|
||||||
|
public static void displayStudents() {
|
||||||
|
StringBuilder text = new StringBuilder();
|
||||||
|
text.append("<font size='").append(Settings.FontSize).append("'><strong>======================== Students ==========================</strong><br>");
|
||||||
|
for (Student student : StudentManagementGUI.getSv().studentManager().getStudents())
|
||||||
|
text.append("<b>Name: </b>").append(student.getFullname())
|
||||||
|
.append("<br><b>Group: </b>").append(student.getGroup().getName())
|
||||||
|
.append("<br><b>Email: </b>").append(student.getEmail())
|
||||||
|
.append("<br><b>Graduated: </b>").append((student.isGraduated() ? "<b color='green'>Yes</b>" : "<b color='red'>No</b>"))
|
||||||
|
.append("<br><strong>===============================================</strong><br>");
|
||||||
|
StudentManagementGUI.getMainPane().setText(text.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void displayGroups() {
|
||||||
|
StringBuilder text = new StringBuilder();
|
||||||
|
text.append("<font size='").append(Settings.FontSize).append("'><strong>========================= Groups ===========================</strong><br>");
|
||||||
|
for (Group group : StudentManagementGUI.getSv().groupManager().getGroups())
|
||||||
|
text.append("<b>Name: </b>").append(group.getName())
|
||||||
|
.append("<br><b>Faculty: </b>").append(group.getFaculty().getName())
|
||||||
|
.append("<br><b>Number of students: </b>").append(group.getStudents().size())
|
||||||
|
.append("<br><strong>===============================================</strong><br>");
|
||||||
|
StudentManagementGUI.getMainPane().setText(text.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void displayFaculties() {
|
||||||
|
StringBuilder text = new StringBuilder();
|
||||||
|
text.append("<font size='").append(Settings.FontSize).append("'><strong>======================= Faculties =========================</strong><br>");
|
||||||
|
for (Faculty fac : StudentManagementGUI.getSv().facultyManager().getFaculties())
|
||||||
|
text.append("<b>Name: </b>").append(fac.getName()).append("<br> <b>Specialty: </b>").append(fac.getField().getName())
|
||||||
|
.append("<br><b>Abbreviation:</b> ").append(fac.getAbbreviation())
|
||||||
|
.append("<br><b>Number of groups: </b>").append(fac.getGroups().size())
|
||||||
|
.append("<br><strong>===============================================</strong><br>");
|
||||||
|
StudentManagementGUI.getMainPane().setText(text.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void displayGraduates() {
|
||||||
|
StringBuilder text = new StringBuilder();
|
||||||
|
text.append("<font size='").append(Settings.FontSize).append("'><strong>======================== Students ==========================</strong<br>");
|
||||||
|
for (Student st : StudentManagementGUI.getSv().studentManager().getStudents())
|
||||||
|
if (st.isGraduated())
|
||||||
|
text.append("<b>Name: </b>").append(st.getFullname())
|
||||||
|
.append("<br><b>Group: </b>").append(st.getGroup().getName())
|
||||||
|
.append("<br><b>Graduated: </b>").append("<b color='green'>Yes</b>")
|
||||||
|
.append("<br>===============================================<br>");
|
||||||
|
StudentManagementGUI.getMainPane().setText(text.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void displayEnrolled() {
|
||||||
|
StringBuilder text = new StringBuilder();
|
||||||
|
text.append("<font size='").append(Settings.FontSize).append("'><strong>======================== Students ==========================</strong><br>");
|
||||||
|
for (Student st : StudentManagementGUI.getSv().studentManager().getStudents())
|
||||||
|
if (!st.isGraduated())
|
||||||
|
text.append("<b>Name: </b>").append(st.getFullname())
|
||||||
|
.append("<br><b>Group: </b>").append(st.getGroup().getName())
|
||||||
|
.append("<br><b>Graduated: </b>").append("<b color='red'>No</b>")
|
||||||
|
.append("<br><strong>===============================================</strong><br>");
|
||||||
|
StudentManagementGUI.getMainPane().setText(text.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
5
src/main/java/org/lumijiez/gui/util/Settings.java
Normal file
5
src/main/java/org/lumijiez/gui/util/Settings.java
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
package org.lumijiez.gui.util;
|
||||||
|
|
||||||
|
public class Settings {
|
||||||
|
public static int FontSize = 5;
|
||||||
|
}
|
||||||
13
src/main/java/org/lumijiez/gui/util/WindowConfig.java
Normal file
13
src/main/java/org/lumijiez/gui/util/WindowConfig.java
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
package org.lumijiez.gui.util;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
|
public class WindowConfig {
|
||||||
|
public static <T extends JFrame> void center(T frame) {
|
||||||
|
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
|
||||||
|
int x = (screenSize.width - frame.getWidth()) / 2;
|
||||||
|
int y = (screenSize.height - frame.getHeight()) / 2;
|
||||||
|
frame.setLocation(x, y);
|
||||||
|
}
|
||||||
|
}
|
||||||
32
src/main/java/org/lumijiez/managers/FacultyManager.java
Normal file
32
src/main/java/org/lumijiez/managers/FacultyManager.java
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
package org.lumijiez.managers;
|
||||||
|
|
||||||
|
import org.lumijiez.base.Faculty;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class FacultyManager implements Serializable {
|
||||||
|
|
||||||
|
private final StudentManager sm = new StudentManager();
|
||||||
|
|
||||||
|
private final GroupManager gm = new GroupManager(sm);
|
||||||
|
|
||||||
|
private final List<Faculty> faculties = new ArrayList<>();
|
||||||
|
|
||||||
|
public GroupManager getGm() {
|
||||||
|
return gm;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addFaculty(Faculty faculty) {
|
||||||
|
faculties.add(faculty);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteFaculty(Faculty faculty) {
|
||||||
|
faculties.remove(faculty);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Faculty> getFaculties() {
|
||||||
|
return faculties;
|
||||||
|
}
|
||||||
|
}
|
||||||
34
src/main/java/org/lumijiez/managers/GroupManager.java
Normal file
34
src/main/java/org/lumijiez/managers/GroupManager.java
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
package org.lumijiez.managers;
|
||||||
|
|
||||||
|
import org.lumijiez.base.Group;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class GroupManager implements Serializable {
|
||||||
|
|
||||||
|
public GroupManager(StudentManager sm) {
|
||||||
|
this.sm = sm;
|
||||||
|
}
|
||||||
|
|
||||||
|
private final StudentManager sm;
|
||||||
|
|
||||||
|
private final List<Group> groups = new ArrayList<>();
|
||||||
|
|
||||||
|
public void addGroup(Group group) {
|
||||||
|
groups.add(group);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteGroup(Group group) {
|
||||||
|
groups.remove(group);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Group> getGroups() {
|
||||||
|
return groups;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StudentManager getSm() {
|
||||||
|
return sm;
|
||||||
|
}
|
||||||
|
}
|
||||||
56
src/main/java/org/lumijiez/managers/LogManager.java
Normal file
56
src/main/java/org/lumijiez/managers/LogManager.java
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
package org.lumijiez.managers;
|
||||||
|
|
||||||
|
import java.io.BufferedWriter;
|
||||||
|
import java.io.FileWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
public class LogManager implements Serializable {
|
||||||
|
|
||||||
|
// Has to be transient since it is not serializable
|
||||||
|
private transient BufferedWriter writer;
|
||||||
|
|
||||||
|
// Initializes the writer object with a file that matches the exact date of application launch time.
|
||||||
|
// Doing it to keep easier track of logging files.
|
||||||
|
private void init() {
|
||||||
|
BufferedWriter writerTemp;
|
||||||
|
LocalDateTime currentDateTime = LocalDateTime.now();
|
||||||
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd-HH-mm-ss");
|
||||||
|
String fileHandle = "log-" + currentDateTime.format(formatter) + ".txt";
|
||||||
|
try {
|
||||||
|
FileWriter fwriter = new FileWriter(fileHandle);
|
||||||
|
writerTemp = new BufferedWriter(fwriter);
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.out.println(Arrays.toString(e.getStackTrace()));
|
||||||
|
writerTemp = null;
|
||||||
|
}
|
||||||
|
this.writer = writerTemp;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Logs an operation, also adds the current time to it.
|
||||||
|
// Inits the writer if it's not initialized already.
|
||||||
|
public void logOperation(String msg) {
|
||||||
|
if (writer == null) init();
|
||||||
|
LocalDateTime currentDateTime = LocalDateTime.now();
|
||||||
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss | ");
|
||||||
|
try {
|
||||||
|
writer.write(currentDateTime.format(formatter) + msg);
|
||||||
|
writer.flush();
|
||||||
|
writer.newLine();
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.out.println(Arrays.toString(e.getStackTrace()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Closes the file.
|
||||||
|
public void close() {
|
||||||
|
try {
|
||||||
|
this.writer.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
44
src/main/java/org/lumijiez/managers/StudentManager.java
Normal file
44
src/main/java/org/lumijiez/managers/StudentManager.java
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
package org.lumijiez.managers;
|
||||||
|
|
||||||
|
import org.lumijiez.base.Student;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class StudentManager implements Serializable {
|
||||||
|
private final List<Student> students = new ArrayList<>();
|
||||||
|
|
||||||
|
public void addStudent(Student student) {
|
||||||
|
student.getGroup().addStudent(student);
|
||||||
|
students.add(student);
|
||||||
|
}
|
||||||
|
public List<Student> getStudents() {
|
||||||
|
return students;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteStudent(Student student) {
|
||||||
|
students.remove(student);
|
||||||
|
}
|
||||||
|
|
||||||
|
// public List<Student> getGraduates() {
|
||||||
|
// List<Student> stList = new ArrayList<>();
|
||||||
|
// for (Student st : students) {
|
||||||
|
// if (st.isGraduated()) {
|
||||||
|
// stList.add(st);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return stList;
|
||||||
|
// }
|
||||||
|
|
||||||
|
public List<Student> getEnrolled() {
|
||||||
|
List<Student> stList = new ArrayList<>();
|
||||||
|
for (Student st : students) {
|
||||||
|
if (!st.isGraduated()) {
|
||||||
|
stList.add(st);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return stList;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
141
src/main/java/org/lumijiez/managers/Supervisor.java
Normal file
141
src/main/java/org/lumijiez/managers/Supervisor.java
Normal file
@@ -0,0 +1,141 @@
|
|||||||
|
package org.lumijiez.managers;
|
||||||
|
|
||||||
|
import org.lumijiez.base.Faculty;
|
||||||
|
import org.lumijiez.base.Grade;
|
||||||
|
import org.lumijiez.base.Group;
|
||||||
|
import org.lumijiez.base.Student;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
// Supervisor class handles all managers, and all operations regarding any data
|
||||||
|
public class Supervisor implements Serializable {
|
||||||
|
|
||||||
|
private final FacultyManager fm;
|
||||||
|
|
||||||
|
private final LogManager logger;
|
||||||
|
|
||||||
|
public Supervisor() {
|
||||||
|
this.fm = new FacultyManager();
|
||||||
|
this.logger = new LogManager();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Adds a faculty using the FacultyManager
|
||||||
|
public void addFaculty(Faculty faculty) {
|
||||||
|
facultyManager().addFaculty(faculty);
|
||||||
|
logger.logOperation("Faculty added: " + faculty.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deletes a faculty, then deletes all students and groups from the faculty
|
||||||
|
public void deleteFaculty(Faculty faculty) {
|
||||||
|
fm.deleteFaculty(faculty);
|
||||||
|
for (Group gr : faculty.getGroups()) {
|
||||||
|
groupManager().deleteGroup(gr);
|
||||||
|
for (Student st : gr.getStudents()) {
|
||||||
|
studentManager().deleteStudent(st);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
logger.logOperation("Faculty deleted : " + faculty.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Adds a grade, self-explanatory
|
||||||
|
public void addGrade(Student student, Grade grade) {
|
||||||
|
student.addGrade(grade);
|
||||||
|
logger.logOperation("Student graded: " + student.getName() + " " + grade.getSubject().getName() + " " + grade.getGrade());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Edits a group, also normalizes data to keep track of all bi-directional references
|
||||||
|
// due to all my base classes containing two-way references to each other.
|
||||||
|
// For example every Student class holds a reference to the Group and Faculty he is in.
|
||||||
|
// I did that to keep easier track of objects.
|
||||||
|
public void editGroup(Group group, String name, Faculty faculty) {
|
||||||
|
group.setName(name);
|
||||||
|
Faculty oldFac = group.getFaculty();
|
||||||
|
group.setFaculty(faculty);
|
||||||
|
faculty.addGroup(group);
|
||||||
|
oldFac.getGroups().remove(group);
|
||||||
|
logger.logOperation("Group edited: " + group.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deletes a group, then deletes the students.
|
||||||
|
public void deleteGroup(Group group) {
|
||||||
|
groupManager().deleteGroup(group);
|
||||||
|
for (Student st : group.getStudents()) {
|
||||||
|
studentManager().deleteStudent(st);
|
||||||
|
}
|
||||||
|
logger.logOperation("Group deleted: " + group.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Adds a student, using the StudentManager
|
||||||
|
public void addStudent(String name, String surname, String email, Group group, Faculty faculty, Date birth, Date enrol) {
|
||||||
|
Student newStudent = new Student(name, surname, email, group, faculty, birth, enrol);
|
||||||
|
studentManager().addStudent(newStudent);
|
||||||
|
logger.logOperation("Student added: " + newStudent.getFullname());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Edits the student, deletes the reference from the old group, and adds everything to the new one
|
||||||
|
public void editStudent(Student student, String name, String surname, String email, Group group, Faculty faculty, Date birth, Date enrol) {
|
||||||
|
student.getGroup().deleteStudent(student);
|
||||||
|
student.setName(name);
|
||||||
|
student.setSurname(surname);
|
||||||
|
student.setFullname(name + " " + surname);
|
||||||
|
student.setEmail(email);
|
||||||
|
student.setGroup(group);
|
||||||
|
group.addStudent(student);
|
||||||
|
student.setFaculty(faculty);
|
||||||
|
student.setDateOfBirth(birth);
|
||||||
|
student.setEnrollmentDate(enrol);
|
||||||
|
logger.logOperation("Student edited: " + student.getFullname());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Adds a group, and adds it to the faculty
|
||||||
|
public void addGroup(Group group, Faculty faculty) {
|
||||||
|
group.setFaculty(faculty);
|
||||||
|
faculty.addGroup(group);
|
||||||
|
groupManager().addGroup(group);
|
||||||
|
logger.logOperation("Group added: " + group.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deletes a student, simple as that
|
||||||
|
public void deleteStudent(Student st) {
|
||||||
|
st.getGroup().deleteStudent(st);
|
||||||
|
studentManager().deleteStudent(st);
|
||||||
|
logger.logOperation("Student deleted: " + st.getFullname());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Iterates through all faculties to get a faculty that matches the name
|
||||||
|
// In the future would be great to replace it using an UUID instead of a String name.
|
||||||
|
public Faculty getFacultyByName(String facultyName) {
|
||||||
|
for (Faculty faculty : facultyManager().getFaculties()) {
|
||||||
|
if (faculty.getName().equals(facultyName))
|
||||||
|
return faculty;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Same thing as getFacultyByName() except for Groups
|
||||||
|
public Group getGroupByName(String groupName, Faculty faculty) {
|
||||||
|
for (Group group : groupManager().getGroups()) {
|
||||||
|
if (group.getName().equals(groupName) && group.getFaculty().equals(faculty))
|
||||||
|
return group;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FacultyManager facultyManager() {
|
||||||
|
return fm;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GroupManager groupManager() {
|
||||||
|
return fm.getGm();
|
||||||
|
}
|
||||||
|
|
||||||
|
public StudentManager studentManager() {
|
||||||
|
return fm.getGm().getSm();
|
||||||
|
}
|
||||||
|
|
||||||
|
public LogManager getLogger() {
|
||||||
|
return this.logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user