Java Code Examples for java.util.prefs.Preferences#userNodeForPackage()

The following examples show how to use java.util.prefs.Preferences#userNodeForPackage() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LicenseVerifier.java    From hugegraph with Apache License 2.0 5 votes vote down vote up
private LicenseParam initLicenseParam(LicenseVerifyParam param) {
    Preferences preferences = Preferences.userNodeForPackage(
                              LicenseVerifier.class);
    CipherParam cipherParam = new DefaultCipherParam(
                              param.storePassword());
    KeyStoreParam keyStoreParam = new DefaultKeyStoreParam(
                                  LicenseVerifier.class,
                                  param.publicKeyPath(),
                                  param.publicAlias(),
                                  param.storePassword(),
                                  null);
    return new DefaultLicenseParam(param.subject(), preferences,
                                   keyStoreParam, cipherParam);
}
 
Example 2
Source File: DualSub.java    From dualsub with GNU General Public License v3.0 5 votes vote down vote up
private void loadProperties() throws IOException {
	// Load properties
	properties = new Properties();
	InputStream inputStream = Thread.currentThread().getContextClassLoader()
			.getResourceAsStream("dualsub.properties");
	Reader reader = new InputStreamReader(inputStream, Charset.ISO88591);
	properties.load(reader);
	Font.setProperties(properties);

	// Instantiate preferences
	preferences = Preferences.userNodeForPackage(DualSub.class);
}
 
Example 3
Source File: FileChooser.java    From beast-mcmc with GNU Lesser General Public License v2.1 5 votes vote down vote up
public FileChooser(Class<?> clazz) {
	_prefs = Preferences.userNodeForPackage(clazz);
	_key = "currentDir-"
		+ clazz.getName().substring(clazz.getName().lastIndexOf('.') + 1);
	String path = _prefs.get(_key, null);

	if (path != null) {
		setCurrentDirectory(new File(path));
	}
}
 
Example 4
Source File: MainActivity.java    From Raccoon with Apache License 2.0 5 votes vote down vote up
/**
 * Must be called to connect to an archive.
 * 
 * @param archive
 *          the archive to mount.
 */
protected void doMount(Archive archive) {
	this.archive = archive;
	archive.getRoot().mkdirs();
	new DownloadLogger(archive).clear();
	setTitle("Raccoon - " + archive.getRoot().getAbsolutePath()); //$NON-NLS-1$
	views.removeAll();
	if (archive.getAndroidId().length() == 0) {
		views.addTab(Messages.getString("MainActivity.16"), InitView.create(this, archive)); //$NON-NLS-1$
	}
	else {
		searchView = SearchView.create(this, archive);
		update.setEnabled(true);
		views.addTab(Messages.getString("MainActivity.17"), searchView); //$NON-NLS-1$
		views.addChangeListener(searchView);
		search.setEnabled(true);
		downloads.setEnabled(true);
		importArchive.setEnabled(true);
		exportArchive.setEnabled(true);
		downloadListScroll = new JScrollPane();
		downloadListScroll.setViewportView(downloadList);
		downloadListScroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
		views.addTab(Messages.getString("MainActivity.18"), downloadListScroll); //$NON-NLS-1$
		Preferences prefs = Preferences.userNodeForPackage(getClass());
		prefs.put(LASTARCHIVE, archive.getRoot().getAbsolutePath());
		SwingUtilities.invokeLater(searchView);
	}
}
 
Example 5
Source File: App.java    From usergrid with Apache License 2.0 5 votes vote down vote up
public void loadPrefs() {
    prefs = Preferences.userNodeForPackage( org.apache.usergrid.launcher.App.class );
    initializeDatabaseOnStart = prefs.getBoolean( "initializeDatabaseOnStart", true );
    startDatabaseWithServer = prefs.getBoolean( "startDatabaseWithServer", true );
    adminUserEmail = prefs.get( "adminUserEmail", "[email protected]" );
    autoLogin = prefs.getBoolean( "autoLogin", true );
}
 
Example 6
Source File: Renderer.java    From tribaltrouble with GNU General Public License v2.0 5 votes vote down vote up
private static String readOrSetPreference(String key, String value) {
	try {
		Preferences pref = Preferences.userNodeForPackage(com.oddlabs.tt.render.Renderer.class);
		String result = pref.get(key, null);
		if (result == null) {
			pref.put(key, value);
			return value;
		} else
			return result;
	} catch (Exception e) {
		System.out.println("Could not access preferences");
		return value;
	}
}
 
