@SuppressWarnings("all") @Override public Subscription observePath(URI uri, BiConsumer<Kind, URI> consumer) { try { return observePath(Paths.get(new java.net.URI(uri.toString())), (k, p) -> consumer.accept(k, URI.create(p.toUri().toString()))); } catch (URISyntaxException e) { throw new RuntimeException(e); } }
/** * Extract the file suffix * * @param uri * the uri * @return the suffix */ @Nullable public static String suffix(@NonNull URI uri) { String last = uri.lastSegment(); if (last == null) { return null; } int idx = last.lastIndexOf('.'); if (idx != -1) { return last.substring(idx + 1).toLowerCase(); } return null; } }
@SuppressWarnings("null") @Override public Node getGraphicNode(URI uri) throws IOException { if( uri.isPlatformPlugin() ) { Bundle b = org.eclipse.core.runtime.Platform.getBundle(uri.segment(1)); if( b != null ) { StringBuilder sb = new StringBuilder(); for (int i = 2; i < uri.segmentCount(); i++) { if (sb.length() != 0) { sb.append("/"); //$NON-NLS-1$ } sb.append(uri.segment(i)); } FXMLLoader loader = new FXMLLoader(); loader.setClassLoader(b.adapt(BundleWiring.class).getClassLoader()); URL url = b.getResource(sb.toString()); loader.setLocation(url); return loader.load(); } else { throw new IOException("Unknown bundle '"+uri.segment(1)+"'"); //$NON-NLS-1$ //$NON-NLS-2$ } } else { return FXMLLoader.load(new URL(uri.toString())); } } }
part = modelService.createModelElement(MPart.class); part.setCloseable(true); part.setLabel(URI.create(uri).lastSegment()); String editorBundleURI = editorUrlProvider .stream()
/** * Split the query params into a {@link Map} * * @param uri * the uri * @return the map */ @NonNull public static Map<String, String> parseQuery(@NonNull URI uri) { Map<String, String> params = new HashMap<>(); StringTokenizer tk = new StringTokenizer(uri.query(), "&"); //$NON-NLS-1$ while (tk.hasMoreTokens()) { String element = tk.nextToken(); int idx = element.indexOf('='); params.put(element.substring(0, idx), element.substring(idx + 1)); } return params; }
if (uri.hasQuery()) { String provider = Util.getQueryValue(uri, "providerName"); //$NON-NLS-1$ if (provider != null) {
/** * Get query param with the given name * * @param uri * the uri * @param name * the name * @return the value */ @Nullable public static String getQueryValue(@NonNull URI uri, @NonNull String name) { StringTokenizer tk = new StringTokenizer(uri.query(), "&"); //$NON-NLS-1$ String searchValue = name + "="; //$NON-NLS-1$ while (tk.hasMoreTokens()) { String element = tk.nextToken(); if (element.startsWith(searchValue)) { return element.substring(element.indexOf('=') + 1); } } return null; }
if (uri.hasQuery()) { String provider = Util.getQueryValue(uri, "providerName"); //$NON-NLS-1$ if (provider != null) {
@SuppressWarnings("null") @NonNull private static URI replaceDynamicValues(@NonNull URI uri, @NonNull Map<@NonNull String, @NonNull String> dynamicMap) { String s = uri.toString(); s = StrSubstitutor.replace(s, dynamicMap); return URI.create(s); } }