本文整理汇总了Java中javafx.application.HostServices类的典型用法代码示例。如果您正苦于以下问题:Java HostServices类的具体用法?Java HostServices怎么用?Java HostServices使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
HostServices类属于javafx.application包,在下文中一共展示了HostServices类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: showPackageContents
import javafx.application.HostServices; //导入依赖的package包/类
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);
}
});
}
示例2: showAboutView
import javafx.application.HostServices; //导入依赖的package包/类
/**
* 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;
}
示例3: StartUpView
import javafx.application.HostServices; //导入依赖的package包/类
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 );
}
示例4: getEventHander
import javafx.application.HostServices; //导入依赖的package包/类
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");
}
}
}
};
}
示例5: MainWindow
import javafx.application.HostServices; //导入依赖的package包/类
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();
}
示例6: openUrl
import javafx.application.HostServices; //导入依赖的package包/类
@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());
}
}
示例7: AppController
import javafx.application.HostServices; //导入依赖的package包/类
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);
}
示例8: AboutDialog
import javafx.application.HostServices; //导入依赖的package包/类
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 );
}
示例9: AboutAlert
import javafx.application.HostServices; //导入依赖的package包/类
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());
}
示例10: shouldDownloadNewVersion
import javafx.application.HostServices; //导入依赖的package包/类
@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);
}
示例11: start
import javafx.application.HostServices; //导入依赖的package包/类
@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();
}
示例12: MainViewController
import javafx.application.HostServices; //导入依赖的package包/类
/**
* 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);
}
示例13: start
import javafx.application.HostServices; //导入依赖的package包/类
@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);
}
}
});
}
示例14: getJavaFxParent
import javafx.application.HostServices; //导入依赖的package包/类
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();
}
};
}
示例15: TipPanel
import javafx.application.HostServices; //导入依赖的package包/类
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();
}