Commit ea49001f authored by Christos Christodoulopoulos's avatar Christos Christodoulopoulos
Browse files

Added the ability to add brief bookmark messages

parent a97fcab3
No preview for this file type
......@@ -21,7 +21,7 @@ public class JBCorpus {
private List<JBDataStructure> annotations;
private List<String> contexts;
private Map<Integer, List<JBDataStructure>> contextToAnnotation;
private List<String> bookmarks;
private Map<String, String> bookmarks;
private int lastEditIndex;
......@@ -40,7 +40,7 @@ public class JBCorpus {
annotations = new ArrayList<JBDataStructure>();
contexts = new ArrayList<String>();
contextToAnnotation = new HashMap<Integer, List<JBDataStructure>>();
bookmarks = new ArrayList<String>();
bookmarks = new HashMap<String, String>();
corpusFile = file;
currentAnnotationIndex = 0;
currentAnnotationOriginal = new JBDataStructure();
......@@ -65,7 +65,7 @@ public class JBCorpus {
contexts = corpora[0].contexts;
currentAnnotationIndex = 0;
currentAnnotationOriginal = new JBDataStructure();
bookmarks = new ArrayList<String>();
bookmarks = new HashMap<String, String>();
// Aggregate the annotations across corpora
contextToAnnotation = new HashMap<Integer, List<JBDataStructure>>();
......@@ -145,7 +145,8 @@ public class JBCorpus {
if (new File(bookmarksFile).exists()) {
in = new BufferedReader(new InputStreamReader(new FileInputStream(bookmarksFile)));
while ((line = in.readLine()) != null) {
bookmarks.add(line);
String[] parts = line.split("\\s+");
bookmarks.put(parts[0], parts[1]);
}
}
}
......@@ -173,8 +174,8 @@ public class JBCorpus {
out.close();
out = new FileWriter(file + bookmarksFileExt);
for (String bookmark : bookmarks) {
out.write(bookmark + "\n");
for (String bookmark : bookmarks.keySet()) {
out.write(bookmark + "\t" + bookmarks.get(bookmark) + "\n");
}
out.close();
}
......@@ -321,8 +322,8 @@ public class JBCorpus {
/**
* Adds a bookmark to the current annotation
*/
public void addBookmark() {
bookmarks.add(generateBookmarkKey());
public void addBookmark(String message) {
bookmarks.put(generateBookmarkKey(), message);
}
/**
......@@ -330,13 +331,13 @@ public class JBCorpus {
*/
public void removeBookmark() {
String key = generateBookmarkKey();
if (bookmarks.contains(key))
if (bookmarks.containsKey(key))
bookmarks.remove(key);
}
public boolean isBookmarked() {
String key = generateBookmarkKey();
return (bookmarks.contains(key));
return (bookmarks.containsKey(key));
}
private String generateBookmarkKey() {
......
......@@ -512,8 +512,12 @@ public class JBToolkit extends JFrame implements ActionListener, ItemListener, L
buttonBookmark.setText(WHITE_STAR);
}
else {
corpus.addBookmark();
buttonBookmark.setText(BLACK_STAR);
String response = JOptionPane.showInputDialog(null, "Enter a brief message for the bookmark", "Add bookmark",
JOptionPane.QUESTION_MESSAGE);
if (response != null) {
corpus.addBookmark(response);
buttonBookmark.setText(BLACK_STAR);
}
}
// Mark that the content has changed
if (!getTitle().startsWith(EDITED))
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment