Omluvny list, odstraneny .class soubory, pokus o taby

This commit is contained in:
Thastertyn 2023-03-29 22:03:51 +02:00
parent ccbaef8e5b
commit c650fc5247
28 changed files with 131 additions and 41 deletions

3
.gitignore vendored
View File

@ -1,2 +1 @@
/src/main/java/xyz/thastertyn/Jecna/Credentials.java *.class
/target/classes/xyz/thastertyn/Jecna/Credentials.class

View File

@ -1,5 +1,7 @@
package xyz.thastertyn.ContentDisplay.Content; package xyz.thastertyn.ContentDisplay.Content;
import com.googlecode.lanterna.gui2.Border;
import com.googlecode.lanterna.gui2.Component;
import com.googlecode.lanterna.gui2.Panel; import com.googlecode.lanterna.gui2.Panel;
import com.googlecode.lanterna.gui2.WindowBasedTextGUI; import com.googlecode.lanterna.gui2.WindowBasedTextGUI;
@ -9,9 +11,9 @@ import com.googlecode.lanterna.gui2.WindowBasedTextGUI;
public abstract class JecnaContent { public abstract class JecnaContent {
public abstract Panel getPanel(); public abstract Panel getPanel();
public abstract void download(String s); public abstract void download(final String JsessionId);
public abstract boolean hasStarted(); public abstract boolean hasStarted();
public abstract String getLabel(); public abstract Border getLabel();
public abstract void specify(int y, int hy); public abstract void specify(final int y, final int hy);
public abstract void getOptions(WindowBasedTextGUI textGUI); public abstract void getOptions(final WindowBasedTextGUI textGUI);
} }

View File

@ -0,0 +1,69 @@
package xyz.thastertyn.ContentDisplay.Content;
import java.io.IOException;
import java.net.UnknownHostException;
import java.util.ArrayList;
import com.googlecode.lanterna.gui2.Border;
import com.googlecode.lanterna.gui2.Borders;
import com.googlecode.lanterna.gui2.Component;
import com.googlecode.lanterna.gui2.Label;
import com.googlecode.lanterna.gui2.Panel;
import com.googlecode.lanterna.gui2.WindowBasedTextGUI;
import xyz.thastertyn.Tuple.Pair;
public class OmluvnyList extends JecnaContent{
private Panel omluvnyPanel = new Panel();
private xyz.thastertyn.JecnaParse.OmluvnyList omluvnyList = new xyz.thastertyn.JecnaParse.OmluvnyList();
private boolean hasStarted = false;
@Override
public void download(final String JsessionId) {
try{
omluvnyList.downloadOmluvnyList(JsessionId);
ArrayList<Pair<String, String>> a = omluvnyList.getData();
for(Pair<String, String> p : a)
{
omluvnyPanel.addComponent(new Label(p.getValue0() + " - " + p.getValue1()));
}
}catch(UnknownHostException e)
{
omluvnyPanel.addComponent(new Label("A connection error occurred"));
}catch(IOException e)
{
omluvnyPanel.addComponent(new Label("An error occurred"));
}
}
@Override
public Panel getPanel() {
return omluvnyPanel;
}
@Override
public boolean hasStarted() {
return hasStarted;
}
@Override
public Border getLabel() {
return new Label("Omluvny L.").withBorder(Borders.singleLine());
}
@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) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'getOptions'");
}
}

View File

@ -3,6 +3,9 @@ package xyz.thastertyn.ContentDisplay.Content;
import java.io.IOException; import java.io.IOException;
import java.net.UnknownHostException; import java.net.UnknownHostException;
import com.googlecode.lanterna.gui2.Border;
import com.googlecode.lanterna.gui2.Borders;
import com.googlecode.lanterna.gui2.Component;
import com.googlecode.lanterna.gui2.Label; import com.googlecode.lanterna.gui2.Label;
import com.googlecode.lanterna.gui2.Panel; import com.googlecode.lanterna.gui2.Panel;
import com.googlecode.lanterna.gui2.WindowBasedTextGUI; import com.googlecode.lanterna.gui2.WindowBasedTextGUI;
@ -67,9 +70,9 @@ public class Rozvrh extends JecnaContent {
} }
@Override @Override
public String getLabel() public Border getLabel()
{ {
return "Rozvrh"; return new Label("Rozvrh").withBorder(Borders.doubleLine());
} }
@Override @Override

