/** * Clears the data to save. * * @see AnnotationUI#clearData() */ protected void clearData() { if (!init) { buildGUI(); init = true; } tagNames.clear(); existingTags.clear(); selectedValue = 0; if (!model.isMultiSelection()) selectedValue = model.getUserRating(); initialValue = 0; otherRating.setText(""); rating.removePropertyChangeListener(RatingComponent.RATE_PROPERTY, this); rating.setValue(selectedValue); rating.addPropertyChangeListener(RatingComponent.RATE_PROPERTY, this); publishedBox.setSelected(false); tagsPane.removeAll(); tagsDocList.clear(); DocComponent doc = new DocComponent(null, model); tagsDocList.add(doc); tagsPane.add(doc); docPane.removeAll(); filesDocList.clear(); doc = new DocComponent(null, model); filesDocList.add(doc); docPane.add(doc); tagFlag = false; docFlag = false; // double h = TableLayout.PREFERRED; // TableLayout layout = (TableLayout) content.getLayout(); // layout.setRow(tagRow, h); content.revalidate(); content.repaint(); revalidate(); repaint(); }
/** * Overridden to lay out the rating. * * @see AnnotationUI#buildUI() */ protected void buildUI() { selectedValue = 0; String text = ""; if (!model.isMultiSelection()) { selectedValue = model.getUserRating(); int n = model.getRatingCount(); if (n > 0) { text += "(avg:" + model.getRatingAverage() + " | " + n + " vote"; if (n > 1) text += "s"; text += ")"; } } otherRating.setText(text); initialValue = selectedValue; rating.setValue(selectedValue); publishedBox.setSelected(model.hasBeenPublished()); // Add attachments Collection l = model.getAttachments(); int count = 0; /* List v = null; if (l != null) { v = new ArrayList(); Iterator k = l.iterator(); FileAnnotationData data; boolean b = false; while (k.hasNext()) { data = (FileAnnotationData) k.next(); b = isEditorFile(data.getFileName()); if (!b) b = isEditorFile(data.getNameSpace()); if (!b) v.add(data); } count += v.size(); } */ // Viewed by if (!model.isMultiSelection()) { l = model.getTags(); if (l != null) count += l.size(); layoutTags(l); l = model.getAttachments(); if (l != null) count += l.size(); layoutAttachments(l); } else { layoutTags(null); layoutAttachments(null); } filterButton.setEnabled(count > 0); // Allow to handle annotation. boolean enabled = model.canAnnotate(); if (enabled && model.isMultiSelection()) { enabled = !model.isAcrossGroups(); } rating.setEnabled(enabled); addTagsButton.setEnabled(enabled); addDocsButton.setEnabled(enabled); enabled = model.canDeleteAnnotationLink(); removeTagsButton.setEnabled(enabled); removeDocsButton.setEnabled(enabled); enabled = model.canDelete(); // to be reviewed unrateButton.setEnabled(enabled); buildGUI(); }