mensi organizace, misto tuplu bude novy typ

This commit is contained in:
Thastertyn 2023-04-07 11:03:54 +02:00
parent 5e5e6f26da
commit 7b7c00b866
26 changed files with 189 additions and 93 deletions

View File

@ -1,6 +1,6 @@
package xyz.thastertyn;
import xyz.thastertyn.ContentDisplay.MainWindow;
import xyz.thastertyn.Display.MainWindow;
/**
* Hello world!

View File

@ -1,5 +0,0 @@
package xyz.thastertyn.ContentDisplay.Content;
public class Jidelna {
}

View File

@ -1,6 +1,7 @@
package xyz.thastertyn.ContentDisplay.Content;
package xyz.thastertyn.Display.Content;
import com.googlecode.lanterna.gui2.WindowBasedTextGUI;
import com.googlecode.lanterna.gui2.dialogs.MessageDialog;
import com.googlecode.lanterna.gui2.Panel;
import com.googlecode.lanterna.gui2.Label;
@ -13,6 +14,5 @@ public abstract class JecnaContent {
public abstract void download();
public abstract boolean hasStarted();
public abstract Label getLabel();
public abstract void specify(final int y, final int hy);
public abstract void getOptions(final WindowBasedTextGUI textGUI);
public abstract void showOptions(final WindowBasedTextGUI textGUI);
}

View File

@ -0,0 +1,5 @@
package xyz.thastertyn.Display.Content;
public class Jidelna {
}

View File

@ -1,4 +1,4 @@
package xyz.thastertyn.ContentDisplay.Content;
package xyz.thastertyn.Display.Content;
import java.io.IOException;
import java.net.UnknownHostException;
@ -14,7 +14,7 @@ public class OmluvnyList extends JecnaContent{
private Panel omluvnyPanel = new Panel();
private Label borderLabel = new Label("Omluvny L.");
private xyz.thastertyn.JecnaParse.OmluvnyList omluvnyList = new xyz.thastertyn.JecnaParse.OmluvnyList();
private xyz.thastertyn.Scrape.OmluvnyList omluvnyList = new xyz.thastertyn.Scrape.OmluvnyList();
private boolean hasStarted = false;
@ -55,13 +55,7 @@ public class OmluvnyList extends JecnaContent{
}
@Override
public void specify(int y, int hy) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'specify'");
}
@Override
public void getOptions(WindowBasedTextGUI textGUI) {
public void showOptions(WindowBasedTextGUI textGUI) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'getOptions'");
}

View File

@ -1,4 +1,4 @@
package xyz.thastertyn.ContentDisplay.Content;
package xyz.thastertyn.Display.Content;
import java.io.IOException;
import java.net.UnknownHostException;
@ -6,13 +6,14 @@ import java.net.UnknownHostException;
import com.googlecode.lanterna.gui2.Label;
import com.googlecode.lanterna.gui2.Panel;
import com.googlecode.lanterna.gui2.WindowBasedTextGUI;
import com.googlecode.lanterna.gui2.dialogs.MessageDialog;
import com.googlecode.lanterna.gui2.table.Table;
public class Rozvrh extends JecnaContent {
private Panel rozvrhPanel = new Panel();
private Label borderLabel = new Label("Rozvrh");
private xyz.thastertyn.JecnaParse.Rozvrh rozvrh = new xyz.thastertyn.JecnaParse.Rozvrh();
private xyz.thastertyn.Scrape.Rozvrh rozvrh = new xyz.thastertyn.Scrape.Rozvrh();
private boolean hasStarted = false;
@ -73,13 +74,7 @@ public class Rozvrh extends JecnaContent {
}
@Override
public void specify(int y, int hy) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'specify'");
}
@Override
public void getOptions(WindowBasedTextGUI textGUI) {
public void showOptions(WindowBasedTextGUI textGUI) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'getOptions'");
}

View File

@ -1,4 +1,4 @@
package xyz.thastertyn.ContentDisplay.Content;
package xyz.thastertyn.Display.Content;
import java.io.IOException;
@ -9,13 +9,14 @@ import com.googlecode.lanterna.gui2.GridLayout;
import com.googlecode.lanterna.gui2.Label;
import com.googlecode.lanterna.gui2.Panel;
import com.googlecode.lanterna.gui2.WindowBasedTextGUI;
import com.googlecode.lanterna.gui2.dialogs.MessageDialog;
public class Sdeleni extends JecnaContent {
private Panel sdeleniPanel = new Panel();
private Label borderLabel = new Label("Sdeleni R.");
private xyz.thastertyn.JecnaParse.Sdeleni sdeleni = new xyz.thastertyn.JecnaParse.Sdeleni();
private xyz.thastertyn.Scrape.Sdeleni sdeleni = new xyz.thastertyn.Scrape.Sdeleni();
private boolean hasStarted = false;
@ -65,13 +66,7 @@ public class Sdeleni extends JecnaContent {
}
@Override
public void specify(int y, int hy) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'specify'");
}
@Override
public void getOptions(WindowBasedTextGUI textGUI) {
public void showOptions(WindowBasedTextGUI textGUI) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'getOptions'");
}

View File

@ -1,4 +1,4 @@
package xyz.thastertyn.ContentDisplay.Content;
package xyz.thastertyn.Display.Content;
import java.io.IOException;
import java.util.ArrayList;
@ -11,7 +11,9 @@ import com.googlecode.lanterna.gui2.Label;
import com.googlecode.lanterna.gui2.LinearLayout;
import com.googlecode.lanterna.gui2.Panel;
import com.googlecode.lanterna.gui2.WindowBasedTextGUI;
import com.googlecode.lanterna.gui2.dialogs.MessageDialog;
import xyz.thastertyn.Display.Dialogs.OptionsDialog;
import xyz.thastertyn.Tuples.Pair;
public class Znamky extends JecnaContent {
@ -20,7 +22,7 @@ public class Znamky extends JecnaContent {
.setLayoutManager(new GridLayout(3));
private Label borderLabel = new Label("Znamky");
private xyz.thastertyn.JecnaParse.Znamky znamky = new xyz.thastertyn.JecnaParse.Znamky();
private xyz.thastertyn.Scrape.Znamky znamky = new xyz.thastertyn.Scrape.Znamky();
private boolean hasStarted = false;
@ -159,14 +161,9 @@ public class Znamky extends JecnaContent {
}
@Override
public void specify(int y, int hy) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'specify'");
}
public void showOptions(WindowBasedTextGUI textGUI) {
OptionsDialog d = new OptionsDialog(znamky.getOptions());
@Override
public void getOptions(WindowBasedTextGUI textGUI) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'getOptions'");
d.showDialog(textGUI);
}
}

View File

@ -1,4 +1,4 @@
package xyz.thastertyn.ContentDisplay;
package xyz.thastertyn.Display.Dialogs;
import java.util.Arrays;
@ -29,7 +29,7 @@ public class CredentialsInput extends DialogWindow {
private CheckBox remember;
CredentialsInput()
public CredentialsInput()
{
super("Login");
this.user = null;

View File

@ -0,0 +1,74 @@
package xyz.thastertyn.Display.Dialogs;
import java.util.ArrayList;
import java.util.Arrays;
import com.googlecode.lanterna.gui2.Button;
import com.googlecode.lanterna.gui2.ComboBox;
import com.googlecode.lanterna.gui2.EmptySpace;
import com.googlecode.lanterna.gui2.GridLayout;
import com.googlecode.lanterna.gui2.LocalizedString;
import com.googlecode.lanterna.gui2.Panel;
import com.googlecode.lanterna.gui2.Window;
import com.googlecode.lanterna.gui2.WindowBasedTextGUI;
import com.googlecode.lanterna.gui2.dialogs.DialogWindow;
import xyz.thastertyn.Tuples.Pair;
public class OptionsDialog extends DialogWindow {
private int option0 = 0;
private int option1 = 0;
public OptionsDialog(Pair<ArrayList<String>, ArrayList<String>> options)
{
super("Choose from below");
Panel mainPanel = new Panel()
.setLayoutManager(new GridLayout(1)
.setLeftMarginSize(1)
.setRightMarginSize(1));
new Panel().setLayoutManager(new GridLayout(3))
.addComponent(new ComboBox<>(options.getValue0(), options.getValue0().size() - 1))
.addComponent(new EmptySpace())
.addComponent(new ComboBox<>(options.getValue1(), options.getValue1().size() - 1))
.addTo(mainPanel);
new Panel()
.setLayoutManager(
new GridLayout(2).setHorizontalSpacing(1))
.addComponent(
new Button(LocalizedString.OK.toString(), this::onOK)
.setLayoutData(GridLayout.createLayoutData(
GridLayout.Alignment.CENTER,
GridLayout.Alignment.CENTER,
true,
false)))
.addComponent(
new Button(LocalizedString.Cancel.toString(), this::onCancel))
.addTo(mainPanel);
setHints(Arrays.asList(Window.Hint.CENTERED));
setComponent(mainPanel);
}
public void onOK()
{
close();
}
public void onCancel()
{
close();
}
@Override
public String showDialog(WindowBasedTextGUI textGUI) {
super.showDialog(textGUI);
return "";
}
}

View File

@ -1,4 +1,4 @@
package xyz.thastertyn.ContentDisplay;
package xyz.thastertyn.Display;
import java.io.BufferedReader;
import java.io.BufferedWriter;
@ -14,13 +14,14 @@ import com.googlecode.lanterna.gui2.WindowBasedTextGUI;
import com.googlecode.lanterna.gui2.dialogs.MessageDialog;
import com.googlecode.lanterna.gui2.dialogs.MessageDialogButton;
import xyz.thastertyn.Display.Dialogs.CredentialsInput;
import xyz.thastertyn.Tuples.Triplet;
public class LoginController {
private WindowBasedTextGUI textGUI;
private xyz.thastertyn.ContentDisplay.CredentialsInput dialog;
private xyz.thastertyn.JecnaParse.Login login = new xyz.thastertyn.JecnaParse.Login();
private xyz.thastertyn.Display.Dialogs.CredentialsInput dialog;
private xyz.thastertyn.Scrape.Login login = new xyz.thastertyn.Scrape.Login();
public LoginController(WindowBasedTextGUI textGUI)
{

View File

@ -1,4 +1,4 @@
package xyz.thastertyn.ContentDisplay;
package xyz.thastertyn.Display;
import java.io.IOException;
import java.util.Arrays;

View File

@ -1,4 +1,4 @@
package xyz.thastertyn.ContentDisplay;
package xyz.thastertyn.Display;
import java.util.concurrent.atomic.AtomicBoolean;
@ -17,11 +17,11 @@ import com.googlecode.lanterna.gui2.dialogs.MessageDialogButton;
import com.googlecode.lanterna.input.KeyStroke;
import com.googlecode.lanterna.input.KeyType;
import xyz.thastertyn.ContentDisplay.Content.JecnaContent;
import xyz.thastertyn.ContentDisplay.Content.OmluvnyList;
import xyz.thastertyn.ContentDisplay.Content.Rozvrh;
import xyz.thastertyn.ContentDisplay.Content.Sdeleni;
import xyz.thastertyn.ContentDisplay.Content.Znamky;
import xyz.thastertyn.Display.Content.JecnaContent;
import xyz.thastertyn.Display.Content.OmluvnyList;
import xyz.thastertyn.Display.Content.Rozvrh;
import xyz.thastertyn.Display.Content.Sdeleni;
import xyz.thastertyn.Display.Content.Znamky;
public class WindowSwitchListener implements WindowListener {
@ -115,7 +115,7 @@ public class WindowSwitchListener implements WindowListener {
case Character:
if(keyStroke.getCharacter() == ' ')
{
MessageDialog.showMessageDialog(textGUI, "Space pressed", "Good job", MessageDialogButton.OK);
contents[current].showOptions(textGUI);
}
break;
case Escape:

View File

@ -1,5 +0,0 @@
package xyz.thastertyn.JecnaParse;
public class JecnaParser {
}

View File

@ -1,5 +0,0 @@
package xyz.thastertyn.JecnaParse;
public class Jidelna {
}

View File

@ -0,0 +1,9 @@
package xyz.thastertyn.Scrape;
import xyz.thastertyn.Types.BaseType;
public abstract class BaseJecnaParser {
public abstract void download();
public abstract BaseType getData();
}

View File

@ -1,4 +1,4 @@
package xyz.thastertyn.JecnaParse;
package xyz.thastertyn.Scrape;
import org.jsoup.Connection;
import org.jsoup.Jsoup;

View File

@ -0,0 +1,5 @@
package xyz.thastertyn.Scrape;
public class Jidelna {
}

View File

@ -1,4 +1,4 @@
package xyz.thastertyn.JecnaParse;
package xyz.thastertyn.Scrape;
import java.io.IOException;
import java.net.UnknownHostException;

View File

@ -1,4 +1,4 @@
package xyz.thastertyn.JecnaParse;
package xyz.thastertyn.Scrape;
import java.io.IOException;
import java.net.UnknownHostException;

View File

@ -1,4 +1,4 @@
package xyz.thastertyn.JecnaParse;
package xyz.thastertyn.Scrape;
import java.io.IOException;
import java.net.UnknownHostException;

View File

@ -1,4 +1,4 @@
package xyz.thastertyn.JecnaParse;
package xyz.thastertyn.Scrape;
import java.io.IOException;
import java.net.UnknownHostException;

View File

@ -1,4 +1,4 @@
package xyz.thastertyn.JecnaParse;
package xyz.thastertyn.Scrape;
import java.io.IOException;
import java.net.UnknownHostException;
@ -11,15 +11,18 @@ import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import xyz.thastertyn.Tuples.Pair;
import xyz.thastertyn.Tuples.Triplet;
public class Znamky {
private boolean wasDownloaded;
// schoolYear, schoolYearId
private ArrayList<Triplet<String, ArrayList<Pair<Integer, Double>>, Double>> test = new ArrayList<>();
private ArrayList<Pair<String, Pair<ArrayList<Pair<Integer, Double>>,Double>>> grades = new ArrayList<>();
// Integer znaci id roku, boolean jestli je jen prvni nebo i druhe pololeti
private Pair<ArrayList<String>, ArrayList<String>> options = new Pair<>();
private Pair<ArrayList<Pair<String, String>>, ArrayList<Pair<String, String>>> options = new Pair<>(new ArrayList<Pair<String, String>>(), new ArrayList<Pair<String, String>>());
public void downloadZnamky(/*, int schoolYearId, int schoolYearHalfId*/) throws UnknownHostException, IOException
{
@ -80,26 +83,17 @@ public class Znamky {
Elements schoolYear = optionsPanel.select("select[id=schoolYearId]").select("option");
Elements schoolYearId = optionsPanel.select("select[id=schoolYearHalfId]").select("option");
/*
Elements roky = znamkyDoc.select("select[name=schoolYearId]");
Elements pololetiSelect = znamkyDoc.select("select[name=schoolYearHalfId]");
for(Element e : schoolYear)
{
options.getValue0().add(e.attr("value"));
}
for(Element e : roky)
{
boolean jeCelyRok = false;
if(pololetiSelect.size() == 2)
{
jeCelyRok = true;
}
int rok = Integer.parseInt(e.attr("value"));
options.add(new Pair<Integer, Boolean>(rok, jeCelyRok));
}*/
for(Element e : schoolYearId)
{
options.getValue1().add(new Pair<>(e.attr("value", e.text()));
}
wasDownloaded = true;
}
private void addGrade(int index, String subject, int grade, double weight)
@ -147,6 +141,11 @@ public class Znamky {
return grades;
}
public Pair<ArrayList<String>, ArrayList<String>> getOptions()
{
return options;
}
@Override
public String toString()
{

View File

@ -0,0 +1,5 @@
package xyz.thastertyn.Types;
public abstract class BaseType {
}

View File

@ -0,0 +1,13 @@
package xyz.thastertyn.Types;
public class OmluvnyList {
private String datum;
private String popis;
public OmluvnyList(String datum, String popis)
{
this.datum = datum;
this.popis = popis;
}
}

View File

@ -0,0 +1,19 @@
package xyz.thastertyn.Types;
public class Znamka {
private int znamka;
private boolean malaZnamka;
private String text;
private String datum;
public Znamka(int znamka, boolean malaZnamka, String text, String datum)
{
this.znamka = znamka;
this.malaZnamka = malaZnamka;
this.datum = datum;
this.text = text;
}
}