-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implemented error console in JavaFX #1383
Conversation
Please adress the Language-key related errors, The first build failed because there were still some obsolete keys... |
@tobiasdiez @Siedlerchr slowly, slowly... let the students check this PR first and wait until it is labeled with "ready-for-review" 😉 |
while (true) { | ||
Thread.sleep(REFRESH_RATE); | ||
|
||
// IMO this is a really, really bad way to do this, but a saw no other way since the stage is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: don't use a refresh thread but data binding.
So you add a property to ErrorConsoleViewModel to return a FX-observable list of output/errormessages which are always up-to-date and then bind the text property of the textarea to it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how can i bind the observable list to this outputStream. The problem is that all output gets written to a stream which in my opinion is incompatibe with a observable List.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can register a custom PrintStream as a TeeStream, similar to what is done in
return new TeeStream(consoleOut, systemOut); |
This custom PrintStream writes to a (observable) list.
new PrintStream(System.out) {
List<String> messages = new blabla();
@Override
public void println(String s) {
messages.add(s);
super.println(s); //needed?
}
Current coverage is 28.39% (diff: 10.52%)@@ javafx #1383 diff @@
==========================================
Files 705 705
Lines 46412 46332 -80
Methods 0 0
Messages 0 0
Branches 7637 7639 +2
==========================================
+ Hits 5002 13154 +8152
+ Misses 40963 32053 -8910
- Partials 447 1125 +678
|
I am having trouble to hide the developer information. The css file probably needs some changes, I tried to set the visibilty but that didn't work out. @tobiasdiez Do you have some tips to handle this? |
Sorry for my later answer. Normally you do this by using a PseudoClass I would however only use the PseudoClasses for real styling purposes, for example For debugging UI issues, the tool Scenic View is very helpful (http://fxexperience.com/scenic-view/). I had some problems with running it separately and bind it to JabRef. However, adding it to the dependencies (Project Structure -> Modules -> Dependencies -> Add) and then invoke |
|
||
developerInformation.bind(developerButton.selectedProperty()); | ||
developerInformation.addListener((observable, oldValue, newValue) -> { | ||
ObservableList<ObservableMessageWithPriority> emptyList = FXCollections.observableArrayList(Collections.EMPTY_LIST); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there is no need to replace the items in allMessage
, just use filteredData.setPredicate
. Have a look at http://stackoverflow.com/questions/30915007/javafx-filteredlist-filtering-based-on-property-of-items-in-the-list
@tobiasdiez |
Sorry but I don't understand where your problem is. It looks like it prints the Test Cache message as well as the (first line of) the error stack trace. The system.out is ignored as I would have expected since you hide low priority messages. |
Hi @tobiasdiez ,
Thx you |
this.outStream = out2; | ||
this.priority = priority; | ||
|
||
} | ||
|
||
public TeeStream(PrintStream out1, PrintStream out2) { | ||
super(out1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Call the other constructor using this(...) here.
Thanks for the additional description. I added a comment to ErrorConsoleViewModel which should help you to solve the problem. For the next time, please try to add some tests first. There were quite a few things which could have been wrong:
The first 3 options could have been ruled out by automatic tests. It would be good if you could add corresponding tests (which also require some positve refactoring, like making |
There are three solution for this problem with create issue function:
After close or click on OK Button. The default browser will open and show create issue site with default title (automatic bug report-"current time with this format yyyyMMddHHmmss") and a default issue description (JabRef version, operating system version, Java version). During the show of this create issue site, the log and exception information will be saved in clipboard. So the user can be paste it for detail information in issue description. (take a look in create issue in default browser with paste detail information screenshot) |
Which one did you implement? |
I really like the copied-to-clipboard-solution. Its simple yet effective. |
Can you please post a new screenshot of the actual look? |
this.message = message; | ||
} | ||
|
||
public void setIsFiltered(boolean isFiltered) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this still used?
Thanks for the update. The code looks better now. I have just a few more remarks, then this can be merged. @koppor pls do the final review |
/** | ||
* This LogMessage will be save all message entries in a ListProperty. | ||
* <p></p> | ||
* This list will be use late in ErrorConsoleViewModel to filter message after their priority |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix English. Proposal:
This call saves all messages in a list. The list is used in ErrorConsoleViewModel to filter messages according to their priority.
@tobiasdiez @koppor: feedbacks are done. Only this teestream thing, i am not sure how to fix it 😄 |
Maybe someone else from @JabRef/stupro can help. @bartsch-dev maybe? It's a kind of architectural decision. |
Try to use StreamEavesdropper instead of TeeStream |
@tobiasdiez Is this what you meant with moving the code to the streamEavesdropper? |
super.write(buf, off, len); | ||
String s = new String(buf, off, len); | ||
addToLog(s, MessageType.EXCEPTION | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Formatting.
); | ||
} | ||
}; | ||
return new TeeStream(consoleErr, systemErr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand it correctly, then everything from systemErr is also written to consoleErr. With your implementation all messages to consoleErr are posted to the cache (addToLog
).
So far so good. But they also get posted as well as to the underlying errByteStream
, which is no longer required (is it?). Thus could you remove the byte stream part?
Yes this looks better.
And you added:
Could you refactor the code so that everything is only written ̀to the internal list of Appendum for myself: |
* <li>MessageType.EXCEPTION is define for exception entries | ||
* </ul> | ||
*/ | ||
public class LogMessage { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please replace this class by org.apache.logging.log4j.core.LogEvent
and Log4jLogEvent.newBuilder().setMessage(message).build()
if you need to convert a string to the LogEvent
.
@tobiasdiez I have refactored and have done feedback. Hope it will be merged this time 😄 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not quite mergable but only a few final remarks. Good work.
@@ -59,12 +66,14 @@ public void show() { | |||
errorConsole.setDialogPane(pane); | |||
errorConsole.setResizable(true); | |||
errorConsole.show(); | |||
Log log = LogFactory.getLog(this.getClass()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this was for test purposes, right? Please remove it.
setText(logMessage.getMessage().toString()); | ||
|
||
Level prio = logMessage.getLevel(); | ||
if (prio.equals(ERROR)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pls use a switch statement here and show an info by default (instead of nothing with null/null
)
* @param message message of log event | ||
* @param priority level of log event | ||
*/ | ||
private void addToLog(String message, Level priority) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please go through the code that all priority
and prio
are properly renamed to level
.
// stack traces logged by 'Log.error("message"), e' will be split by new lines so we can create a new log event for each line as 'e.printStackTrace()' would do. | ||
if (event.getLevel() == Level.ERROR) { | ||
Arrays.asList(message.split("\n")).stream().filter(s -> !s.isEmpty()).forEach(log -> { | ||
LogEvent messageWithPriority = Log4jLogEvent.newBuilder().setMessage(new SimpleMessage(log.replace("\n", ""))).setLevel(event.getLevel()).build(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this kind of message-rework really necessary?
I had the hope that here a simple LogMessages.getInstance().add(event)
would satisfy and then maybe use event.getMessage().getFormattedMessage()
in the view (d6c8eb1#diff-d08231c1b1e93f3d52d35f72f3b55821R112).
If this is not possible, please move the code to the view, i.e. determine there how a LogEvent should be displayed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tobiasdiez if i don't split this it will be show me not so nice in list view. It looks like this, because in append-method of GuiAppender I get only one LogEvent entry with all information by insert a log entry like Log.error (e). It is not like System.err:
And if i don't replace System.lineseparator with "" then i will get 2 line each list cell.
That is the reason, why i have reformat this log event entry. That look better. 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. What happens if you use setText(logMessage.getMessage().getFormattedMessage()) to show the message instead of setText(logMessage.getMessage().toString()) ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have tried it, but i get the same effect like that screenshot 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, then keep your code but move it to the view if this is possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I have tried it, but it doesn't let me extract to view. 😢. Other feedback I have done it 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, then we leave it like that for the moment and maybe fix it later.
This is the error console in JabRef being implemented in JavaFX. The Console is highly flexible in positioning and styling its components through a fxml and corresponding css stylesheet.
Also to show better the error console content (Log, Output, Exception), i have allowed to resize error console windows manually.
PS:
The error console should be resizable #872: have done