final AssociationService associationService = new AssociationService(); final ServiceBuilder<AssociationService> associationServiceBuilder = context.getServiceTarget().addService(AssociationService.SERVICE_NAME, associationService); associationServiceBuilder.addDependency(DeploymentRepositoryService.SERVICE_NAME, DeploymentRepository.class, associationService.getDeploymentRepositoryInjector())
AssociationService serv = new AssociationService(); Association logassoc = serv.getFileExtensionAssociation("LOG"); // .log ? if (logassoc == null) { return; // .log not a registered file type. }
import org.jdesktop.jdic.filetypes.*; AssociationService serv = new AssociationService();
import org.jdesktop.jdic.filetypes.*; AssociationService serv = new AssociationService(); Association logassoc = new Association();
boolean editDefaultApplication(){ AssociationService serv = new AssociationService(); //try to remove old association Association logassoc = serv.getFileExtensionAssociation(".mp3"); try { serv.unregisterUserAssociation(logassoc); } catch (java.lang.IllegalArgumentException | AssociationNotRegisteredException | RegisterFailedException e) { e.printStackTrace(); return false; } //add your own application as default logassoc.addFileExtension(".mp3"); logassoc.addAction(new org.jdesktop.jdic.filetypes.Action("open", "<path to wrapper executable>")); try { serv.registerUserAssociation(logassoc); } catch (java.lang.IllegalArgumentException | AssociationNotRegisteredException | RegisterFailedException e) { e.printStackTrace(); return false; } return true; }
AssociationService serv = new AssociationService(); Association logassoc = new Association(); logassoc.addFileExtension("DAN"); logassoc.addAction( new Action("open", "C:\\WINDOWS\\JAVA.EXE -jar C:\\dan.jar %1"));