private static ValueSerializer getValueSerializer() { if( serializer == null ) { serializer = Util.lookupService(ValueSerializer.class); } return serializer; }
public static boolean isCopyEvent(MouseEvent event) { if( org.eclipse.fx.core.Util.isMacOS() ) { return event.isAltDown(); } else { return event.isControlDown(); } } }
private ExtensibleURLStreamHandlerFactory() { this.handlerMap = Util.lookupServiceList(org.eclipse.fx.core.URLStreamHandler.class).stream().collect(Collectors.toMap(h -> h.getProtocol(), h -> h)); }
/** * Convert an URL to a path on the local filesystem * * @param url * the url * @param copyIfNeeded * <code>true</code> if the url can not be converted to a local * the content is copied to the local filesystem * @return the path * @since 2.2.0 */ public static Optional<Resource<@NonNull Path>> getLocalPath(@NonNull URL url, boolean copyIfNeeded) { return lookupServiceList(URLResolver.class) .stream() .filter(r -> r.test(url)).findFirst() .map(r -> Optional.of(Resource.createResource(r.resolveToLocalPath(url)))) .orElseGet(() -> copyIfNeeded ? ExExecutor.executeSupplier( () -> Util.copyToTempFile(url), "Unable to copy resource") : Optional.empty()); //$NON-NLS-1$ }
/** * Create a media instance from the given source * * @param url * the url the media is located at * @return media object created */ public static Optional<Media> createMedia(@NonNull URL url) { if (isSupported(url)) { return Optional.of(new Media(url.toExternalForm())); } Optional<URL> localURL = Util.getLocalURL(url); if (localURL.isPresent()) { if (isSupported(localURL.get())) { return Optional.of(new Media(localURL.get().toExternalForm())); } } Optional<Resource<@NonNull Path>> localPath = Util.getLocalPath(url, false); if( localPath.isPresent() ) { try { return Optional.of(new Media(localPath.get().getNativeResource().toUri().toURL().toExternalForm())); } catch (MalformedURLException e) { throw new RuntimeException(e); } } return Optional.empty(); }
case AT_LEAST_ONE: case MULTIPLE: { List<?> list = Util.lookupServiceList(serviceInterface); if (cardinality == ReferenceCardinality.AT_LEAST_ONE && list.isEmpty()) { logError("Unsatisfied dependency '"+r.getIface()+"'. There must be at least one component providing this service", null); //$NON-NLS-1$//$NON-NLS-2$ Optional<?> service = Util.getService(serviceInterface); if (ReferenceCardinality.MANDATORY == cardinality && !service.isPresent()) { logError("Unsatisfied dependency '"+r.getIface()+"'. There must be at least one component providing this service", null); //$NON-NLS-1$//$NON-NLS-2$
return b.build(); } , (v) -> v.toInstant().toString())); if (!Util.isOsgiEnv()) { Map<Class<?>, TwoVal<?>> collect = Util.lookupServiceList(ValueSerializeProvider.class).stream() .collect(Collectors.toMap(p -> p.getType(), p -> new TwoVal<>(p::fromString, p::toString))); this.mappings.putAll(collect);
private static void enterNestedEventLoop(String id) { if( Util.isFX9() ) { enterNestedEventLoop9(id); } else { enterNestedEventLoop8(id); } }
double constraintedValue = Util.unsignedConstraintValue( value, getMinHeight(), value = Util.unsignedConstraintValue( value, getMinHeight(), double constraintedValue = Util.unsignedConstraintValue( value, getMinWidth(), value = Util.unsignedConstraintValue( value, getMinWidth(),
public static DecoratedNode apply(Node control) { return Util.getService(NodeDecorator.class).orElseGet(() -> new GraphicDecorator()).decorate(control); }
/** * Create a media instance from the given source * * @param url * the url the media is located at * @return media object created */ public static Optional<Media> createMedia(@NonNull URL url) { if (isSupported(url)) { return Optional.of(new Media(url.toExternalForm())); } Optional<URL> localURL = Util.getLocalURL(url); if (localURL.isPresent()) { if (isSupported(localURL.get())) { return Optional.of(new Media(localURL.get().toExternalForm())); } } Optional<Resource<@NonNull Path>> localPath = Util.getLocalPath(url, false); if( localPath.isPresent() ) { try { return Optional.of(new Media(localPath.get().getNativeResource().toUri().toURL().toExternalForm())); } catch (MalformedURLException e) { throw new RuntimeException(e); } } return Optional.empty(); }
private static void exitNestedEventLoop(String id) { if( Util.isFX9() ) { exitNestedEventLoop9(id); } else { exitNestedEventLoop8(id); } }
double constraintedValue = Util.unsignedConstraintValue( value, getMinHeight(), value = Util.unsignedConstraintValue( value, getMinHeight(), double constraintedValue = Util.unsignedConstraintValue( value, getMinWidth(), value = Util.unsignedConstraintValue( value, getMinWidth(),
private static ObjectSerializer getObjectSerializer() { if( objectSerializer == null ) { objectSerializer = Util.lookupService(ObjectSerializer.class); } return objectSerializer; }
return Optional.of(new AudioClip(url.toExternalForm())); Optional<URL> localURL = Util.getLocalURL(url); Optional<Resource<@NonNull Path>> localPath = Util.getLocalPath(url, false); if( localPath.isPresent() ) { try {
/** * Convert an URL to a path on the local filesystem * * @param url * the url * @return the path * @since 2.2.0 */ public static Optional<URL> getLocalURL(@NonNull URL url) { return lookupServiceList(URLResolver.class) .stream() .filter(r -> r.test(url)).findFirst() .map(r -> r.resolveToLocalURL(url)); }
/** * Enter a nested event loop * * @param id * the id of the nested event loop * @since 2.3.0 */ public static void enterNestedEventLoop(String id) { if (org.eclipse.fx.core.Util.isFX9()) { enterNestedEventLoop9(id); } else { enterNestedEventLoop8(id); } }
if( getScene() != null && getScene().getWindow() != null ) { Window w = getScene().getWindow(); getScene().getWindow().setWidth(Util.unsignedConstraintValue(w.getWidth(), getMinWidth(), getMaxWidth())); if( getScene() != null && getScene().getWindow() != null ) { Window w = getScene().getWindow(); getScene().getWindow().setHeight(Util.unsignedConstraintValue(w.getHeight(), getMinHeight(), getMaxHeight()));
private static IPreferencesService getPreferenceService() { if( preferenceService == null ) { preferenceService = Util.lookupService(IPreferencesService.class); } return preferenceService; }