public final RController sleep(long millis) { BlockCondition<Void> b = new BlockCondition<>(); this.threadSynchronize.scheduleExecution(millis, () -> b.release(null)); this.threadSynchronize.block(b); return this; } }
@SuppressWarnings("null") @Override public InputStream getInputStream() throws IOException { return this.h.createStream(getURL()); } }
/** * Read the input stream into a string * * @param in * the stream * @param charset * the charset to be used * @return the string */ public static String readToString(InputStream in, Charset charset) { return readToString(in, 1024, charset); }
@Override public void changed(ObservableValue<? extends T> observable, T oldValue, T newValue) { if (this.currentSubscription != null) { this.currentSubscription.dispose(); } this.currentSubscription = scheduleExecution(delay, () -> { consumer.accept(newValue); this.currentSubscription = null; }); } };
@Override protected void lastListenerRemoved(){ if(this.currentSubscription != null){ this.currentSubscription.dispose(); this.currentSubscription = null; } } }
/** * Register a service * * @param service * the service * @param properties * the properties */ protected void registerService(S service, Map<String, Object> properties) { this.registry.registerObject(getOSGiServiceRank(properties), service); }
private static ValueSerializer getValueSerializer() { if( serializer == null ) { serializer = Util.lookupService(ValueSerializer.class); } return serializer; }
/** * Unregister a service * * @param service * the service */ protected void unregisterService(S service) { this.registry.unregisterObject(service); } }
@Override public int compareTo(CompareableService<S> o) { int i1; int i2; if (this.instance instanceof RankedService && o.instance instanceof RankedService) { i1 = ((RankedService) this.instance).getRanking(); i2 = ((RankedService) o.instance).getRanking(); } else { i1 = getRanking(this.r); i2 = getRanking(o.r); } return -1 * Integer.compare(i1, i2); } }
/** * Extract the rank from the OSGi-Service properties * * @param properties * the properties * @return the rank */ public static int getOSGiServiceRank(Map<String, Object> properties) { return getServiceRank(properties, "service.ranking"); //$NON-NLS-1$ }
public final RController block(BlockCondition<Void> b) { threadSynchronize.block(b); return this; }
/** * Wraps a runnable so that it is called on the UI thread. * <p> * This is handy if you pass a {@link Runnable} as callback into some async * API * </p> * * @param r * the runnable to wrap * @return a new runnable who invokes the real runnable on the UI thread */ default Runnable wrap(Runnable r) { return () -> asyncExec(r); }
/** * Create a platform plugin URI as speced by {@link #isPlatformPlugin()} * * @param symbolicBundleName * the symbolic name of the bundle * @param path * the path * @return the uri */ public static URI createPlatformPluginURI(String symbolicBundleName, String path) { return new SimpleURI("platform:/plugin/" + symbolicBundleName + "/" //$NON-NLS-1$ //$NON-NLS-2$ + path); } }
/** * Register an object * * @param rank * the rank of the object * @param object * the object */ public synchronized void registerObject(int rank, T object) { this.objectList.add(new Registration<>(rank, object)); }
/** * Create a new uri * * @param uri * the uri */ public SimpleURI(@NonNull String uri) { this.uri = uri; parseURI(uri); }
public void registerModelProvider(ConfigurationModelProvider provider, Map<String, Object> properties) { modelProviders.registerObject(getOSGiServiceRank(properties), provider); }
private static ObjectSerializer getObjectSerializer() { if( objectSerializer == null ) { objectSerializer = Util.lookupService(ObjectSerializer.class); } return objectSerializer; }
public void unregisterModelProvider(ConfigurationModelProvider provider) { modelProviders.unregisterObject(provider); }
private static IPreferencesService getPreferenceService() { if( preferenceService == null ) { preferenceService = Util.lookupService(IPreferencesService.class); } return preferenceService; }
public synchronized void unregisterInputContextProvider(InputContextProvider provider) { providerList.unregisterObject(provider); }