/** * Updates the screen to be consistent with the internal ClientDataModel representation. * * @param t String representing the title of the document. Is guaranteed not to be null. */ protected void updateGUI(Integer d) { if (currentDocID == d) { // document changed is document being worked on if (dm.hasDoc(d)) currentDoc = dm.getDoc(d); else { // current document has been deleted currentDoc = new DefaultStyledDocument(); } textPane.setStyledDocument(currentDoc); } else { // document changed is not being worked on if (docIDList.contains(d) && !dm.hasDoc(d)) { // remove deleted document from selector int positionOfDoc = docIDList.indexOf(d); docSelect.remove(positionOfDoc); docIDList.remove(positionOfDoc); } else if (!docIDList.contains(d) && dm.hasDoc(d)) { // put in new document into selector docIDList.add(d); docSelect.addItem(dm.getTitle(d)); } } }
/** * Ensures that the data model reflects the current title and content of the document being * displayed */ private void updateDocToDataModel() { dm.replaceDoc(currentDocID, currentTitle, currentDoc); }