diff --git a/.gitignore b/.gitignore index 2992de4..5241a72 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1 @@ -/src/main/java/xyz/thastertyn/Jecna/Credentials.java -/target/classes/xyz/thastertyn/Jecna/Credentials.class \ No newline at end of file +*.class \ No newline at end of file diff --git a/src/main/java/xyz/thastertyn/ContentDisplay/Content/JecnaContent.java b/src/main/java/xyz/thastertyn/ContentDisplay/Content/JecnaContent.java index b650424..bba5966 100644 --- a/src/main/java/xyz/thastertyn/ContentDisplay/Content/JecnaContent.java +++ b/src/main/java/xyz/thastertyn/ContentDisplay/Content/JecnaContent.java @@ -1,5 +1,7 @@ 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.WindowBasedTextGUI; @@ -9,9 +11,9 @@ import com.googlecode.lanterna.gui2.WindowBasedTextGUI; public abstract class JecnaContent { public abstract Panel getPanel(); - public abstract void download(String s); + public abstract void download(final String JsessionId); public abstract boolean hasStarted(); - public abstract String getLabel(); - public abstract void specify(int y, int hy); - public abstract void getOptions(WindowBasedTextGUI textGUI); + public abstract Border getLabel(); + public abstract void specify(final int y, final int hy); + public abstract void getOptions(final WindowBasedTextGUI textGUI); } diff --git a/src/main/java/xyz/thastertyn/ContentDisplay/Content/OmluvnyList.java b/src/main/java/xyz/thastertyn/ContentDisplay/Content/OmluvnyList.java new file mode 100644 index 0000000..b0895b5 --- /dev/null +++ b/src/main/java/xyz/thastertyn/ContentDisplay/Content/OmluvnyList.java @@ -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> a = omluvnyList.getData(); + + for(Pair 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'"); + } +} diff --git a/src/main/java/xyz/thastertyn/ContentDisplay/Content/Rozvrh.java b/src/main/java/xyz/thastertyn/ContentDisplay/Content/Rozvrh.java index 1419745..7493a89 100644 --- a/src/main/java/xyz/thastertyn/ContentDisplay/Content/Rozvrh.java +++ b/src/main/java/xyz/thastertyn/ContentDisplay/Content/Rozvrh.java @@ -3,6 +3,9 @@ package xyz.thastertyn.ContentDisplay.Content; import java.io.IOException; 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.Panel; import com.googlecode.lanterna.gui2.WindowBasedTextGUI; @@ -67,9 +70,9 @@ public class Rozvrh extends JecnaContent { } @Override - public String getLabel() + public Border getLabel() { - return "Rozvrh"; + return new Label("Rozvrh").withBorder(Borders.doubleLine()); } @Override diff --git a/src/main/java/xyz/thastertyn/ContentDisplay/Content/Sdeleni.java b/src/main/java/xyz/thastertyn/ContentDisplay/Content/Sdeleni.java index 4e06603..3c366e7 100644 --- a/src/main/java/xyz/thastertyn/ContentDisplay/Content/Sdeleni.java +++ b/src/main/java/xyz/thastertyn/ContentDisplay/Content/Sdeleni.java @@ -5,6 +5,9 @@ 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.GridLayout; import com.googlecode.lanterna.gui2.Label; import com.googlecode.lanterna.gui2.Panel; @@ -62,8 +65,8 @@ public class Sdeleni extends JecnaContent { } @Override - public String getLabel() { - return "Sdeleni"; + public Border getLabel() { + return new Label("Sdeleni R.").withBorder(Borders.singleLine()); } @Override diff --git a/src/main/java/xyz/thastertyn/ContentDisplay/Content/Znamky.java b/src/main/java/xyz/thastertyn/ContentDisplay/Content/Znamky.java index 25ab6ea..cf28fe5 100644 --- a/src/main/java/xyz/thastertyn/ContentDisplay/Content/Znamky.java +++ b/src/main/java/xyz/thastertyn/ContentDisplay/Content/Znamky.java @@ -5,12 +5,14 @@ import java.util.ArrayList; import com.googlecode.lanterna.TextColor; 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.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.ActionListDialogBuilder; import xyz.thastertyn.Tuple.Pair; @@ -34,6 +36,12 @@ public class Znamky extends JecnaContent { ArrayList>,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>,Double>> predmet : grades) { 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)); break; case 1: - znamkaLabel.setTheme(new SimpleTheme(TextColor.ANSI.BLACK, new TextColor.RGB(85,212,0))); + znamkaLabel.setTheme(new SimpleTheme(TextColor.ANSI.BLACK, vyborny)); break; case 2: - znamkaLabel.setTheme(new SimpleTheme(TextColor.ANSI.BLACK, new TextColor.RGB(196,224,80))); + znamkaLabel.setTheme(new SimpleTheme(TextColor.ANSI.BLACK, chvalitebny)); break; case 3: - znamkaLabel.setTheme(new SimpleTheme(TextColor.ANSI.BLACK, new TextColor.RGB(255,213,42))); + znamkaLabel.setTheme(new SimpleTheme(TextColor.ANSI.BLACK, dobry)); break; case 4: - znamkaLabel.setTheme(new SimpleTheme(TextColor.ANSI.BLACK, new TextColor.RGB(255,102,0))); + znamkaLabel.setTheme(new SimpleTheme(TextColor.ANSI.BLACK, dostatecny)); break; case 5: - znamkaLabel.setTheme(new SimpleTheme(TextColor.ANSI.BLACK, new TextColor.RGB(255,48,48))); + znamkaLabel.setTheme(new SimpleTheme(TextColor.ANSI.BLACK, nedostatecny)); break; - // Todo try set sgr } znamkyZPredmetu.addComponent(znamkaLabel); @@ -84,21 +91,21 @@ public class Znamky extends JecnaContent { 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) { - 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) { - 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) { - 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) { - vysl.setTheme(new SimpleTheme(TextColor.ANSI.BLACK, new TextColor.RGB(255,48,48))); + vysl.setTheme(new SimpleTheme(TextColor.ANSI.BLACK, nedostatecny)); } vyslPanel.addComponent(vysl); @@ -128,9 +135,9 @@ public class Znamky extends JecnaContent { } @Override - public String getLabel() + public Border getLabel() { - return "Znamky"; + return new Label("Znamky").withBorder(Borders.singleLine()); } @Override diff --git a/src/main/java/xyz/thastertyn/ContentDisplay/MainWindow.java b/src/main/java/xyz/thastertyn/ContentDisplay/MainWindow.java index 0fc95cc..bde7ae2 100644 --- a/src/main/java/xyz/thastertyn/ContentDisplay/MainWindow.java +++ b/src/main/java/xyz/thastertyn/ContentDisplay/MainWindow.java @@ -52,10 +52,7 @@ public class MainWindow { window.setComponent(mainPanel); Panel tabs = new Panel() - .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())); + .setLayoutManager(new LinearLayout(Direction.HORIZONTAL)); mainPanel.addComponent(tabs); diff --git a/src/main/java/xyz/thastertyn/ContentDisplay/WindowSwitchListener.java b/src/main/java/xyz/thastertyn/ContentDisplay/WindowSwitchListener.java index d4873a9..320f4fa 100644 --- a/src/main/java/xyz/thastertyn/ContentDisplay/WindowSwitchListener.java +++ b/src/main/java/xyz/thastertyn/ContentDisplay/WindowSwitchListener.java @@ -4,6 +4,9 @@ import java.util.concurrent.atomic.AtomicBoolean; import com.googlecode.lanterna.TerminalPosition; 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.Window; import com.googlecode.lanterna.gui2.WindowBasedTextGUI; @@ -12,6 +15,7 @@ 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; @@ -20,23 +24,22 @@ public class WindowSwitchListener implements WindowListener { 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 Panel content; - private Panel tabs; - - String title; - int current = 0; public WindowSwitchListener(Panel holder, String JsessionId, Panel tabs, String title) { this.content = holder; - this.tabs = tabs; - this.title = title; + this.tabsPanel = tabs; this.JsessionId = JsessionId; + addTabs(); defaultPanel(); } @@ -45,11 +48,12 @@ public class WindowSwitchListener implements WindowListener { contents[0].download(JsessionId); content.removeAllComponents(); content.addComponent(contents[0].getPanel()); - title = contents[0].getLabel(); } public void next() { + // tabs.getChildrenList().get(current).withBorder(Borders.singleLine()); + if(current + 1 == contents.length) { current = 0; @@ -62,10 +66,11 @@ public class WindowSwitchListener implements WindowListener { contents[current].download(JsessionId); } + // tabs[current].getComponent().withBorder(Borders.doubleLine()); + content.removeAllComponents(); content.addComponent(contents[current].getPanel()); - title = contents[current].getLabel(); } public void previous() @@ -83,11 +88,16 @@ public class WindowSwitchListener implements WindowListener { } content.removeAllComponents(); 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 public void onInput(Window basePane, KeyStroke keyStroke, AtomicBoolean deliverEvent) { diff --git a/target/classes/xyz/thastertyn/App.class b/target/classes/xyz/thastertyn/App.class deleted file mode 100644 index 7c1dfc3..0000000 Binary files a/target/classes/xyz/thastertyn/App.class and /dev/null differ diff --git a/target/classes/xyz/thastertyn/ContentDisplay/Content/JecnaContent.class b/target/classes/xyz/thastertyn/ContentDisplay/Content/JecnaContent.class deleted file mode 100644 index a28c243..0000000 Binary files a/target/classes/xyz/thastertyn/ContentDisplay/Content/JecnaContent.class and /dev/null differ diff --git a/target/classes/xyz/thastertyn/ContentDisplay/Content/Jidelna.class b/target/classes/xyz/thastertyn/ContentDisplay/Content/Jidelna.class deleted file mode 100644 index b396fa7..0000000 Binary files a/target/classes/xyz/thastertyn/ContentDisplay/Content/Jidelna.class and /dev/null differ diff --git a/target/classes/xyz/thastertyn/ContentDisplay/Content/Rozvrh.class b/target/classes/xyz/thastertyn/ContentDisplay/Content/Rozvrh.class deleted file mode 100644 index 55943eb..0000000 Binary files a/target/classes/xyz/thastertyn/ContentDisplay/Content/Rozvrh.class and /dev/null differ diff --git a/target/classes/xyz/thastertyn/ContentDisplay/Content/Sdeleni.class b/target/classes/xyz/thastertyn/ContentDisplay/Content/Sdeleni.class deleted file mode 100644 index 6f248fc..0000000 Binary files a/target/classes/xyz/thastertyn/ContentDisplay/Content/Sdeleni.class and /dev/null differ diff --git a/target/classes/xyz/thastertyn/ContentDisplay/Content/Znamky.class b/target/classes/xyz/thastertyn/ContentDisplay/Content/Znamky.class deleted file mode 100644 index dc5cd14..0000000 Binary files a/target/classes/xyz/thastertyn/ContentDisplay/Content/Znamky.class and /dev/null differ diff --git a/target/classes/xyz/thastertyn/ContentDisplay/CredentialsInput.class b/target/classes/xyz/thastertyn/ContentDisplay/CredentialsInput.class deleted file mode 100644 index 7fcd5d0..0000000 Binary files a/target/classes/xyz/thastertyn/ContentDisplay/CredentialsInput.class and /dev/null differ diff --git a/target/classes/xyz/thastertyn/ContentDisplay/LoginController.class b/target/classes/xyz/thastertyn/ContentDisplay/LoginController.class deleted file mode 100644 index b521cd9..0000000 Binary files a/target/classes/xyz/thastertyn/ContentDisplay/LoginController.class and /dev/null differ diff --git a/target/classes/xyz/thastertyn/ContentDisplay/MainWindow.class b/target/classes/xyz/thastertyn/ContentDisplay/MainWindow.class deleted file mode 100644 index cec5373..0000000 Binary files a/target/classes/xyz/thastertyn/ContentDisplay/MainWindow.class and /dev/null differ diff --git a/target/classes/xyz/thastertyn/ContentDisplay/WindowSwitchListener.class b/target/classes/xyz/thastertyn/ContentDisplay/WindowSwitchListener.class deleted file mode 100644 index 5e06dfc..0000000 Binary files a/target/classes/xyz/thastertyn/ContentDisplay/WindowSwitchListener.class and /dev/null differ diff --git a/target/classes/xyz/thastertyn/JecnaParse/Dochazka.class b/target/classes/xyz/thastertyn/JecnaParse/Dochazka.class deleted file mode 100644 index 1be59ec..0000000 Binary files a/target/classes/xyz/thastertyn/JecnaParse/Dochazka.class and /dev/null differ diff --git a/target/classes/xyz/thastertyn/JecnaParse/Downloader.class b/target/classes/xyz/thastertyn/JecnaParse/Downloader.class deleted file mode 100644 index 1135a57..0000000 Binary files a/target/classes/xyz/thastertyn/JecnaParse/Downloader.class and /dev/null differ diff --git a/target/classes/xyz/thastertyn/JecnaParse/Jidelna.class b/target/classes/xyz/thastertyn/JecnaParse/Jidelna.class deleted file mode 100644 index 365e7f2..0000000 Binary files a/target/classes/xyz/thastertyn/JecnaParse/Jidelna.class and /dev/null differ diff --git a/target/classes/xyz/thastertyn/JecnaParse/Login.class b/target/classes/xyz/thastertyn/JecnaParse/Login.class deleted file mode 100644 index 83f6c19..0000000 Binary files a/target/classes/xyz/thastertyn/JecnaParse/Login.class and /dev/null differ diff --git a/target/classes/xyz/thastertyn/JecnaParse/OmluvnyList.class b/target/classes/xyz/thastertyn/JecnaParse/OmluvnyList.class deleted file mode 100644 index 4bc779b..0000000 Binary files a/target/classes/xyz/thastertyn/JecnaParse/OmluvnyList.class and /dev/null differ diff --git a/target/classes/xyz/thastertyn/JecnaParse/Rozvrh.class b/target/classes/xyz/thastertyn/JecnaParse/Rozvrh.class deleted file mode 100644 index ea187f9..0000000 Binary files a/target/classes/xyz/thastertyn/JecnaParse/Rozvrh.class and /dev/null differ diff --git a/target/classes/xyz/thastertyn/JecnaParse/Sdeleni.class b/target/classes/xyz/thastertyn/JecnaParse/Sdeleni.class deleted file mode 100644 index 22ea66e..0000000 Binary files a/target/classes/xyz/thastertyn/JecnaParse/Sdeleni.class and /dev/null differ diff --git a/target/classes/xyz/thastertyn/JecnaParse/Znamky.class b/target/classes/xyz/thastertyn/JecnaParse/Znamky.class deleted file mode 100644 index e8a058b..0000000 Binary files a/target/classes/xyz/thastertyn/JecnaParse/Znamky.class and /dev/null differ diff --git a/target/classes/xyz/thastertyn/Tuple/Pair.class b/target/classes/xyz/thastertyn/Tuple/Pair.class deleted file mode 100644 index 7b59897..0000000 Binary files a/target/classes/xyz/thastertyn/Tuple/Pair.class and /dev/null differ diff --git a/target/test-classes/xyz/thastertyn/AppTest.class b/target/test-classes/xyz/thastertyn/AppTest.class deleted file mode 100644 index e343e48..0000000 Binary files a/target/test-classes/xyz/thastertyn/AppTest.class and /dev/null differ