Java 类java.util.prefs.PreferencesFactory 实例源码

项目:vars    文件:AnnotationFrameController.java   
/**
 * Updates the image URL's for all the CameraData objects in a VideoArchive
 * so that local references are converted to http URL's
 * @param videoArchive
 */
public void updateCameraData(VideoArchive videoArchive) {
    PreferencesFactory preferencesFactory = Lookup.getPreferencesFactory();
    UserAccount userAccount = (UserAccount) Lookup.getUserAccountDispatcher().getValueObject();
    if (videoArchive != null &&
            preferencesFactory instanceof VarsUserPreferencesFactory &&
            userAccount != null) {
        VarsUserPreferencesFactory vpf = (VarsUserPreferencesFactory) preferencesFactory;
        PreferencesService preferencesService = new PreferencesService(vpf);
        File imageTarget = preferencesService.findImageTarget(userAccount.getUserName(), preferencesService.getHostname());
        URL imageTargetMapping = preferencesService.findImageTargetMapping(userAccount.getUserName(),
                preferencesService.getHostname());
        try {
            toolBelt.getPersistenceController().updateCameraDataUrls(videoArchive, imageTarget, imageTargetMapping);
        } catch (MalformedURLException ex) {
            EventBus.publish(Lookup.TOPIC_NONFATAL_ERROR, ex);
        }
    }
}
项目:javify    文件:NodeReader.java   
public NodeReader(Reader r, PreferencesFactory factory) {
    if(r instanceof BufferedReader) {
        br = (BufferedReader) r;
    } else {
        br = new BufferedReader(r);
    }
    this.factory = factory;
}
项目:jvm-stm    文件:NodeReader.java   
public NodeReader(Reader r, PreferencesFactory factory) {
    if(r instanceof BufferedReader) {
        br = (BufferedReader) r;
    } else {
        br = new BufferedReader(r);
    }
    this.factory = factory;
}
项目:cross-preferences    文件:PreferencesAcceptanceTest.java   
protected PreferencesAcceptanceTest(Class<F> factoryClass,
                                    Class<P> preferencesClass,
                                    long delay) {
    super(delay);
    System.setProperty(PreferencesFactory.class.getName(), factoryClass.getName());
    this.factoryClass = factoryClass;
    this.preferencesClass = preferencesClass;
}
项目:JamVM-PH    文件:NodeReader.java   
public NodeReader(Reader r, PreferencesFactory factory) {
    if(r instanceof BufferedReader) {
        br = (BufferedReader) r;
    } else {
        br = new BufferedReader(r);
    }
    this.factory = factory;
}
项目:classpath    文件:NodeReader.java   
public NodeReader(Reader r, PreferencesFactory factory) {
    if(r instanceof BufferedReader) {
        br = (BufferedReader) r;
    } else {
        br = new BufferedReader(r);
    }
    this.factory = factory;
}
项目:vars    文件:VarsJpaModule.java   
public void configure(Binder binder) {

        /*
         * Binding an iso8601 data format
         */
        final DateFormat dateFormatISO = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'") {{
            setTimeZone(TimeZone.getTimeZone("UTC"));
        }};
        binder.bind(DateFormat.class).toInstance(dateFormatISO);

        // Bind the EntityManagerFactories
        binder.bind(EntityManagerFactory.class).annotatedWith(Names.named("annotationPersistenceUnit")).toInstance(Persistence.createEntityManagerFactory(annotationPersistenceUnit));
        binder.bind(EntityManagerFactory.class).annotatedWith(Names.named("knowledgebasePersistenceUnit")).toInstance(Persistence.createEntityManagerFactory(knowledgebasePersistenceUnit));
        binder.bind(EntityManagerFactory.class).annotatedWith(Names.named("miscPersistenceUnit")).toInstance(Persistence.createEntityManagerFactory(miscPersistenceUnit));

        // Bind annotation object and DAO factories
        binder.bind(AnnotationDAOFactory.class).to(AnnotationDAOFactoryImpl.class).in(Scopes.SINGLETON);
        binder.bind(AnnotationFactory.class).to(AnnotationFactoryImpl.class);
        binder.bind(AnnotationPersistenceService.class).to(AnnotationPersistenceServiceImpl.class).in(Scopes.SINGLETON);
        binder.bind(ExternalDataPersistenceService.class).to(EXPDPersistenceService.class);
        binder.bind(KnowledgebaseDAOFactory.class).to(KnowledgebaseDAOFactoryImpl.class).in(Scopes.SINGLETON);
        binder.bind(KnowledgebaseFactory.class).to(KnowledgebaseFactoryImpl.class);
        binder.bind(KnowledgebasePersistenceService.class).to(KnowledgebasePersistenceServiceImpl.class);
        binder.bind(MiscDAOFactory.class).to(MiscDAOFactoryImpl.class).in(Scopes.SINGLETON);
        binder.bind(MiscFactory.class).to(MiscFactoryImpl.class);
        binder.bind(PersistenceCacheProvider.class).to(JPACacheProvider.class);
        binder.bind(QueryPersistenceService.class).to(QueryPersistenceServiceImpl.class);
        binder.bind(VarsUserPreferencesFactory.class).to(VarsUserPreferencesFactoryImpl.class).in(Scopes.SINGLETON);
        binder.bind(PreferencesFactory.class).toProvider(PreferenceFactoryProvider.class);

    }
