Changeset 958
- Timestamp:
- 01/14/11 23:59:28 (2 years ago)
- Location:
- trunk
- Files:
-
- 7 modified
- 1 moved
-
data/codehelper/commands.xml (modified) (1 diff)
-
src/jlatexeditor/codehelper/BackgroundParser.java (modified) (9 diffs)
-
src/jlatexeditor/codehelper/BibParser.java (modified) (5 diffs)
-
src/jlatexeditor/codehelper/JumpTo.java (modified) (1 diff)
-
src/jlatexeditor/JLatexEditorJFrame.java (modified) (1 diff)
-
src/jlatexeditor/tools/SVN.java (modified) (3 diffs)
-
src/sce/codehelper/CodeHelperPane.java (modified) (4 diffs)
-
src/util/Tuple.java (moved) (moved from trunk/src/util/Pair.java) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/data/codehelper/commands.xml
r904 r958 136 136 137 137 <command name="\bibliography" usage="\bibliography{@file@}" hint="set bibliography file"> 138 <argument name="file" value="" completion="true" hint="filename of the bibliography file"/>138 <argument name="file" type="file" value="" completion="true" hint="filename of the bibliography file"/> 139 139 </command> 140 140 -
trunk/src/jlatexeditor/codehelper/BackgroundParser.java
r943 r958 27 27 28 28 private long bibModified = 0; 29 private ArrayList< BibEntry> bibEntries = new ArrayList<BibEntry>();29 private ArrayList<FilePos<BibEntry>> bibEntries = new ArrayList<FilePos<BibEntry>>(); 30 30 31 31 private HashSet<File> files = new HashSet<File>(); … … 35 35 private Trie<FilePos> labelDefs = new Trie<FilePos>(); 36 36 private Trie<FilePos> labelRefs = new Trie<FilePos>(); 37 private Trie< BibEntry> cites = new Trie<BibEntry>();37 private Trie<FilePos<BibEntry>> cites = new Trie<FilePos<BibEntry>>(); 38 38 39 39 private DefaultTreeModel structure = new DefaultTreeModel(new DefaultMutableTreeNode()); … … 47 47 } 48 48 49 public ArrayList< BibEntry> getBibEntries() {49 public ArrayList<FilePos<BibEntry>> getBibEntries() { 50 50 return bibEntries; 51 51 } … … 71 71 } 72 72 73 public Trie< BibEntry> getCites() {73 public Trie<FilePos<BibEntry>> getCites() { 74 74 return cites; 75 75 } … … 279 279 280 280 bibEntries = BibParser.parseBib(bibFile); 281 cites = new Trie< BibEntry>();282 for ( BibEntrybibEntry : bibEntries) {283 cites.add(bibEntry.get EntryName(), bibEntry);281 cites = new Trie<FilePos<BibEntry>>(); 282 for (FilePos<BibEntry> bibEntry : bibEntries) { 283 cites.add(bibEntry.getName(), bibEntry); 284 284 } 285 285 } … … 289 289 ArrayList<BibEntry> entries = new ArrayList<BibEntry>(); 290 290 291 for ( BibEntryentry : bibEntries) {291 for (FilePos<BibEntry> entry : bibEntries) { 292 292 boolean all = true; 293 293 for (String key : keys) { 294 if (entry.get Text().toLowerCase().indexOf(key) == -1) {294 if (entry.getElement().getText().toLowerCase().indexOf(key) == -1) { 295 295 all = false; 296 296 break; 297 297 } 298 298 } 299 if (all) entries.add(entry );299 if (all) entries.add(entry.getElement()); 300 300 } 301 301 … … 329 329 } 330 330 331 public static class FilePos extends DefaultMutableTreeNode {331 public static class FilePos<E> extends DefaultMutableTreeNode { 332 332 private String name; 333 333 334 334 private String file; 335 335 private int lineNr; 336 337 private E element; 336 338 337 339 public FilePos(String name, String file, int lineNr) { … … 341 343 } 342 344 345 public FilePos(String name, String file, int lineNr, E element) { 346 super(element); 347 this.name = name; 348 this.file = file; 349 this.lineNr = lineNr; 350 this.element = element; 351 } 352 343 353 public String getName() { 344 354 return name; … … 351 361 public int getLineNr() { 352 362 return lineNr; 363 } 364 365 public E getElement() { 366 return element; 353 367 } 354 368 -
trunk/src/jlatexeditor/codehelper/BibParser.java
r744 r958 12 12 */ 13 13 public class BibParser { 14 public static ArrayList<B ibEntry> parseBib(File file) {15 ArrayList<B ibEntry> results = new ArrayList<BibEntry>();14 public static ArrayList<BackgroundParser.FilePos<BibEntry>> parseBib(File file) { 15 ArrayList<BackgroundParser.FilePos<BibEntry>> results = new ArrayList<BackgroundParser.FilePos<BibEntry>>(); 16 16 17 17 String bib; … … 22 22 } 23 23 24 int lineNr = 0; 25 int lastAt = 0; 24 26 int at = -1; 25 27 while ((at = bib.indexOf("@", at + 1)) != -1) { 28 lineNr += countNewLinesBetween(bib, lastAt, at); 29 26 30 int openBracket = bib.indexOf('{', at); 27 31 if (openBracket == -1) break; … … 36 40 37 41 BibEntry entry = new BibEntry(); 42 BackgroundParser.FilePos<BibEntry> filePos = new BackgroundParser.FilePos<BibEntry>(name, file.getAbsolutePath(), lineNr, entry); 38 43 39 44 int index = comma + 1; … … 60 65 entry.getYear() 61 66 ); 62 results.add(entry); 67 results.add(filePos); 68 69 lastAt = at; 63 70 } 64 71 … … 66 73 } 67 74 68 private static String removeBraces(String string) { 75 private static int countNewLinesBetween(String bib, int start, int end) { 76 int count = 0; 77 for (int i = start; i < end; i++) { 78 if (bib.charAt(i) == '\n') count++; 79 } 80 return count; 81 } 82 83 private static String removeBraces(String string) { 69 84 if (string.startsWith("{") || string.startsWith("\"")) string = string.substring(1); 70 85 if (string.endsWith("}") || string.endsWith("\"")) string = string.substring(0, string.length() - 1); -
trunk/src/jlatexeditor/codehelper/JumpTo.java
r898 r958 86 86 return; 87 87 } 88 } else 89 if (command.equals("cite")) { 90 BackgroundParser.FilePos filePos = backgroundParser.getCites().get(word.word); 91 if (filePos != null) { 92 jLatexEditorJFrame.open(new FileDoc(new File(filePos.getFile())), filePos.getLineNr()); 93 return; 94 } 88 95 } 89 96 } -
trunk/src/jlatexeditor/JLatexEditorJFrame.java
r955 r958 1213 1213 ""); 1214 1214 if (message != null) { 1215 Pair<Boolean, String> result = null;1215 Tuple<Boolean, String> result = null; 1216 1216 try { 1217 1217 result = SVN.getInstance().commit(getMainEditor().getFile().getParentFile(), message); -
trunk/src/jlatexeditor/tools/SVN.java
r835 r958 1 1 package jlatexeditor.tools; 2 2 3 import util. Pair;3 import util.Tuple; 4 4 import util.ProcessUtil; 5 5 import util.StreamUtils; … … 62 62 } 63 63 64 public synchronized Pair<Boolean, String> commit(File dir, String message) throws Exception {64 public synchronized Tuple<Boolean, String> commit(File dir, String message) throws Exception { 65 65 message = message.replace('"', ' '); 66 66 message = message.replace('\\', ' '); … … 92 92 checkProcessResult(svn, "SVN update"); 93 93 94 return new Pair<Boolean, String>(success, builder.toString());94 return new Tuple<Boolean, String>(success, builder.toString()); 95 95 } 96 96 -
trunk/src/sce/codehelper/CodeHelperPane.java
r941 r958 2 2 3 3 import sce.component.*; 4 import util. Pair;4 import util.Tuple; 5 5 6 6 import javax.swing.*; … … 224 224 225 225 // set the caret position and remove it from template 226 Pair<String, SCEDocumentPosition> pair = getTransformedTemplate(templateWithAt, arguments, row, column);226 Tuple<String, SCEDocumentPosition> pair = getTransformedTemplate(templateWithAt, arguments, row, column); 227 227 templateWithAt = pair.first; 228 228 … … 303 303 } 304 304 305 private Pair<String, SCEDocumentPosition> getTransformedTemplate(String templateWithAt, ArrayList<CHCommandArgument> arguments, int row, int column) {305 private Tuple<String, SCEDocumentPosition> getTransformedTemplate(String templateWithAt, ArrayList<CHCommandArgument> arguments, int row, int column) { 306 306 int cursorIndex = templateWithAt.lastIndexOf("@|@"); 307 307 if (cursorIndex != -1) { … … 324 324 } 325 325 326 return new Pair<String,SCEDocumentPosition>(templateWithAt, document.createDocumentPosition(caret_row, caret_column));326 return new Tuple<String,SCEDocumentPosition>(templateWithAt, document.createDocumentPosition(caret_row, caret_column)); 327 327 } 328 328 -
trunk/src/util/Tuple.java
r744 r958 1 1 package util; 2 2 3 public class Pair<S, T> {3 public class Tuple<S, T> { 4 4 public S first; 5 5 public T second; 6 6 7 public Pair(S first, T second) {7 public Tuple(S first, T second) { 8 8 this.first = first; 9 9 this.second = second;
![(please configure the [header_logo] section in trac.ini)](http://jlatexeditor.endrullis.de/chrome/site/logo.png)