From e38434b32122743cc224ecc795ddea6491fa70d2 Mon Sep 17 00:00:00 2001 From: Ted Morin Date: Fri, 9 May 2014 16:29:29 -0400 Subject: [PATCH] Fix edit-pane overflow, make combobox more obvious on startup --- .../ca/uottawa/schedule/Course.java | 2 +- .../ca/uottawa/schedule/courseCodes.csv.small | 40 ---------------- .../ca/uottawa/ui/ClientGUI.java | 46 +++++++++++++++++-- 3 files changed, 43 insertions(+), 45 deletions(-) delete mode 100644 schedule-generator/ca/uottawa/schedule/courseCodes.csv.small diff --git a/schedule-generator/ca/uottawa/schedule/Course.java b/schedule-generator/ca/uottawa/schedule/Course.java index d269eeb..be5fc4c 100644 --- a/schedule-generator/ca/uottawa/schedule/Course.java +++ b/schedule-generator/ca/uottawa/schedule/Course.java @@ -237,7 +237,7 @@ public List getSemesters() { public List getCourseSelections() { List selections = new ArrayList(); - //Basicaly, we need to generate as many possible course selections for this course. + //Basically, we need to generate as many possible course selections for this course. //Each section and activity have a boolean selected which will help in this process. for (Section s : sections) { if (s.isSelected()) { diff --git a/schedule-generator/ca/uottawa/schedule/courseCodes.csv.small b/schedule-generator/ca/uottawa/schedule/courseCodes.csv.small deleted file mode 100644 index 4028111..0000000 --- a/schedule-generator/ca/uottawa/schedule/courseCodes.csv.small +++ /dev/null @@ -1,40 +0,0 @@ -ECO1192 - Engineering Economics,,,,,,,, -20139,ECO1192A,LEC,1,T,19:00,22:00,MRN AUD,Claude Th‚oret -20141,ECO1192B,LEC,1,R,19:00,22:00,MNT 202,N/A -ADM1300 - Intro. To Business Management,,,,,,,, -20139,ADM1300A 1DGD,LEC,1,W,10:00,11:30,DMS 1160,David Delcorde -,,LEC,2,F,8:30,10:00,DMS 1160,David Delcorde -,,DGD,1,T,14:30,16:00,THN 124,N/A -,,DGD,2,R,16:00,17:30,FSS 7035,N/A -,,DGD,3,T,17:30,19:00,FSS 1005,N/A -,,DGD,4,T,14:30,16:00,SMD 430,N/A -,,DGD,5,T,10:00,11:30,SMD 430,N/A -,,DGD,6,F,13:00,14:30,MRT 251,N/A -,ADM1300B 1DGD,LEC,1,T,19:00,22:00,STE B0138,Matthew Archibald -,,DGD,1,R,16:00,17:30,FTX 136,Matthew Archibald -,,DGD,2,F,17:30,19:00,FSS 1005,Matthew Archibald -,,DGD,3,R,19:00,20:30,SMD 402,Matthew Archibald -,,DGD,4,T,16:00,17:30,BRS 314,Matthew Archibald -,,DGD,5,W,16:00,17:30,CBY E016,Matthew Archibald -,,DGD,6,R,16:00,17:30,SMD 429,Matthew Archibald -,ADM1300C 1DGD,LEC,1,R,16:00,19:00,DMS 1160,Gerard Brathwaite-Sturgeon -,,DGD,1,W,11:30,13:00,FSS 4012,N/A -,,DGD,2,W,13:00,14:30,LMX 124,N/A -,,DGD,3,W,16:00,17:30,FSS 4012,N/A -,,DGD,4,T,14:30,16:00,LMX 124,N/A -,,DGD,5,F,10:00,11:30,FTX 137,N/A -,,DGD,6,M,10:00,11:30,STE F0126,N/A -,ADM1300D 1DGD,LEC,1,M,8:30,10:00,DMS 1160,Matthew Archibald -,,LEC,2,R,10:00,11:30,DMS 1160,N/A -,,DGD,1,R,16:00,17:30,DMS 8161,N/A -,,DGD,2,T,8:30,10:00,MNT 204,N/A -,,DGD,3,W,11:30,13:00,SMD 330,N/A -,,DGD,4,F,11:30,13:00,FSS 4012,N/A -,,DGD,5,R,11:30,13:00,FSS 6032,N/A -,,DGD,6,M,16:00,17:30,FTX 136,N/A -20141,ADM1300M 1DGD,LEC,1,M,10:00,11:30,DMS 1150,David Delcorde -,,LEC,2,W,8:30,10:00,DMS 1150,David Delcorde -,,DGD,1,W,13:00,14:30,DMS 11161,N/A -,,DGD,2,W,14:30,16:00,DMS 10161,N/A -,,DGD,3,R,14:30,16:00,BRS 314,N/A -,,DGD,4,T,14:30,16:00,TBT 327,N/A \ No newline at end of file diff --git a/schedule-generator/ca/uottawa/ui/ClientGUI.java b/schedule-generator/ca/uottawa/ui/ClientGUI.java index c0a69a6..d0f048f 100644 --- a/schedule-generator/ca/uottawa/ui/ClientGUI.java +++ b/schedule-generator/ca/uottawa/ui/ClientGUI.java @@ -45,6 +45,7 @@ public class ClientGUI implements ClientIF, ActionListener, DocumentListener, It private static final int DAY = 106; //110 private static final int DAY_MARGIN = 24; //25 private static final int LIST_ROWS = 5; + private static final int EDIT_HEIGHT = 500; //Dialog edit height. //GUI variables //The top-level frame @@ -96,6 +97,20 @@ public ClientGUI(String title, String host, int port) { fntMain = new Font("SansSerif", Font.BOLD, 15); fntActivity = new Font("SansSerif", Font.BOLD, 13); + + //Freeze items + btnAdd.setEnabled(false); + txtSearch.setEditable(false); + chkOptional.setEnabled(false); + btnClearAll.setEnabled(false); + btnRemove.setEnabled(false); + btnIncK.setEnabled(false); + btnDecK.setEnabled(false); + chkIgnoreExtras.setEnabled(false); + cboSortOrder.setEnabled(false); + btnGenerate.setEnabled(false); + btnEdit.setEnabled(false); + //Make loading screen. frmLoading = new JFrame("Loading..."); frmLoading.add(new JTextArea("Connecting to server...")); @@ -531,8 +546,7 @@ public static void main(String[] args) { { port = DEFAULT_PORT; //Else default to the default port. } - new ClientGUI("uOttawa Schedule Generator", host, port); - + new ClientGUI("uOttawa Schedule Generator - v1.0.0", host, port); } /** @@ -735,11 +749,16 @@ public String getSemester(List semesters) { } cboSemester.addItem(month + " " + year); } + cboSemester.setSelectedIndex(-1); frmLoading.setVisible(false); + //We'll add a border to emphasize the starting point, for now. + paneSemester.setBorder(BorderFactory.createLineBorder(Color.black, 2)); while (cboSemester.getSelectedIndex() == -1) { - //wait. + } + paneSemester.setBorder(null); + btnAdd.setEnabled(true); txtSearch.setEditable(true); chkOptional.setEnabled(true); @@ -955,7 +974,8 @@ public void editCourse(Course edit, String semester) { JFrame editFrame = new JFrame("Edit Course"); editFrame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); editFrame.setResizable(false); - Container pane = (editFrame.getContentPane()); + Container contentPane = (editFrame.getContentPane()); + Container pane = new Container(); pane.setLayout(new BoxLayout(pane, BoxLayout.Y_AXIS)); btnPrint.setEnabled(false); @@ -1058,6 +1078,24 @@ public void actionPerformed(ActionEvent e) { } } pane.add(Box.createRigidArea(new Dimension(15, 15))); //Gives us some margins. + + //We are adding the contents to a scroll pane so that if there are many, many sections, we wrap to a set number of pixels. + JScrollPane scrollContent = new JScrollPane(pane); + scrollContent.getVerticalScrollBar().setUnitIncrement(16); + contentPane.add(scrollContent); + + Dimension preferred = editFrame.getPreferredSize(); + if (preferred.height > EDIT_HEIGHT) { + preferred.height = EDIT_HEIGHT; + preferred.width+=20; //This is to handle the extra width of the scrollbar. + } + + + editFrame.setPreferredSize(preferred); + + + + editFrame.pack(); editFrame.setLocationRelativeTo(frame); //Show the window. The window listener will evaluate when you close the window.