Example 7
Source File: VehicleCommanderJFrame.java    From defense-solutions-proofs-of-concept with Apache License 2.0 5 votes vote down vote up
private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
    map.dispose();
    
    //Store window location and size
    Preferences prefs = Preferences.userNodeForPackage(getClass());
    prefs.putInt(KEY_FRAME_EXTENDED_STATE, getExtendedState());
    Dimension size = getSize();
    prefs.putInt(KEY_FRAME_WIDTH, size.width);
    prefs.putInt(KEY_FRAME_HEIGHT, size.height);
    java.awt.Point location = getLocation();
    prefs.putInt(KEY_FRAME_LOCATION_X, (int) Math.round(location.getX()));
    prefs.putInt(KEY_FRAME_LOCATION_Y, (int) Math.round(location.getY()));
}
 
Example 8
Source File: GtpShell.java    From FancyBing with GNU General Public License v3.0 4 votes vote down vote up
public GtpShell(Frame owner, Listener listener,
                MessageDialogs messageDialogs)
{
    super(owner, i18n("TIT_SHELL"));
    m_messageDialogs = messageDialogs;
    m_listener = listener;
    Preferences prefs = Preferences.userNodeForPackage(getClass());
    m_historyMin = prefs.getInt("history-min", 2000);
    m_historyMax = prefs.getInt("history-max", 3000);
    JPanel panel = new JPanel(new BorderLayout());
    getContentPane().add(panel, BorderLayout.CENTER);
    m_gtpShellText = new GtpShellText(m_historyMin, m_historyMax, false);
    CaretListener caretListener = new CaretListener()
        {
            public void caretUpdate(CaretEvent event)
            {
                if (m_listener == null)
                    return;
                // Call the callback only if the selected text has changed.
                // This avoids that the callback is called multiple times
                // if the caret position changes, but the text selection
                // was null before and after the change (see also bug
                // #2964755)
                String selectedText = m_gtpShellText.getSelectedText();
                if (! ObjectUtil.equals(selectedText, m_selectedText))
                {
                    m_listener.textSelected(selectedText);
                    m_selectedText = selectedText;
                }
            }
        };
    m_gtpShellText.addCaretListener(caretListener);
    m_scrollPane =
        new JScrollPane(m_gtpShellText,
                        JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
                        JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    if (Platform.isMac())
        // Default Apple L&F uses no border, but Quaqua 3.7.4 does
        m_scrollPane.setBorder(null);
    panel.add(m_scrollPane, BorderLayout.CENTER);
    panel.add(createCommandInput(), BorderLayout.SOUTH);
    setMinimumSize(new Dimension(160, 112));
    pack();
}
 
Example 9
Source File: PickMIDlet.java    From CodenameOne with GNU General Public License v2.0 4 votes vote down vote up
private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
    SwingUtilities.windowForComponent(this).dispose();
    Preferences pref = Preferences.userNodeForPackage(ResourceEditorView.class);
    pref.put("jar", jarFile.getText());
    pref.put("midlet", (String)midletPicker.getSelectedItem());
}
 
Example 10
Source File: WorldGenerationBencher.java    From amidst with GNU General Public License v3.0 4 votes vote down vote up
private Application startAmidst() throws FormatException, IOException {
	AmidstSettings settings = new AmidstSettings(Preferences.userNodeForPackage(getClass()));
	CommandLineParameters params = new CommandLineParameters();
	AmidstMetaData metadata = Amidst.createMetadata();
	return new PerApplicationInjector(params, metadata, settings).getApplication();
}
 
Example 11
Source File: PrefsConfigurationStorage.java    From tcMenu with Apache License 2.0 4 votes vote down vote up
@Override
public String getRegisteredKey() {
    Preferences prefs = Preferences.userNodeForPackage(MenuEditorController.class);
    return prefs.get(REGISTERED_KEY, "");
}
 
Example 12
Source File: FileChooser.java    From mappwidget with Apache License 2.0 4 votes vote down vote up
public static void savePath(Composite composite, String key, String value)
{
	Preferences prefs = Preferences.userNodeForPackage(composite.getClass());
	prefs.put(key, value);
}
 
Example 13
Source File: Settings.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public static Preferences get() {
    return Preferences.userNodeForPackage(Settings.class);
}
 
Example 14
Source File: StartScreen.java    From WorldGrower with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Launch the application.
 */
