public BundleLocale() { this(new BundleApplicationResourcesFinder().bundle()); }
/** * This function works only with executables stored in the * <code>Contents/Library/LoginItems</code> directory of the bundle. */ @Override public boolean register(final Application application) { final Local helper = new FinderLocal(new BundleApplicationResourcesFinder().find().getParent(), String.format("Library/LoginItems/%s.app", application.getName())); if(!finder.register(helper)) { log.warn(String.format("Failed to register %s (%s) with launch services", helper, finder.getDescription(application.getIdentifier()))); } if(!ServiceManagementLibrary.SMLoginItemSetEnabled(application.getIdentifier(), true)) { log.warn(String.format("Failed to register %s as login item", application)); return false; } return true; }
@Override public Local find() { final NSBundle b = this.bundle(); if(null == b) { log.warn("No main bundle found"); return new TemporarySupportDirectoryFinder().find(); } final Local folder = new FinderLocal(b.resourcePath()); if(log.isDebugEnabled()) { log.debug(String.format("Use folder %s for application resources directory", folder)); } return folder; }
public NSBundle bundle() { if(cached != null) { return cached; } if(log.isInfoEnabled()) { log.info("Loading application bundle resources"); } final NSBundle main = NSBundle.mainBundle(); if(null == main) { cached = null; } else { final Local executable = new FinderLocal(main.executablePath()); cached = this.bundle(main, executable); } return cached; }