Skip to content

Commit

Permalink
Initialise javadocViewer if null
Browse files Browse the repository at this point in the history
  • Loading branch information
alanocallaghan committed Jul 24, 2024
1 parent 4b2ae28 commit 5ad612e
Showing 1 changed file with 23 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,19 @@ public class JavadocViewerCommand implements Runnable {
private Stage stage;
private JavadocViewer javadocViewer;

/**
* Get a reference to the singleton {@link JavadocViewer}
* @return A JavadocViewer, unless the constructor fails, in which case
* a {@link RuntimeException} is thrown.
*/
public JavadocViewer getJavadocViewer() {
if (javadocViewer == null) {
try {
javadocViewer = new JavadocViewer(stylesheet, urisToSearch);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return javadocViewer;
}

Expand All @@ -40,24 +52,21 @@ public JavadocViewerCommand(Stage owner, ReadOnlyStringProperty stylesheet, URI.
@Override
public void run() {
if (stage == null) {
try {
stage = new Stage();
if (owner != null) {
stage.initOwner(owner);
}

javadocViewer = new JavadocViewer(stylesheet, urisToSearch);
stage = new Stage();
if (owner != null) {
stage.initOwner(owner);
}

Scene scene = new Scene(javadocViewer);
stage.setScene(scene);
stage.show();
javadocViewer = getJavadocViewer();

stage.setMinWidth(javadocViewer.getWidth());
stage.setMinHeight(javadocViewer.getHeight());
Scene scene = new Scene(javadocViewer);
stage.setScene(scene);
stage.show();

stage.setMinWidth(javadocViewer.getWidth());
stage.setMinHeight(javadocViewer.getHeight());

} catch (IOException e) {
throw new RuntimeException(e);
}
}

stage.show();
Expand Down

0 comments on commit 5ad612e

Please sign in to comment.