Skip to content
This repository has been archived by the owner on Oct 29, 2021. It is now read-only.

Commit

Permalink
Fix edit-pane overflow, make combobox more obvious on startup
Browse files Browse the repository at this point in the history
  • Loading branch information
morinted committed May 9, 2014
1 parent f47afa9 commit e38434b
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 45 deletions.
2 changes: 1 addition & 1 deletion schedule-generator/ca/uottawa/schedule/Course.java
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ public List<String> getSemesters() {

public List<CourseSelection> getCourseSelections() {
List<CourseSelection> selections = new ArrayList<CourseSelection>();
//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()) {
Expand Down
40 changes: 0 additions & 40 deletions schedule-generator/ca/uottawa/schedule/courseCodes.csv.small

This file was deleted.

46 changes: 42 additions & 4 deletions schedule-generator/ca/uottawa/ui/ClientGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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..."));
Expand Down Expand Up @@ -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);
}

/**
Expand Down Expand Up @@ -735,11 +749,16 @@ public String getSemester(List<String> 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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit e38434b

Please sign in to comment.