项目:vars    文件:ImagePreferencesPanel.java   
/**
 * Create the panel
 *
 * @param preferencesFactory
 */
public ImagePreferencesPanel(PreferencesFactory preferencesFactory) {
    super();
    this.controller = new ImagePreferencesPanelController(this, preferencesFactory);

    try {
        initialize();
    }
    catch (Exception e) {
        log.warn("Failed to initialize!", e);
    }
}
项目:vars    文件:PreferencesFrame.java   
/**
 * Create the frame
 */
@Inject
public PreferencesFrame(PreferencesFactory preferencesFactory) {
    super();
    this.preferencesFactory = preferencesFactory;
    setBounds(100, 100, 500, 375);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    try {
        initialize();
    }
    catch (Throwable e) {
        e.printStackTrace();
    }
}
项目:javify    文件:NodeReader.java   
public NodeReader(InputStream is, PreferencesFactory factory) {
    this(new InputStreamReader(is), factory);
}
项目:jvm-stm    文件:NodeReader.java   
public NodeReader(InputStream is, PreferencesFactory factory) {
    this(new InputStreamReader(is), factory);
}
项目:JamVM-PH    文件:NodeReader.java   
public NodeReader(InputStream is, PreferencesFactory factory) {
    this(new InputStreamReader(is), factory);
}
项目:spring-rich-client    文件:PreferencesSettingsFactory.java   
public PreferencesFactory getPreferencesFactory() {
    return preferencesFactory;
}
项目:spring-rich-client    文件:PreferencesSettingsFactory.java   
public void setPreferencesFactory(PreferencesFactory preferencesFactory) {
    this.preferencesFactory = preferencesFactory;
}
项目:classpath    文件:NodeReader.java   
public NodeReader(InputStream is, PreferencesFactory factory) {
    this(new InputStreamReader(is), factory);
}
项目:vars    文件:VideoConnectionPreferencesPanelController.java   
public VideoConnectionPreferencesPanelController(VideoConnectionPreferencesPanel panel, PreferencesFactory preferencesFactory) {
    this.panel = panel;
    preferencesService = new PreferencesService(preferencesFactory);
}
项目:vars    文件:VideoConnectionPreferencesPanel.java   
public VideoConnectionPreferencesPanel(PreferencesFactory preferencesFactory) {
    this.controller = new VideoConnectionPreferencesPanelController(this, preferencesFactory);
    initialize();
}
项目:vars    文件:AnnotationFrameController.java   
private void persistPreferences(Preferences userPreferences) {
    if (userPreferences != null) {

        // Persist UI preferences
        String hostName = null;
        try {
            hostName = InetAddress.getLocalHost().getHostName();
        }
        catch (UnknownHostException ex) {
            throw new VARSException("Unable to get hostname", ex);
        }

        String className = getClass().getCanonicalName();
        Preferences preferences = userPreferences.node(hostName).node(className);

        // -- Save AnnotationFrame size
        Dimension size = annotationFrame.getSize();
        preferences.putInt(PREF_WIDTH, size.width);
        preferences.putInt(PREF_HEIGHT, size.height);

        // -- Save TableScrollPane size();
        Dimension tablePaneSize = annotationFrame.getTableScrollPane().getSize();
        preferences.putInt(PREF_TABLE_WIDTH, tablePaneSize.width);
        preferences.putInt(PREF_TABLE_HEIGHT, tablePaneSize.height);

        // -- Save OuterSplitPane split location
        int outerDividerLocation = annotationFrame.getOuterSplitPane().getDividerLocation();
        preferences.putInt(PREF_OUTER_DIVIDER_LOCATION, outerDividerLocation);

        // -- Save InnerSplitPane split location
        int innerDividerLocation = annotationFrame.getInnerSplitPane().getDividerLocation();
        preferences.putInt(PREF_INNER_DIVIDER_LOCATION, innerDividerLocation);

        // -- Save AllControlsSplitPane location
        int allControlsDividerLocation = annotationFrame.getAllControlsSplitPane().getDividerLocation();
        preferences.putInt(PREF_ALLCONTROLS_DIVIDER_LOCATION, allControlsDividerLocation);

        // -- Save ControlSplitPane location
        int controlsDividerLocation = annotationFrame.getControlsPanelSplitPane().getDividerLocation();
        preferences.putInt(PREF_CONTROLS_DIVIDER_LOCATION, controlsDividerLocation);

        // -- Save video control info
        Injector injector = (Injector) Lookup.getGuiceInjectorDispatcher().getValueObject();
        PreferencesFactory preferencesFactory = injector.getInstance(PreferencesFactory.class);
        PreferencesService preferencesService = new PreferencesService(preferencesFactory);
        VideoControlService videoControlService = (VideoControlService) Lookup.getVideoControlServiceDispatcher().getValueObject();
        try {
            preferencesService.persistLastVideoConnectionId(preferencesService.getHostname(),
                    videoControlService.getVideoControlInformation().getVideoConnectionID());
        }
        catch (NullPointerException e) {
            log.info("Did not save Last VideoConnection ID preference. Most likely this " +
                    "was attempted after the video connection was closed");
        }

    }
}
项目:vars    文件:AnnotationFrameController.java   
private void loadPreferences(Preferences userPreferences) {
    if (userPreferences != null) {

        String hostName = null;
        try {
            hostName = InetAddress.getLocalHost().getHostName();
        }
        catch (UnknownHostException ex) {
            log.warn("Unable to get hostname, defaulting to 'localhost'.", ex);
            hostName = "localhost";
        }

        String className = getClass().getCanonicalName();

        Preferences hostPreferences = userPreferences.node(hostName);
        Preferences preferences = hostPreferences.node(className);

        // -- Set AnnotationFrame size
        Dimension currentSize = annotationFrame.getSize();
        int width = preferences.getInt(PREF_WIDTH, currentSize.width);
        int height = preferences.getInt(PREF_HEIGHT, currentSize.height);

        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        width = width <= screenSize.width ? width : screenSize.width;
        height = height <= screenSize.height ? height : screenSize.height;
        annotationFrame.setSize(width, height);
        annotationFrame.validate();

        // -- Set TableScrollPane size
        int tablePaneWidth = preferences.getInt(PREF_TABLE_WIDTH, -1);
        int tablePaneHeight = preferences.getInt(PREF_TABLE_HEIGHT, -1);
        if (tablePaneWidth > 0 && tablePaneHeight > 0) {
            annotationFrame.getTableScrollPane().setPreferredSize(new Dimension(tablePaneWidth, tablePaneHeight));
        }

        // -- Set OuterSplitPane divider location
        int outerDividerLocation = preferences.getInt(PREF_OUTER_DIVIDER_LOCATION, -1);
        if (outerDividerLocation > 0) {
            annotationFrame.getOuterSplitPane().setDividerLocation(outerDividerLocation);
        }

        // -- Set innerSplitPane divider location
        int innerDividerLocation = preferences.getInt(PREF_INNER_DIVIDER_LOCATION, -1);
        if (innerDividerLocation > 0) {
            annotationFrame.getInnerSplitPane().setDividerLocation(innerDividerLocation);
        }

        // -- Set AllControlsSplitPane divider location
        int allControlsDividerLocation = preferences.getInt(PREF_ALLCONTROLS_DIVIDER_LOCATION, -1);
        if (allControlsDividerLocation > 0) {
            annotationFrame.getAllControlsSplitPane().setDividerLocation(allControlsDividerLocation);
        }

        // -- Set ControlsSplitPane divider location
        int controlsDividerLocation = preferences.getInt(PREF_CONTROLS_DIVIDER_LOCATION, -1);
        if (controlsDividerLocation > 0) {
            annotationFrame.getControlsPanelSplitPane().setDividerLocation(controlsDividerLocation);
        }

        // -- Load video control info
        Injector injector = (Injector) Lookup.getGuiceInjectorDispatcher().getValueObject();
        PreferencesFactory preferencesFactory = injector.getInstance(PreferencesFactory.class);
        PreferencesService preferencesService = new PreferencesService(preferencesFactory);
        if (preferencesService.findAutoconnectVcr(preferencesService.getHostname())) {
            String videoID = preferencesService.findLastVideoConnectionId(preferencesService.getHostname());
            VideoControlService videoControlService;
            try {
                videoControlService = VideoControlServiceFactory.newVideoControlService(videoID);
            }
            catch (Exception e) {
                log.warn("Failed to create a VideoControlService for " + videoID);
                videoControlService = new DoNothingVideoControlService();
            }
            Lookup.getVideoControlServiceDispatcher().setValueObject(videoControlService);
        }

    }
}
项目:spring-richclient    文件:PreferencesSettingsFactory.java   
public PreferencesFactory getPreferencesFactory() {
    return preferencesFactory;
}
项目:spring-richclient    文件:PreferencesSettingsFactory.java   
public void setPreferencesFactory(PreferencesFactory preferencesFactory) {
    this.preferencesFactory = preferencesFactory;
}
项目:vars    文件:Lookup.java   
/**
 * @return The {@link PreferencesFactory} object used to fetch preferences.
 * The PreferencesFactory object should be configured in your Guice
 * injector Module
 */
public static PreferencesFactory getPreferencesFactory() {
    return PREFERENCES_FACTORY;
}
项目:vars    文件:ImagePreferencesPanelController.java   
/**
 * Constructs ...
 *
 * @param panel
 * @param preferencesFactory
 */
public ImagePreferencesPanelController(ImagePreferencesPanel panel, PreferencesFactory preferencesFactory) {
    this.panel = panel;
    this.preferencesService = new PreferencesService(preferencesFactory);

}