2626import com .temporaryteam .noticeditor .model .*;
2727import com .temporaryteam .noticeditor .view .Chooser ;
2828import com .temporaryteam .noticeditor .view .EditNoticeTreeCell ;
29+ import com .temporaryteam .noticeditor .view .Notification ;
2930import java .util .ResourceBundle ;
3031import java .util .logging .Level ;
3132import java .util .logging .Logger ;
3233import javafx .beans .binding .Bindings ;
3334
3435import javafx .beans .value .ChangeListener ;
3536import javafx .beans .value .ObservableValue ;
36- import jfx . messagebox . MessageBox ;
37+ import javafx . scene . layout . VBox ;
3738
3839public class NoticeController {
3940
@@ -58,14 +59,20 @@ public class NoticeController {
5859 private Menu previewStyleMenu ;
5960
6061 @ FXML
61- private TextField searchField ;
62+ private TextField searchField ;
6263
6364 @ FXML
6465 private TreeView <NoticeItem > noticeTreeView ;
6566
6667 @ FXML
6768 private NoticeSettingsController noticeSettingsController ;
6869
70+ @ FXML
71+ private VBox notificationBox ;
72+
73+ @ FXML
74+ private Label notificationLabel ;
75+
6976 @ FXML
7077 private ResourceBundle resources ;
7178
@@ -89,6 +96,7 @@ public void setApplication(Main main) {
8996 */
9097 @ FXML
9198 private void initialize () {
99+ Notification .init (notificationBox , notificationLabel );
92100 engine = viewer .getEngine ();
93101
94102 // Set preview styles menu items
@@ -101,6 +109,7 @@ private void initialize() {
101109 item .setSelected (true );
102110 }
103111 item .setOnAction (new EventHandler <ActionEvent >() {
112+ @ Override
104113 public void handle (ActionEvent e ) {
105114 String path = cssPath ;
106115 if (path != null ) {
@@ -243,6 +252,7 @@ private void handleOpen(ActionEvent event) {
243252 noticeSettingsController .updateStatuses ();
244253 } catch (IOException | JSONException e ) {
245254 logger .log (Level .SEVERE , null , e );
255+ Notification .error ("Unable to open " + fileSaved .getName ());
246256 }
247257 }
248258
@@ -261,8 +271,9 @@ private void handleSaveAs(ActionEvent event) {
261271 .filter (Chooser .ZIP , Chooser .JSON )
262272 .title ("Save notice" )
263273 .show (main .getPrimaryStage ());
264- if (fileSaved == null )
274+ if (fileSaved == null ) {
265275 return ;
276+ }
266277
267278 saveDocument (fileSaved );
268279 }
@@ -275,24 +286,32 @@ private void saveDocument(File file) {
275286 } else {
276287 strategy = ExportStrategyHolder .ZIP ;
277288 }
278- DocumentFormat .save (file , noticeTree , strategy );
289+ try {
290+ DocumentFormat .save (file , noticeTree , strategy );
291+ Notification .success ("Successfully saved!" );
292+ } catch (ExportException e ) {
293+ logger .log (Level .SEVERE , null , e );
294+ Notification .error ("Successfully failed!" );
295+ }
296+
279297 }
280298
281299 @ FXML
282300 private void handleExportHtml (ActionEvent event ) {
283301 File destDir = Chooser .directory ()
284302 .title ("Select directory to save HTML files" )
285303 .show (main .getPrimaryStage ());
286- if (destDir == null )
304+ if (destDir == null ) {
287305 return ;
306+ }
288307
289308 try {
290309 ExportStrategyHolder .HTML .setProcessor (processor );
291310 ExportStrategyHolder .HTML .export (destDir , noticeTree );
292- MessageBox . show ( main . getPrimaryStage (), "Export success!" , "" , MessageBox . OK );
311+ Notification . success ( "Export success!" );
293312 } catch (ExportException e ) {
294313 logger .log (Level .SEVERE , null , e );
295- MessageBox . show ( main . getPrimaryStage (), "Export failed!" , "" , MessageBox . OK );
314+ Notification . error ( "Export failed!" );
296315 }
297316 }
298317
@@ -309,7 +328,7 @@ private void handleSwitchOrientation(ActionEvent event) {
309328
310329 @ FXML
311330 private void handleAbout (ActionEvent event ) {
312-
331+ Notification . show ( "NoticEditor \n ========== \n \n https://github.com/TemporaryTeam/NoticEditor" );
313332 }
314333
315334 public NoticeTreeItem getCurrentNotice () {
0 commit comments