Omluvny list, odstraneny .class soubory, pokus o taby
This commit is contained in:
1 parent
ccbaef8e5b
commit
c650fc5247
28 files changed
+131
-41
No files matched your search
@@ -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);
|
||||
}
|
||||
@@ -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'");
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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<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)
|
||||
{
|
||||
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
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in new issue
Block a user