Lines 44-49
Link Here
|
44 |
* |
44 |
* |
45 |
* Contributor(s): Andrei Badea |
45 |
* Contributor(s): Andrei Badea |
46 |
* Petr Hrebejk |
46 |
* Petr Hrebejk |
|
|
47 |
* markiewb@netbeans.org |
47 |
*/ |
48 |
*/ |
48 |
|
49 |
|
49 |
package org.netbeans.modules.jumpto.file; |
50 |
package org.netbeans.modules.jumpto.file; |
Lines 70-75
Link Here
|
70 |
import java.util.Set; |
71 |
import java.util.Set; |
71 |
import java.util.logging.Level; |
72 |
import java.util.logging.Level; |
72 |
import java.util.logging.Logger; |
73 |
import java.util.logging.Logger; |
|
|
74 |
import java.util.regex.Matcher; |
73 |
import java.util.regex.Pattern; |
75 |
import java.util.regex.Pattern; |
74 |
import java.util.regex.PatternSyntaxException; |
76 |
import java.util.regex.PatternSyntaxException; |
75 |
import javax.swing.AbstractAction; |
77 |
import javax.swing.AbstractAction; |
Lines 139-150
Link Here
|
139 |
private FileSearchPanel panel; |
141 |
private FileSearchPanel panel; |
140 |
private Dimension initialDimension; |
142 |
private Dimension initialDimension; |
141 |
private Iterable<? extends FileProvider> providers; |
143 |
private Iterable<? extends FileProvider> providers; |
|
|
144 |
private final Pattern patternWithLineNumber; |
142 |
|
145 |
|
143 |
public FileSearchAction() { |
146 |
public FileSearchAction() { |
144 |
super( NbBundle.getMessage(FileSearchAction.class, "CTL_FileSearchAction") ); |
147 |
super( NbBundle.getMessage(FileSearchAction.class, "CTL_FileSearchAction") ); |
145 |
// XXX this should be in initialize()? |
148 |
// XXX this should be in initialize()? |
146 |
putValue("PopupMenuText", NbBundle.getBundle(FileSearchAction.class).getString("editor-popup-CTL_FileSearchAction")); // NOI18N |
149 |
putValue("PopupMenuText", NbBundle.getBundle(FileSearchAction.class).getString("editor-popup-CTL_FileSearchAction")); // NOI18N |
147 |
putValue("noIconInMenu", Boolean.TRUE); // NOI18N |
150 |
putValue("noIconInMenu", Boolean.TRUE); // NOI18N |
|
|
151 |
|
152 |
this.patternWithLineNumber = Pattern.compile("(.*):(\\d+)"); |
148 |
} |
153 |
} |
149 |
|
154 |
|
150 |
@Override |
155 |
@Override |
Lines 212-222
Link Here
|
212 |
else { |
217 |
else { |
213 |
nameKind = panel.isCaseSensitive() ? QuerySupport.Kind.PREFIX : QuerySupport.Kind.CASE_INSENSITIVE_PREFIX; |
218 |
nameKind = panel.isCaseSensitive() ? QuerySupport.Kind.PREFIX : QuerySupport.Kind.CASE_INSENSITIVE_PREFIX; |
214 |
} |
219 |
} |
|
|
220 |
|
221 |
|
222 |
//Extract linenumber from search text |
223 |
//Pattern is like 'My*Object.java:123' |
224 |
Matcher matcher = patternWithLineNumber.matcher(text); |
225 |
boolean endsWithLineNumber = matcher.matches(); |
226 |
int lineNr; |
227 |
if (endsWithLineNumber) |
228 |
{ |
229 |
text = matcher.group(1); |
230 |
try { |
231 |
lineNr = Integer.parseInt(matcher.group(2)); |
232 |
} catch (NumberFormatException numberFormatException) { |
233 |
//prevent non convertable numbers |
234 |
lineNr=-1; |
235 |
} |
236 |
} |
237 |
else { |
238 |
lineNr = -1; |
239 |
} |
215 |
|
240 |
|
216 |
// Compute in other thread |
241 |
// Compute in other thread |
217 |
|
242 |
|
218 |
synchronized( this ) { |
243 |
synchronized( this ) { |
219 |
running = new Worker(text , nameKind, panel.getCurrentProject()); |
244 |
running = new Worker(text , nameKind, panel.getCurrentProject(), lineNr); |
220 |
task = rp.post( running, 220); |
245 |
task = rp.post( running, 220); |
221 |
if ( panel.time != -1 ) { |
246 |
if ( panel.time != -1 ) { |
222 |
LOGGER.log( Level.FINE, "Worker posted after {0} ms.", System.currentTimeMillis() - panel.time ); |
247 |
LOGGER.log( Level.FINE, "Worker posted after {0} ms.", System.currentTimeMillis() - panel.time ); |
Lines 395-403
Link Here
|
395 |
private final QuerySupport.Kind searchType; |
420 |
private final QuerySupport.Kind searchType; |
396 |
private final Project currentProject; |
421 |
private final Project currentProject; |
397 |
private final long createTime; |
422 |
private final long createTime; |
|
|
423 |
private final int lineNr; |
398 |
|
424 |
|
399 |
public Worker(String text, QuerySupport.Kind searchType, Project currentProject) { |
425 |
public Worker(String text, QuerySupport.Kind searchType, Project currentProject, int lineNr) { |
400 |
this.text = text; |
426 |
this.text = text; |
|
|
427 |
this.lineNr = lineNr; |
401 |
this.searchType = searchType; |
428 |
this.searchType = searchType; |
402 |
this.currentProject = currentProject; |
429 |
this.currentProject = currentProject; |
403 |
this.createTime = System.currentTimeMillis(); |
430 |
this.createTime = System.currentTimeMillis(); |
Lines 516-522
Link Here
|
516 |
FileDescriptor fd = new FileDescription( |
543 |
FileDescriptor fd = new FileDescription( |
517 |
file, |
544 |
file, |
518 |
r.getRelativePath().substring(0, Math.max(r.getRelativePath().length() - file.getNameExt().length() - 1, 0)), |
545 |
r.getRelativePath().substring(0, Math.max(r.getRelativePath().length() - file.getNameExt().length() - 1, 0)), |
519 |
project); |
546 |
project, lineNr); |
520 |
FileProviderAccessor.getInstance().setFromCurrentProject(fd, preferred); |
547 |
FileProviderAccessor.getInstance().setFromCurrentProject(fd, preferred); |
521 |
files.add(fd); |
548 |
files.add(fd); |
522 |
LOGGER.log(Level.FINER, "Found: {0}, project={1}, currentProject={2}, preferred={3}", |
549 |
LOGGER.log(Level.FINER, "Found: {0}, project={1}, currentProject={2}, preferred={3}", |
Lines 599-605
Link Here
|
599 |
FileDescriptor fd = new FileDescription( |
626 |
FileDescriptor fd = new FileDescription( |
600 |
file, |
627 |
file, |
601 |
relativePath, |
628 |
relativePath, |
602 |
project |
629 |
project, lineNr |
603 |
); |
630 |
); |
604 |
FileProviderAccessor.getInstance().setFromCurrentProject(fd, preferred); |
631 |
FileProviderAccessor.getInstance().setFromCurrentProject(fd, preferred); |
605 |
files.add(fd); |
632 |
files.add(fd); |