troizet commented on code in PR #6241:
URL: https://github.com/apache/netbeans/pull/6241#discussion_r1272334660
##########
php/php.dbgp/src/org/netbeans/modules/php/dbgp/ui/DbgpLineBreakpointCustomizerPanel.java:
##########
@@ -367,49 +398,77 @@ public boolean cancel() {
@NbBundle.Messages({
"CustomizerController.invalid.file=Existing file must be set.",
- "CustomizerController.invalid.line=Valid line number must be set."
+ "CustomizerController.non.php.file=PHP source file is expected.",
+ "CustomizerController.invalid.line=Valid line number must be set.",
+ "# {0} - entered line number",
+ "# {1} - maximum line number in file",
+ "CustomizerController.too.big.line.number=The line number {0} is
too big. Maximum line number is {1}."
})
- @Override
- public boolean isValid() {
+ public void checkValid() {
boolean isValid = true;
// file
String fileName = fileTextField.getText();
if (fileName == null || fileName.trim().length() == 0) {
setErrorMessage(Bundle.CustomizerController_invalid_file());
- return false;
+ setValid(false);
+ return;
}
File file = new File(fileName.trim());
if (!file.exists()) {
setErrorMessage(Bundle.CustomizerController_invalid_file());
- return false;
+ setValid(false);
+ return;
}
FileObject fileObject = FileUtil.toFileObject(file);
if (fileObject == null) {
setErrorMessage(Bundle.CustomizerController_invalid_file());
- return false;
+ setValid(false);
+ return;
+ }
+ else if (!FileUtils.isPhpFile(fileObject)) {
+ setErrorMessage(Bundle.CustomizerController_non_php_file());
+ setValid(false);
+ return;
}
// line number
String lineNumberString = lineNumberTextField.getText();
if (lineNumberString == null || lineNumberString.trim().length()
== 0) {
setErrorMessage(Bundle.CustomizerController_invalid_line());
- return false;
+ setValid(false);
+ return;
}
try {
int lineNumber =
Integer.parseInt(lineNumberTextField.getText());
if (lineNumber <= 0) {
setErrorMessage(Bundle.CustomizerController_invalid_line());
- return false;
+ setValid(false);
+ return;
+ }
+ int maxLine = findNumLines(fileObject);
+ if (maxLine == 0) { // Not found
+ maxLine = Integer.MAX_VALUE - 1; // Not to bother the user
when we did not find it
+ }
+ if (lineNumber > maxLine + 1) {
Review Comment:
It seems that NbDocument.findLineNumber() always returns a line number one
less than the actual line number. I took this code unchanged from
https://github.com/apache/netbeans/blob/master/java/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/breakpoints/LineBreakpointPanel.java
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists