private void showPackageContents(PackageContents packageContents) { packageConfirmPanel.setVisible(false); downloadingPane.setVisible(false); analysisPane.setVisible(true); pkgContents = packageContents; downloadFileLabel.setText(packageContents.getFile().getPath()); fileCountLabel.setText(String.valueOf(packageContents.getFileCount())); folderCountLabel.setText(String.valueOf(packageContents.getFolderCount())); rootSummaryTable.setItems(FXCollections.observableArrayList(packageContents.getBaseCounts().entrySet())); typeSummaryTable.setItems(FXCollections.observableArrayList(packageContents.getFilesByType().entrySet())); downloadFileLabel.setOnMouseClicked(evt -> { if (evt.getButton() == MouseButton.PRIMARY && evt.getClickCount() == 2) { String path; if (evt.isShiftDown() || evt.isControlDown()) { path = packageContents.getFile().getParent(); } else { path = packageContents.getFile().getPath(); } HostServices services = ApplicationState.getInstance().getApplication().getHostServices(); services.showDocument(path); } }); }
/** * Shows the about view in a separate window. * * @param theme the theme to be applied. * @param hostServices the host services to be aggregated. * @return the controller for the view. */ static AboutViewController showAboutView(CSS.Theme theme, HostServices hostServices) { if (hostServices == null) { throw new NullPointerException("Host services must not be null."); } FXMLLoader fxmlLoader = initFXMLLoader(ABOUT_VIEW_RES); AboutViewController controller = new AboutViewController(theme, hostServices); fxmlLoader.setController(controller); final Stage aboutView = new Stage(); aboutView.initModality(Modality.APPLICATION_MODAL); controller.setPrimaryStage(aboutView); try { aboutView.getIcons().add(BaseController._frameImage); aboutView.setTitle(I18N.getString("aboutViewTitle.text")); aboutView.setScene(loadScene(fxmlLoader, theme)); aboutView.showAndWait(); } catch (IOException ex) { handleErrorLoadingView(ex, theme); } return controller; }
public StartUpView( HostServices hostServices, Stage stage, Consumer<File> openFile ) { VBox box = new AboutLogFXView( hostServices ).createNode(); String metaKey = FxUtils.isMac() ? "⌘" : "Ctrl+"; Hyperlink link = new Hyperlink( String.format( "Open file (%sO)", metaKey ) ); link.getStyleClass().add( "large-background-text" ); link.setOnAction( ( event ) -> new FileOpener( stage, openFile ) ); Text dropText = new Text( "Or drop files here" ); dropText.getStyleClass().add( "large-background-text" ); StackPane fileDropPane = new StackPane( dropText ); fileDropPane.getStyleClass().add("drop-file-pane"); FileDragAndDrop.install( fileDropPane, openFile ); box.getChildren().addAll( link, fileDropPane ); getChildren().addAll( box ); }
public static EventHandler<ActionEvent> getEventHander(HostServices services, String uri){ return new EventHandler<ActionEvent>() { public void handle(ActionEvent t) { if (!PlatformUtils.isUnix()) { if (services!= null) { services.showDocument(uri); } else { logger.warn("No services object"); } }else{ String cmd = PlatformUtils.getFileBrowserCommand() + " " + uri; try { Runtime.getRuntime().exec(cmd); } catch (IOException e) { logger.warn("Error executing browser"); } } } }; }
public MainWindow(ScriptRegistry scriptRegistry, JobManagerFactory jobManagerFactory, Client client, EventBusProvider eventBusProvider, HostServices hostServices, DatatypeRegistry datatypeRegistry) { super(); this.eventBusProvider = eventBusProvider; this.scriptRegistry = scriptRegistry; this.jobManager = jobManagerFactory.createFor(client); this.hostServices = hostServices; currentJobProperty = new SimpleObjectProperty<ObservableJob>(); addCurrentJobChangeListener(); jobData = FXCollections.observableArrayList(); scriptData = FXCollections.observableArrayList(); dataManager = new DataManager(this, datatypeRegistry); this.eventBusListener = new EventBusListener(this); eventBusProvider.get().register(eventBusListener); buildWindow(); }
@EventListener public void openUrl(OpenUrlRequest event) { HostServices services = getHostServices(); if (nonNull(services)) { try { services.showDocument(event.getUrl()); } catch (NullPointerException npe) { // service delegate can be null but there's no way to check it first so we have to catch the npe LOG.info("Unable to open url using HostServices, trying fallback"); try { Runtime.getRuntime().exec(getOpenCmd(event.getUrl())); } catch (IOException e) { LOG.warn("Unable to open the url", e); } } } else { LOG.warn("Unable to open '{}', please copy and paste the url to your browser.", event.getUrl()); } }
public AppController(AllAppList appList, UserAppList userApp, HostServices hostServices) { this.allAppList = appList; this.userAppList = userApp; this.noGameSelected = true; this.imageCache = new HashMap<>(); this.dragDelta = new Point(); this.hostServices = hostServices; this.filterMode = false; this.modified = false; imageCacheHandler = new ImageCacheHandler(imageCache); csvImportTool = new CSVImportTool(userAppList); }
public AboutDialog(HostServices hostServices) throws IOException { this.hostServices = hostServices; setTitle( "About" ); setHeaderText( null ); setResizable( false ); getDialogPane().getButtonTypes().addAll( ButtonType.OK ); FXMLLoader fxmlLoader = new FXMLLoader(); fxmlLoader.setController( this ); Pane aboutContentPane = fxmlLoader.load(getClass().getResourceAsStream("/fxml/about.fxml")); getDialogPane().setContent( aboutContentPane ); }
public AboutAlert(final HostServices hostServices, final ResourceBundle bundle) { super(AlertType.NONE); this.HOSTSERVICES = hostServices; this.BUNDLE = bundle; setTitle(BUNDLE.getString("menu.about")); initStyle(StageStyle.UTILITY); initModality(Modality.NONE); setAndHideButton(); getDialogPane().setContent(createContent()); }
@Test public void shouldDownloadNewVersion() throws Exception { HostServices existingHostServices = GUIState.getHostServices(); ReflectionTestUtils.setField(GUIState.class, "hostServices", mockHostServices); spyUpdateManager.downloadNewVersion(); // Wait for invocation Thread.sleep(500); ReflectionTestUtils.setField(GUIState.class, "hostServices", existingHostServices); verify(mockHostServices, times(1)).showDocument(websiteUrl); }
@Override public void start(Stage primaryStage) throws Exception { Injector.setModelOrService(HostServices.class, getHostServices()); final FixpadView mainView = new FixpadView(); final Scene scene = new Scene( mainView.getView() ); primaryStage.setTitle( "FixPad" ); primaryStage.setScene( scene ); primaryStage.show(); }
/** * Constructs a controller for Main View with the specified CSS theme and * host services. * * @param theme the {@link CSS} theme to apply. * @param hostServices the host services to aggregate. */ public MainViewController(CSS.Theme theme, HostServices hostServices) { super(theme, hostServices); _archiveName = DEFAULT_ARCHIVE_NAME; _compressionLevel = Deflater.DEFAULT_COMPRESSION; _activeTasks = new ConcurrentHashMap<>(); Log.i("Default archive name set to: {0}", _archiveName, false); }
@Override public void start(final Stage stage) { Platform.runLater(new Runnable() { @Override public void run(){ try { ServiceRegistry.getInstance().notifyReady(PipelineApplication.this); ServiceRegistry services=PipelineApplication.this.services; HostServices hostServices = getHostServices(); Client client = services.getWebserviceStorage().getClientStorage().defaultClient(); MainWindow mainWindow = new MainWindow( services.getScriptRegistry(), services.getJobManagerFactory(), client, services.getEventBusProvider(), hostServices, services.getDatatypeRegistry()); stage.setScene(mainWindow.getScene()); stage.setTitle("DAISY Pipeline 2"); stage.show(); } catch (InterruptedException e) { logger.error("Interrupted while wating for services",e); } } }); }
private MarkdownToJavafx.JavaFxParent getJavaFxParent(final Pane parent){ return new MarkdownToJavafx.JavaFxParent(){ @Override public void addChild(Node node) { node.getStyleClass().add("help"); parent.getChildren().add(node); //make sure the text is displayed correctly if (node instanceof Text){ Text text = (Text)node; //if (parent instanceof VBox){ //wrapCorrectly(text, (VBox)parent); //}else{ //wrapCorrectly(text); // //} text.setWrappingWidth(200); } } @Override public HostServices getHostServices() { return GridPaneHelper.this.main.getHostServices(); } }; }
public TipPanel(HostServices hostServices) { this.hostServices = hostServices; tipbarTimeline = new Timeline( new KeyFrame(Duration.ZERO, new KeyValue(tipPanel.translateYProperty(), 0, Interpolator.EASE_BOTH)), new KeyFrame(slideTime, new KeyValue(tipPanel.translateYProperty(), -40, Interpolator.EASE_BOTH)) ); tipbarTimeline.setAutoReverse(false); new Timeline(new KeyFrame(Duration.minutes(1), e -> showTipBar())).play(); }
public static void setHostServices(HostServices hostServices) { // Please, forgive me this approach // it saved me a lot of time ClickableHyperLink.hostServices = hostServices; }
public AboutController(HostServices hostServices, Preferences prefs) { this.hostServices = hostServices; this.prefs = prefs; }
public static HostServices getHostService() { return hostServices; }
public static HostServices getHostService() { return Main.hostService; }
public void setHostServices(HostServices hostServices) { this.hostServices = hostServices; }
public HostServices getHostServices() { return hostservices; }
public void setHostServices(HostServices hostservices) { this.hostservices = hostservices; }
public static void setInstance(HostServices newInstance) { if (instance != null) { throw new IllegalStateException("already set"); } instance = newInstance; }
public static HostServices getInstance() { return instance; }
@Override @FXThread protected void createContent(@NotNull final VBox root) { super.createContent(root); final JFXApplication application = JFXApplication.getInstance(); final HostServices hostServices = application.getHostServices(); final GridPane gridPane = new GridPane(); final Label applicationLabel = new Label(Config.TITLE); applicationLabel.setGraphic(new ImageView(Icons.APPLICATION_64)); final Label versionLabel = new Label(Messages.ABOUT_DIALOG_VERSION + ":"); versionLabel.prefWidthProperty().bind(gridPane.widthProperty().multiply(0.5)); final Label versionField = new Label(Config.STRING_VERSION); final Label projectHomeLabel = new Label(Messages.ABOUT_DIALOG_PROJECT_HOME + ":"); final Hyperlink projectHomeField = new Hyperlink("bitbucket.org"); projectHomeField.setOnAction(event -> hostServices.showDocument(PROJECT_HOME)); projectHomeField.setFocusTraversable(false); final Label forumThreadLabel = new Label(Messages.ABOUT_DIALOG_FORUM_THREAD + ":"); final Hyperlink forumThreadField = new Hyperlink("hub.jmonkeyengine.org"); forumThreadField.setOnAction(event -> hostServices.showDocument(FORUM_THREAD)); forumThreadField.setFocusTraversable(false); final Label usedLibrariesLabel = new Label(Messages.ABOUT_DIALOG_USED_LIBRARIES + ":"); usedLibrariesLabel.prefWidthProperty().bind(gridPane.widthProperty()); final Label usedIcons = new Label(Messages.ABOUT_DIALOG_USED_ICONS + ":"); usedIcons.prefWidthProperty().bind(gridPane.widthProperty()); final TextArea librariesArea = new TextArea(LIBRARIES); librariesArea.setEditable(false); librariesArea.setFocusTraversable(false); final TextArea iconsArea = new TextArea(ICONS); iconsArea.setEditable(false); iconsArea.setFocusTraversable(false); gridPane.add(applicationLabel, 0, 0, 2, 1); gridPane.add(versionLabel, 0, 1, 1, 1); gridPane.add(versionField, 1, 1, 1, 1); gridPane.add(projectHomeLabel, 0, 2, 1, 1); gridPane.add(projectHomeField, 1, 2, 1, 1); gridPane.add(forumThreadLabel, 0, 3, 1, 1); gridPane.add(forumThreadField, 1, 3, 1, 1); gridPane.add(usedLibrariesLabel, 0, 4, 2, 1); gridPane.add(librariesArea, 0, 5, 2, 1); gridPane.add(usedIcons, 0, 6, 2, 1); gridPane.add(iconsArea, 0, 7, 2, 1); FXUtils.addToPane(gridPane, root); FXUtils.addClassTo(root, CSSClasses.ABOUT_DIALOG); FXUtils.addClassTo(gridPane, CSSClasses.DEF_GRID_PANE); FXUtils.addClassTo(usedLibrariesLabel, usedIcons, CSSClasses.ABOUT_DIALOG_LONG_LABEL); FXUtils.addClassesTo(versionLabel, projectHomeLabel, forumThreadLabel, usedLibrariesLabel, usedIcons, versionField, projectHomeField, forumThreadField, CSSClasses.SPECIAL_FONT_16); FXUtils.addClassTo(applicationLabel, CSSClasses.ABOUT_DIALOG_TITLE_LABEL); }
@Override public void run() { try (final CloseableHttpClient httpClient = createMinimal()) { CloseableHttpResponse response = httpClient.execute(new HttpGet(APP_VERSION_URL)); StatusLine statusLine = response.getStatusLine(); if (statusLine.getStatusCode() != 200) { return; } HttpEntity entity = response.getEntity(); InputStream content = entity.getContent(); Header encoding = entity.getContentEncoding(); String enc = encoding == null ? "UTF-8" : encoding.getValue(); final String targetVersion = IOUtils.toString(content, enc) .trim() .replace("v.", ""); if (Config.APP_VERSION.compareTo(new Version(targetVersion)) >= 0) { return; } response = httpClient.execute(new HttpGet(DOWNLOAD_APP_PATH_URL)); statusLine = response.getStatusLine(); if (statusLine.getStatusCode() != 200) { return; } entity = response.getEntity(); content = entity.getContent(); encoding = entity.getContentEncoding(); enc = encoding == null ? "UTF-8" : encoding.getValue(); final String targetLink = IOUtils.toString(content, enc).trim(); Platform.runLater(() -> { final JFXApplication jfxApplication = JFXApplication.getInstance(); final HostServices hostServices = jfxApplication.getHostServices(); final Hyperlink hyperlink = new Hyperlink(Messages.CHECK_NEW_VERSION_DIALOG_HYPERLINK + targetLink); hyperlink.setOnAction(event -> hostServices.showDocument(targetLink)); final Alert alert = new Alert(AlertType.INFORMATION); alert.setTitle(Messages.CHECK_NEW_VERSION_DIALOG_TITLE); alert.setHeaderText(Messages.CHECK_NEW_VERSION_DIALOG_HEADER_TEXT + targetVersion); final DialogPane dialogPane = alert.getDialogPane(); dialogPane.setContent(hyperlink); alert.show(); }); } catch (final IOException e) { LOGGER.warning(e); } }
public void setHostServices(HostServices _hostServices) { hostServices = _hostServices; }
public HostServices getHostServices() { return hostServices; }
void setHostServices(HostServices hostServices) { this.hostServices = hostServices; }
public static HostServices getAppHostServices() { return GUIState.getHostServices(); }
public HostServices getHostServices() { return this.hostServices; }
public void initialize(HostServices hostServices) { this.hostServices = checkNotNull(hostServices, "hostServices == null!"); }
void setHostServices(HostServices hostServices) { aboutTabController.setHostServices(hostServices); }
public AboutDialog(final HostServices hostServices) { super(); this.hostServices = hostServices; final DialogPane dialogPane = getDialogPane(); final StackPane stackPane = new StackPane(); stackPane.setMaxWidth(Double.MAX_VALUE); stackPane.setAlignment(Pos.CENTER_LEFT); setTitle("About"); dialogPane.getButtonTypes().addAll(ButtonType.OK); final TextFlow textFlow = new TextFlow(); String family = "Arial"; double size = 12; final Text text0 = new Text("FixPad - by Ben Warner\n"); text0.setFont(Font.font(family, FontWeight.BOLD, FontPosture.REGULAR, 14)); final Text text1 = new Text("\nA small app to convert snippets of fix into a more readable format. It is covered by the GNU GENERAL PUBLIC LICENSE (free to use commercially and non-commercially). Find it on github at:\n"); text1.setFont(Font.font(family, size)); final Hyperlink text2 = new Hyperlink("https://github.com/fix4j/fix4j-fixpad"); text2.setFont(Font.font(family, FontWeight.BOLD, size)); text2.setOnAction(t -> { this.hostServices.showDocument(text2.getText()); }); final Text text3 = new Text("\n\nFixPad uses the fix4j-assert API to build the readable strings. fix4j-assert is a Java based framework for testing FIX applications. Find it at:\n"); text1.setFont(Font.font(family, size)); final Hyperlink text4 = new Hyperlink("https://github.com/fix4j/fix4j-assert"); text4.setFont(Font.font(family, FontWeight.BOLD, size)); text4.setOnAction(t -> { this.hostServices.showDocument(text4.getText()); }); final Text text5 = new Text("\n\nCheck out github for some more of our software efforts:\n"); text1.setFont(Font.font(family, size)); final Text lineBreak1 = new Text("\n"); final Hyperlink text6 = new Hyperlink("https://github.com/tools4j/decimal4j"); text6.setFont(Font.font(family, FontWeight.BOLD, size)); text6.setOnAction(t -> { this.hostServices.showDocument(text6.getText()); }); final Text lineBreak2 = new Text("\n"); final Hyperlink text7 = new Hyperlink("https://github.com/tools4j/unix4j"); text7.setFont(Font.font(family, FontWeight.BOLD, size)); text7.setOnAction(t -> { this.hostServices.showDocument(text7.getText()); }); final Hyperlink text8 = new Hyperlink("https://github.com/tools4j/meanvar"); text8.setFont(Font.font(family, FontWeight.BOLD, size)); text8.setOnAction(t -> { this.hostServices.showDocument(text8.getText()); }); textFlow.getChildren().addAll(text0, text1, text2, text3, text4, text5, text6, lineBreak1, text7, lineBreak2, text8); textFlow.setPrefWidth(400); stackPane.getChildren().clear(); stackPane.getChildren().add(textFlow); getDialogPane().setContent(stackPane); }
public AboutLogFXView( HostServices hostServices ) { this.hostServices = hostServices; }
/** * @param throwable The throwable exception to display this alert for. * @param services The host services, allows access to {@link HostServices#showDocument(String)} * in order to display the issue website. * @see <a href="http://code.makery.ch/blog/javafx-dialogs-official/">Inspiration</a> */ public ExceptionAlert(final Parent root, final Throwable throwable, final String message, boolean isFatal, final HostServices services) { super(AlertType.ERROR); checkNotNull(root, "The parent can not be null"); checkNotNull(throwable, "The Throwable can not be null"); checkNotNull(services, "HostServices can not be null"); final ButtonType closeBtnType = new ButtonType(isFatal ? "Quit" : "Cancel", ButtonBar.ButtonData.CANCEL_CLOSE); final String exceptionMessage = generateExceptionMessage(throwable); final String systemInfoMessage = generateSystemInfoMessage(); this.setTitle(getInitialCause(throwable).getClass().getSimpleName()); this.setHeaderText((isFatal ? "FATAL: " : "") + message); // Set stylesheet this.getDialogPane().styleProperty().bind(root.styleProperty()); this.getDialogPane().getStylesheets().addAll(root.getStylesheets()); this.setResizable(true); // Add two additional buttons this.getButtonTypes().setAll(COPY, closeBtnType, REPORT); final GridPane dialogContent = new GridPane(); dialogContent.getStyleClass().add("exception-pane"); dialogContent.setMaxWidth(Double.MAX_VALUE); dialogContent.setMaxHeight(Double.MAX_VALUE); final Label issuePasteLabel = new Label(ISSUE_PROMPT_TEXT); issuePasteLabel.setWrapText(true); final TextArea issueText = new TextArea(message + "\n" + exceptionMessage + "\n" + systemInfoMessage); issueText.getStyleClass().add("exception-text"); issuePasteLabel.setLabelFor(issueText); issueText.setEditable(false); issueText.setMaxWidth(Double.MAX_VALUE); issueText.setMaxHeight(Double.MAX_VALUE); dialogContent.add(issuePasteLabel, 0, 0); dialogContent.add(issueText, 0, 1); GridPane.setHgrow(issueText, Priority.ALWAYS); GridPane.setVgrow(issueText, Priority.ALWAYS); this.getDialogPane().setContent(dialogContent); final Button copyBtn = (Button) this.getDialogPane().lookupButton(COPY); copyBtn.addEventFilter(ActionEvent.ACTION, event -> { final ClipboardContent content = new ClipboardContent(); content.putString(issueText.getText()); Clipboard.getSystemClipboard().setContent(content); issueText.requestFocus(); issueText.selectAll(); event.consume(); // Prevent the dialog from closing }); final Button openGitHubIssueBtn = (Button) this.getDialogPane().lookupButton(REPORT); openGitHubIssueBtn.addEventFilter(ActionEvent.ACTION, event -> { services.showDocument(PROJECT_ISSUE_LINK); event.consume(); // Prevent the dialog from closing }); // Set the initial focus to the input box so the cursor goes there first this.initialFocusElement = openGitHubIssueBtn; }
@Override public HostServices getHostServices() { return main.getHostServices(); }