5858import org .phoebus .logbook .olog .ui .HelpViewer ;
5959import org .phoebus .logbook .olog .ui .LogbookUIPreferences ;
6060import org .phoebus .logbook .olog .ui .PreviewViewer ;
61+ import org .phoebus .logbook .olog .ui .menu .SendToLogBookApp ;
6162import org .phoebus .olog .es .api .OlogProperties ;
6263import org .phoebus .olog .es .api .model .OlogLog ;
6364import org .phoebus .security .store .SecureStore ;
@@ -88,7 +89,9 @@ public class LogEntryEditorController {
8889 private final Logger logger = Logger .getLogger (LogEntryEditorController .class .getName ());
8990
9091 @ FXML
91- private VBox root ;
92+ private VBox editorPane ;
93+ @ FXML
94+ private VBox errorPane ;
9295 @ FXML
9396 private Button submitButton ;
9497 @ FXML
@@ -185,6 +188,7 @@ public class LogEntryEditorController {
185188 */
186189 private String originalTitle = "" ;
187190
191+
188192 public LogEntryEditorController (LogEntry logEntry , LogEntry inReplyTo , LogEntryCompletionHandler logEntryCompletionHandler ) {
189193 this .replyTo = inReplyTo ;
190194 this .completionHandler = logEntryCompletionHandler ;
@@ -205,17 +209,29 @@ public LogEntryEditorController(LogEntry logEntry, LogEntry inReplyTo, LogEntryC
205209 this .logEntry = logEntry ;
206210 }
207211 }
208-
212+
209213 @ FXML
210214 public void initialize () {
211- completionMessageLabel .setText ("" );
215+
216+ // This could be configured in the fxml, but then these UI components would not be visible
217+ // in Scene Builder.
218+ completionMessageLabel .textProperty ().set ("" );
219+ progressIndicator .visibleProperty ().bind (submissionInProgress );
220+
221+ // Remote log service not reachable, so show error pane.
222+ if (!checkConnectivity ()) {
223+ errorPane .visibleProperty ().set (true );
224+ editorPane .disableProperty ().set (true );
225+ return ;
226+ }
227+
212228 submitButton .disableProperty ().bind (Bindings .createBooleanBinding (() ->
213229 !inputValid .get () || submissionInProgress .get (),
214230 inputValid , submissionInProgress ));
215231 completionMessageLabel .visibleProperty ()
216232 .bind (Bindings .createBooleanBinding (() -> completionMessageLabel .textProperty ().isNotEmpty ().get () && !submissionInProgress .get (),
217233 completionMessageLabel .textProperty (), submissionInProgress ));
218- progressIndicator . visibleProperty (). bind ( submissionInProgress );
234+
219235 cancelButton .disableProperty ().bind (submissionInProgress );
220236 attachmentsEditorController .setTextArea (textArea );
221237
@@ -390,7 +406,7 @@ public void initialize() {
390406 public void cancel () {
391407 // Need to clear selections.
392408 SelectionService .getInstance ().clearSelection ("" );
393- ((LogEntryEditorStage ) cancelButton .getScene ().getWindow ()).handleCloseEditor (isDirty , root );
409+ ((LogEntryEditorStage ) cancelButton .getScene ().getWindow ()).handleCloseEditor (isDirty , editorPane );
394410 }
395411
396412 @ FXML
@@ -676,4 +692,20 @@ private void updateDropDown(ContextMenu contextMenu, String itemName, boolean it
676692 public boolean isDirty () {
677693 return isDirty ;
678694 }
695+
696+ /**
697+ * Checks connectivity to remote service by querying the info end-point. If connection fails,
698+ * connectionError property is set to <code>true</code>, which should set opacity of the editor pane, and
699+ * set visibility of error pane.
700+ */
701+ private boolean checkConnectivity () {
702+ LogClient logClient = LogService .getInstance ().getLogFactories ().get (LogbookPreferences .logbook_factory ).getLogClient ();
703+ try {
704+ logClient .serviceInfo ();
705+ return true ;
706+ } catch (Exception e ) {
707+ Logger .getLogger (SendToLogBookApp .class .getName ()).warning ("Failed to query logbook service, it may be off-line." );
708+ return false ;
709+ }
710+ }
679711}
0 commit comments