public static void main(String[] args) {
	setSwingSystemProperties();
	ExceptionHandler.registerExceptionHandler();
	
	UIManager.put("Tree.rendererFillBackground", false);
	UIManager.getDefaults().put("MenuItem.disabledForeground", ColorPalette.DISABLED_FOREGROUND_COLOR);
	UIManager.getDefaults().put("Button.disabledForeground", ColorPalette.DISABLED_FOREGROUND_COLOR);
	UIManager.getDefaults().put("Button.disabledText", ColorPalette.DISABLED_FOREGROUND_COLOR);
	UIManager.getDefaults().put("Label.disabledForeground", ColorPalette.DISABLED_FOREGROUND_COLOR);
	UIManager.getDefaults().put("CheckBox.disabledText", ColorPalette.DISABLED_FOREGROUND_COLOR);		
	UIManager.put("ToolTip.font", new FontUIResource(Fonts.FONT));
	UIManager.put("ToolTip.background", Color.BLACK);
	UIManager.put("ToolTip.foreground", Color.WHITE);
	UIManager.put("ToolTip.border", new LineBorder(Color.BLACK));
	
	Color menuSelectionBackground = new Color(255, 0, 0, 0);
	Color menuSelectionForeground = Color.BLACK;
	UIManager.put("MenuItem.selectionBackground", menuSelectionBackground);
	UIManager.put("MenuItem.selectionForeground", menuSelectionForeground);
	
	UIManager.put("Menu.selectionBackground", menuSelectionBackground);
	UIManager.put("Menu.selectionForeground", menuSelectionForeground);
	
	Color acceleratorForeground = Color.WHITE;
	Color acceleratorSelectionForeground = Color.BLACK;
	UIManager.put("MenuItem.acceleratorForeground", acceleratorForeground);
	UIManager.put("MenuItem.acceleratorSelectionForeground", acceleratorSelectionForeground);
	
	UIManager.put("Menu.acceleratorForeground", acceleratorForeground);
	UIManager.put("Menu.acceleratorSelectionForeground", acceleratorSelectionForeground);
	
	Preferences preferences = Preferences.userNodeForPackage(StartScreen.class);
	loadDefaultSoundOutput(preferences);
	ghostImageIds = loadImages();
	loadSounds(preferences);
	loadMusic(preferences);
	CustomPopupFactory.setPopupFactory();
	EventQueue.invokeLater(new Runnable() {
		public void run() {
			try {
				StartScreen window = new StartScreen(imageInfoReader, soundIdReader, musicPlayer);
				window.frame.setVisible(true);
			} catch (Exception e) {
				ExceptionHandler.handle(e);
			}
		}
	});
}
 
Example 15
Source File: CheckUserPrefFirst.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    Preferences prefs = Preferences.userNodeForPackage(CheckUserPrefFirst.class);
    prefs.put("Check", "Success");
    prefs.flush();
}
 
Example 16
Source File: MapImage.java    From triplea with GNU General Public License v3.0 4 votes vote down vote up
public static void setPropertyUnitFactoryDamageColor(final Color color) {
  final Preferences pref = Preferences.userNodeForPackage(MapImage.class);
  pref.putInt(PROPERTY_UNIT_FACTORY_DAMAGE_COLOR_STRING, color.getRGB());
  propertyUnitFactoryDamageColor = color;
}
 
Example 17
Source File: TheApp.java    From opensim-gui with Apache License 2.0 4 votes vote down vote up
public static Preferences getCurrentVersionPreferences() {
    return Preferences.userNodeForPackage(TheApp40.class);
}
 
Example 18
Source File: CheckUserPrefFirst.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    Preferences prefs = Preferences.userNodeForPackage(CheckUserPrefFirst.class);
    prefs.put("Check", "Success");
    prefs.flush();
}
 
Example 19
Source File: UserDiscoverer.java    From neoscada with Eclipse Public License 1.0 4 votes vote down vote up
@Override
protected Preferences getNode ()
{
    return Preferences.userNodeForPackage ( ConnectionStore.class );
}
 
Example 20
Source File: AbstractTransformMeta.java    From hop with Apache License 2.0 4 votes vote down vote up
/**
 * Read properties from preferences.
 */
public void readFromPreferences() {
  final Preferences node = Preferences.userNodeForPackage( this.getClass() );
  this.getProperties().walk( new ReadFromPreferences( node ) );
}