-
-
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
Changes from 8 commits
02d25f1
9b8e932
cf785e5
89ed474
4092ecf
0466d00
221e555
0cbf8ec
cb146de
9b821d7
910d9a9
1b7eccd
0395b2c
d6c8eb1
76d72dc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -119,14 +119,14 @@ public static Optional<ButtonType> showCustomButtonDialogAndWait(AlertType type, | |
*/ | ||
public static Optional<ButtonType> showCustomDialogAndWait(String title, DialogPane contentPane, | ||
ButtonType... buttonTypes) { | ||
FXAlert alert = new FXAlert(AlertType.NONE, title); | ||
FXAlert alert = new FXAlert(AlertType.NONE, title, true); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
alert.setDialogPane(contentPane); | ||
alert.getButtonTypes().setAll(buttonTypes); | ||
return alert.showAndWait(); | ||
} | ||
|
||
private static FXAlert createDialog(AlertType type, String title, String content) { | ||
FXAlert alert = new FXAlert(type, title); | ||
FXAlert alert = new FXAlert(type, title, true); | ||
alert.setHeaderText(null); | ||
alert.setContentText(content); | ||
return alert; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
/* Copyright (C) 2016 JabRef contributors. | ||
This program is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation; either version 2 of the License, or | ||
(at your option) any later version. | ||
|
||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
|
||
You should have received a copy of the GNU General Public License along | ||
with this program; if not, write to the Free Software Foundation, Inc., | ||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
*/ | ||
package net.sf.jabref.gui.errorconsole; | ||
|
||
import javafx.collections.ObservableList; | ||
import javafx.fxml.FXML; | ||
import javafx.scene.control.Alert.AlertType; | ||
import javafx.scene.control.Button; | ||
import javafx.scene.control.ButtonBar; | ||
import javafx.scene.control.DialogPane; | ||
import javafx.scene.control.Label; | ||
import javafx.scene.control.ListCell; | ||
import javafx.scene.control.ListView; | ||
import javafx.scene.text.Text; | ||
import javafx.stage.Stage; | ||
import javafx.util.Callback; | ||
|
||
import net.sf.jabref.gui.FXAlert; | ||
import net.sf.jabref.gui.IconTheme; | ||
import net.sf.jabref.logic.error.LogMessageWithPriority; | ||
import net.sf.jabref.logic.error.MessagePriority; | ||
import net.sf.jabref.logic.l10n.Localization; | ||
import net.sf.jabref.logic.logging.LogMessage; | ||
|
||
import com.airhacks.afterburner.views.FXMLView; | ||
|
||
public class ErrorConsoleView extends FXMLView { | ||
|
||
private final ErrorConsoleViewModel errorViewModel = new ErrorConsoleViewModel(); | ||
|
||
@FXML | ||
private Button closeButton; | ||
@FXML | ||
private Button copyLogButton; | ||
@FXML | ||
private Button createIssueButton; | ||
@FXML | ||
private ListView<LogMessageWithPriority> allMessage; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add plural |
||
@FXML | ||
private Label descriptionLabel; | ||
|
||
public ErrorConsoleView() { | ||
super(); | ||
bundle = Localization.getMessages(); | ||
} | ||
|
||
public void show() { | ||
FXAlert errorConsole = new FXAlert(AlertType.ERROR, Localization.lang("Event log"), false); | ||
DialogPane pane = (DialogPane) this.getView(); | ||
errorConsole.setDialogPane(pane); | ||
errorConsole.setResizable(true); | ||
errorConsole.show(); | ||
} | ||
|
||
@FXML | ||
private void initialize() { | ||
ButtonBar.setButtonData(copyLogButton, ButtonBar.ButtonData.LEFT); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please move this to FXML: http://stackoverflow.com/a/32427404/873661 |
||
ButtonBar.setButtonData(createIssueButton, ButtonBar.ButtonData.LEFT); | ||
|
||
ObservableList<LogMessageWithPriority> masterData = LogMessage.getInstance().messagesProperty(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The view shouldn't know about the datasource (in this case |
||
listViewStyle(); | ||
allMessage.setItems(masterData); | ||
descriptionLabel.setGraphic(IconTheme.JabRefIcon.CONSOLE.getGraphicNode()); | ||
} | ||
|
||
@FXML | ||
private void copyLogButton() { | ||
errorViewModel.copyLog(); | ||
} | ||
|
||
@FXML | ||
private void createIssueButton() { | ||
errorViewModel.reportIssue(); | ||
} | ||
|
||
@FXML | ||
private void closeErrorDialog() { | ||
Stage stage = (Stage) closeButton.getScene().getWindow(); | ||
stage.close(); | ||
} | ||
|
||
/** | ||
* Style the list view with icon and message color | ||
*/ | ||
private void listViewStyle() { | ||
// Handler for listCell appearance (example for exception Cell) | ||
allMessage.setCellFactory( | ||
new Callback<ListView<LogMessageWithPriority>, ListCell<LogMessageWithPriority>>() { | ||
@Override | ||
public ListCell<LogMessageWithPriority> call( | ||
ListView<LogMessageWithPriority> listView) { | ||
return new ListCell<LogMessageWithPriority>() { | ||
|
||
@Override | ||
public void updateItem(LogMessageWithPriority logMessageWithPriority, boolean empty) { | ||
super.updateItem(logMessageWithPriority, empty); | ||
if (logMessageWithPriority != null) { | ||
setText(logMessageWithPriority.getMessage()); | ||
Text graphic = new Text(); | ||
graphic.getStyleClass().add("icon"); | ||
|
||
MessagePriority prio = logMessageWithPriority.getPriority(); | ||
switch (prio) { | ||
case HIGH: | ||
getStyleClass().add("exception"); | ||
graphic.setText(IconTheme.JabRefIcon.INTEGRITY_FAIL.getCode()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
break; | ||
case MEDIUM: | ||
getStyleClass().add("output"); | ||
graphic.setText(IconTheme.JabRefIcon.INTEGRITY_WARN.getCode()); | ||
break; | ||
case LOW: | ||
getStyleClass().add("log"); | ||
graphic.setText(IconTheme.JabRefIcon.INTEGRITY_INFO.getCode()); | ||
break; | ||
default: | ||
break; | ||
} | ||
setGraphic(graphic); | ||
} else { | ||
setText(null); | ||
setGraphic(null); | ||
} | ||
} | ||
}; | ||
} | ||
}); | ||
} | ||
} |
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 would leave all the old constructors and call the new overloads with
isModal=true
since this looks like the default behavior. For example:public FXAlert(AlertType type, String title) { this(type, title, true); }
.