View File

@ -5,6 +5,9 @@ import java.io.IOException;
import java.net.UnknownHostException; import java.net.UnknownHostException;
import java.util.ArrayList; import java.util.ArrayList;
import com.googlecode.lanterna.gui2.Border;
import com.googlecode.lanterna.gui2.Borders;
import com.googlecode.lanterna.gui2.Component;
import com.googlecode.lanterna.gui2.GridLayout; import com.googlecode.lanterna.gui2.GridLayout;
import com.googlecode.lanterna.gui2.Label; import com.googlecode.lanterna.gui2.Label;
import com.googlecode.lanterna.gui2.Panel; import com.googlecode.lanterna.gui2.Panel;
@ -62,8 +65,8 @@ public class Sdeleni extends JecnaContent {
} }
@Override @Override
public String getLabel() { public Border getLabel() {
return "Sdeleni"; return new Label("Sdeleni R.").withBorder(Borders.singleLine());
} }
@Override @Override

View File

@ -5,12 +5,14 @@ import java.util.ArrayList;
import com.googlecode.lanterna.TextColor; import com.googlecode.lanterna.TextColor;
import com.googlecode.lanterna.graphics.SimpleTheme; import com.googlecode.lanterna.graphics.SimpleTheme;
import com.googlecode.lanterna.gui2.Border;
import com.googlecode.lanterna.gui2.Borders;
import com.googlecode.lanterna.gui2.Component;
import com.googlecode.lanterna.gui2.Direction; import com.googlecode.lanterna.gui2.Direction;
import com.googlecode.lanterna.gui2.Label; import com.googlecode.lanterna.gui2.Label;
import com.googlecode.lanterna.gui2.LinearLayout; import com.googlecode.lanterna.gui2.LinearLayout;
import com.googlecode.lanterna.gui2.Panel; import com.googlecode.lanterna.gui2.Panel;
import com.googlecode.lanterna.gui2.WindowBasedTextGUI; import com.googlecode.lanterna.gui2.WindowBasedTextGUI;
import com.googlecode.lanterna.gui2.dialogs.ActionListDialogBuilder;
import xyz.thastertyn.Tuple.Pair; import xyz.thastertyn.Tuple.Pair;
@ -34,6 +36,12 @@ public class Znamky extends JecnaContent {
ArrayList<Pair<String, Pair<ArrayList<Pair<Integer, Double>>,Double>>> grades = znamky.getGrades(); ArrayList<Pair<String, Pair<ArrayList<Pair<Integer, Double>>,Double>>> grades = znamky.getGrades();
TextColor.RGB vyborny = new TextColor.RGB(85,212,0);
TextColor.RGB chvalitebny = new TextColor.RGB(196,224,80);
TextColor.RGB dobry = new TextColor.RGB(255,213,42);
TextColor.RGB dostatecny = new TextColor.RGB(255,102,0);
TextColor.RGB nedostatecny = new TextColor.RGB(255,48,48);
for(Pair<String, Pair<ArrayList<Pair<Integer, Double>>,Double>> predmet : grades) for(Pair<String, Pair<ArrayList<Pair<Integer, Double>>,Double>> predmet : grades)
{ {
predmetyPanel.addComponent(new Label(predmet.getValue0())); predmetyPanel.addComponent(new Label(predmet.getValue0()));
@ -56,21 +64,20 @@ public class Znamky extends JecnaContent {
znamkaLabel.setTheme(new SimpleTheme(TextColor.ANSI.WHITE, TextColor.ANSI.BLACK)); znamkaLabel.setTheme(new SimpleTheme(TextColor.ANSI.WHITE, TextColor.ANSI.BLACK));
break; break;
case 1: case 1:
znamkaLabel.setTheme(new SimpleTheme(TextColor.ANSI.BLACK, new TextColor.RGB(85,212,0))); znamkaLabel.setTheme(new SimpleTheme(TextColor.ANSI.BLACK, vyborny));
break; break;
case 2: case 2:
znamkaLabel.setTheme(new SimpleTheme(TextColor.ANSI.BLACK, new TextColor.RGB(196,224,80))); znamkaLabel.setTheme(new SimpleTheme(TextColor.ANSI.BLACK, chvalitebny));
break; break;
case 3: case 3:
znamkaLabel.setTheme(new SimpleTheme(TextColor.ANSI.BLACK, new TextColor.RGB(255,213,42))); znamkaLabel.setTheme(new SimpleTheme(TextColor.ANSI.BLACK, dobry));
break; break;
case 4: case 4:
znamkaLabel.setTheme(new SimpleTheme(TextColor.ANSI.BLACK, new TextColor.RGB(255,102,0))); znamkaLabel.setTheme(new SimpleTheme(TextColor.ANSI.BLACK, dostatecny));
break; break;
case 5: case 5:
znamkaLabel.setTheme(new SimpleTheme(TextColor.ANSI.BLACK, new TextColor.RGB(255,48,48))); znamkaLabel.setTheme(new SimpleTheme(TextColor.ANSI.BLACK, nedostatecny));
break; break;
// Todo try set sgr
} }
znamkyZPredmetu.addComponent(znamkaLabel); znamkyZPredmetu.addComponent(znamkaLabel);
@ -84,21 +91,21 @@ public class Znamky extends JecnaContent {
if(prumer >= 1 && prumer < 1.5) if(prumer >= 1 && prumer < 1.5)
{ {
vysl.setTheme(new SimpleTheme(TextColor.ANSI.BLACK, new TextColor.RGB(85,212,0))); vysl.setTheme(new SimpleTheme(TextColor.ANSI.BLACK, vyborny));
}else if(prumer >= 1.5 && prumer < 2.5) }else if(prumer >= 1.5 && prumer < 2.5)
{ {
vysl.setTheme(new SimpleTheme(TextColor.ANSI.BLACK, new TextColor.RGB(196,224,80))); vysl.setTheme(new SimpleTheme(TextColor.ANSI.BLACK, chvalitebny));
}else if(prumer >= 2.5 && prumer < 3.5) }else if(prumer >= 2.5 && prumer < 3.5)
{ {
vysl.setTheme(new SimpleTheme(TextColor.ANSI.BLACK, new TextColor.RGB(255,213,42))); vysl.setTheme(new SimpleTheme(TextColor.ANSI.BLACK, dobry));
}else if(prumer >= 3.5 && prumer < 4.5) }else if(prumer >= 3.5 && prumer < 4.5)
{ {
vysl.setTheme(new SimpleTheme(TextColor.ANSI.BLACK, new TextColor.RGB(255,102,0))); vysl.setTheme(new SimpleTheme(TextColor.ANSI.BLACK, dostatecny));
}else if(prumer >= 4.5) }else if(prumer >= 4.5)
{ {
vysl.setTheme(new SimpleTheme(TextColor.ANSI.BLACK, new TextColor.RGB(255,48,48))); vysl.setTheme(new SimpleTheme(TextColor.ANSI.BLACK, nedostatecny));
} }
vyslPanel.addComponent(vysl); vyslPanel.addComponent(vysl);
@ -128,9 +135,9 @@ public class Znamky extends JecnaContent {
} }
@Override @Override
public String getLabel() public Border getLabel()
{ {
return "Znamky"; return new Label("Znamky").withBorder(Borders.singleLine());
} }
@Override @Override

View File

@ -52,10 +52,7 @@ public class MainWindow {
window.setComponent(mainPanel); window.setComponent(mainPanel);
Panel tabs = new Panel() Panel tabs = new Panel()
.setLayoutManager(new LinearLayout(Direction.HORIZONTAL)) .setLayoutManager(new LinearLayout(Direction.HORIZONTAL));
.addComponent(new Label("Rozvrh").withBorder(Borders.singleLine()))
.addComponent(new Label("Znamky").withBorder(Borders.singleLine()))
.addComponent(new Label("Sdeleni R.").withBorder(Borders.singleLine()));
mainPanel.addComponent(tabs); mainPanel.addComponent(tabs);

View File

@ -4,6 +4,9 @@ import java.util.concurrent.atomic.AtomicBoolean;
import com.googlecode.lanterna.TerminalPosition; import com.googlecode.lanterna.TerminalPosition;
import com.googlecode.lanterna.TerminalSize; import com.googlecode.lanterna.TerminalSize;
import com.googlecode.lanterna.gui2.Border;
import com.googlecode.lanterna.gui2.Borders;
import com.googlecode.lanterna.gui2.Label;
import com.googlecode.lanterna.gui2.Panel; import com.googlecode.lanterna.gui2.Panel;
import com.googlecode.lanterna.gui2.Window; import com.googlecode.lanterna.gui2.Window;
import com.googlecode.lanterna.gui2.WindowBasedTextGUI; import com.googlecode.lanterna.gui2.WindowBasedTextGUI;
@ -12,6 +15,7 @@ import com.googlecode.lanterna.input.KeyStroke;
import com.googlecode.lanterna.input.KeyType; import com.googlecode.lanterna.input.KeyType;
import xyz.thastertyn.ContentDisplay.Content.JecnaContent; import xyz.thastertyn.ContentDisplay.Content.JecnaContent;
import xyz.thastertyn.ContentDisplay.Content.OmluvnyList;
import xyz.thastertyn.ContentDisplay.Content.Rozvrh; import xyz.thastertyn.ContentDisplay.Content.Rozvrh;
import xyz.thastertyn.ContentDisplay.Content.Sdeleni; import xyz.thastertyn.ContentDisplay.Content.Sdeleni;
import xyz.thastertyn.ContentDisplay.Content.Znamky; import xyz.thastertyn.ContentDisplay.Content.Znamky;
@ -20,23 +24,22 @@ public class WindowSwitchListener implements WindowListener {
WindowBasedTextGUI gui; WindowBasedTextGUI gui;
private JecnaContent[] contents = {new Rozvrh(), new Znamky(), new Sdeleni()}; private JecnaContent[] contents = {new Rozvrh(), new Znamky(), new Sdeleni(), new OmluvnyList()};
private Border[] tabs = new Border[contents.length];
private Panel tabsPanel;
private Panel content;
private String JsessionId; private String JsessionId;
private Panel content;
private Panel tabs;
String title;
int current = 0; int current = 0;
public WindowSwitchListener(Panel holder, String JsessionId, Panel tabs, String title) public WindowSwitchListener(Panel holder, String JsessionId, Panel tabs, String title)
{ {
this.content = holder; this.content = holder;
this.tabs = tabs; this.tabsPanel = tabs;
this.title = title;
this.JsessionId = JsessionId; this.JsessionId = JsessionId;
addTabs();
defaultPanel(); defaultPanel();
} }
@ -45,11 +48,12 @@ public class WindowSwitchListener implements WindowListener {
contents[0].download(JsessionId); contents[0].download(JsessionId);
content.removeAllComponents(); content.removeAllComponents();
content.addComponent(contents[0].getPanel()); content.addComponent(contents[0].getPanel());
title = contents[0].getLabel();
} }
public void next() public void next()
{ {
// tabs.getChildrenList().get(current).withBorder(Borders.singleLine());
if(current + 1 == contents.length) if(current + 1 == contents.length)
{ {
current = 0; current = 0;
@ -62,10 +66,11 @@ public class WindowSwitchListener implements WindowListener {
contents[current].download(JsessionId); contents[current].download(JsessionId);
} }
// tabs[current].getComponent().withBorder(Borders.doubleLine());
content.removeAllComponents(); content.removeAllComponents();
content.addComponent(contents[current].getPanel()); content.addComponent(contents[current].getPanel());
title = contents[current].getLabel();
} }
public void previous() public void previous()
@ -83,11 +88,16 @@ public class WindowSwitchListener implements WindowListener {
} }
content.removeAllComponents(); content.removeAllComponents();
content.addComponent(contents[current].getPanel()); content.addComponent(contents[current].getPanel());
title = contents[current].getLabel();
} }
private void addTabs()
{
for(int i = 0; i < contents.length; i++)
{
tabs[i] = contents[i].getLabel();
tabsPanel.addComponent(tabs[i]);
}
}
@Override @Override
public void onInput(Window basePane, KeyStroke keyStroke, AtomicBoolean deliverEvent) { public void onInput(Window basePane, KeyStroke keyStroke, AtomicBoolean deliverEvent) {