public void register() { /* * Create the following Registry keys and values: * * Root Key Variable Value * ------------------ ------------ ------------ --------------------------------------------- * HKEY_CLASSES_ROOT protocol URL:name * URL Protocol * DefaultIcon executable,0 * shell * open * command executable "%1" */ SystemUtils.registryWriteText( HKCU, protocol, "", "URL:" + name); // Changed for testing purposes only SystemUtils.registryWriteText(HKCU, protocol, "URL Protocol", ""); SystemUtils.registryWriteText( HKCU, protocol + "\\DefaultIcon", "", "\"" + executable + "\",0"); // FTA: Once the file is associated, Here we can change the icon to a better // one SystemUtils.registryWriteText( HKCU, protocol + "\\shell\\open\\command", "", "\"" + executable + "\" \"%1\""); }
public boolean isRegistered() { Association f; try { f = SERVICE.getFileExtensionAssociation(extention); } catch (IllegalArgumentException iae) { // SEE: LWC-1170 LOG.warn("Can't check registration!", iae); return false; } if (f == null) return false; Action open = f.getActionByVerb(verb); if (open == null) return false; if (executable.equals(open.getCommand())) return true; return executable.equals(SystemUtils.getDefaultExtentionHandler(extention)) && executable.equals(SystemUtils.getDefaultMimeHandler(mimeType)); }
public boolean isAvailable() { try { // if no association at all, then it is available Association f = SERVICE.getFileExtensionAssociation(extention); if (f == null && f == SERVICE.getMimeTypeAssociation(mimeType)) return true; } catch (IllegalArgumentException iae) { // SEE: LWC-1170 // If JDIC bails on us, the registry might be a little confused... // so let's fix it by inserting ours. LOG.warn("Can't check availability!", iae); return true; } // still check for a default handler. String extHandler = SystemUtils.getDefaultExtentionHandler(extention); return ("".equals(extHandler) && "".equals(SystemUtils.getDefaultMimeHandler(mimeType))); }
public void register() { try { SERVICE.registerUserAssociation(association); SystemUtils.flushIconCache(); } catch (AssociationAlreadyRegisteredException ignore) { LOG.error("can't register", ignore); } catch (RegisterFailedException ignore) { LOG.error("can't register", ignore); } }
private void forceUnregister(Association f) { if (f == null) return; try { SERVICE.unregisterUserAssociation(f); SystemUtils.flushIconCache(); } catch (AssociationNotRegisteredException ignore) { LOG.error("can't unregister", ignore); } catch (RegisterFailedException ignore) { LOG.error("can't unregister", ignore); } }
@Override public void addNotify() { super.addNotify(); setAlwaysOnTop(true); SystemUtils.setWindowTopMost(this); }
public void unregister() { SystemUtils.registryDelete(HKCU, protocol); }
protected String get() throws IOException { String command = SystemUtils.registryReadText(HKCU, protocol + "\\shell\\open\\command", ""); return parsePath(command); }