List of usage examples for java.util.prefs Preferences putInt
public abstract void putInt(String key, int value);
From source file:burlov.ultracipher.swing.SwingGuiApplication.java
private void saveWindowState() { Preferences prefs = Preferences.userNodeForPackage(getClass()); prefs.putInt("size.x", mainFrame.getWidth()); prefs.putInt("size.y", mainFrame.getHeight()); prefs.putInt("pos.x", mainFrame.getX()); prefs.putInt("pos.y", mainFrame.getY()); }
From source file:com.moteiv.trawler.Trawler.java
private void savePrefs() { Preferences prefs = Preferences.userNodeForPackage(com.moteiv.trawler.Trawler.class); prefs.putBoolean(PREF_V_SAVE, vSave.isSelected()); prefs.putBoolean(PREF_V_BLINK, vBlink.isSelected()); prefs.putBoolean(PREF_V_LABELS, vLabels.isSelected()); prefs.putBoolean(PREF_E_LABELS, eLabels.isSelected()); prefs.putBoolean(PREF_E_FILTER, eFilter.isSelected()); prefs.putInt(PREF_V_DISPOSE, vDispose.getValue()); prefs.putInt(PREF_E_DISPOSE, eDispose.getValue()); }
From source file:org.syncany.plugins.php.PhpTransferManager.java
@SuppressWarnings("deprecation") private CloseableHttpClient getHttpClient() { try {//from www . j a v a 2s . c o m @SuppressWarnings("deprecation") SSLSocketFactory sf = new SSLSocketFactory(new TrustStrategy() { @Override public boolean isTrusted(X509Certificate[] chain, String authType) throws CertificateException { if (lastSite != null && !lastSite.equals("")) { Preferences prefs = Preferences.userRoot().node(this.getClass().getName()); int prevr = prefs.getInt(lastSite, -1); if (prevr == -1) { int r = JOptionPane.showConfirmDialog(null, lastSite + "'s SSL certificate is not trusted, do you want to accept it?", "Accept SSL Certificate?", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); logger.warning(lastSite + " not trusted, user answered " + r); prevr = r; prefs.putInt(lastSite, r); } logger.warning(lastSite + " not trusted, registered user answer: " + prevr); if (prevr == 0) { return true; } else { return false; } } else { return false; } } }); @SuppressWarnings("deprecation") SchemeRegistry registry = new SchemeRegistry(); registry.register(new Scheme("https", 443, sf)); @SuppressWarnings("deprecation") ClientConnectionManager ccm = new ThreadSafeClientConnManager(registry); return new DefaultHttpClient(ccm); } catch (Exception e) { return new DefaultHttpClient(); } }
From source file:PreferencesTest.java
public PreferencesFrame() { // get position, size, title from preferences Preferences root = Preferences.userRoot(); final Preferences node = root.node("/com/horstmann/corejava"); int left = node.getInt("left", 0); int top = node.getInt("top", 0); int width = node.getInt("width", DEFAULT_WIDTH); int height = node.getInt("height", DEFAULT_HEIGHT); setBounds(left, top, width, height); // if no title given, ask user String title = node.get("title", ""); if (title.equals("")) title = JOptionPane.showInputDialog("Please supply a frame title:"); if (title == null) title = ""; setTitle(title);//from w w w . j ava2s . c o m // set up file chooser that shows XML files final JFileChooser chooser = new JFileChooser(); chooser.setCurrentDirectory(new File(".")); // accept all files ending with .xml chooser.setFileFilter(new javax.swing.filechooser.FileFilter() { public boolean accept(File f) { return f.getName().toLowerCase().endsWith(".xml") || f.isDirectory(); } public String getDescription() { return "XML files"; } }); // set up menus JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar); JMenu menu = new JMenu("File"); menuBar.add(menu); JMenuItem exportItem = new JMenuItem("Export preferences"); menu.add(exportItem); exportItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { if (chooser.showSaveDialog(PreferencesFrame.this) == JFileChooser.APPROVE_OPTION) { try { OutputStream out = new FileOutputStream(chooser.getSelectedFile()); node.exportSubtree(out); out.close(); } catch (Exception e) { e.printStackTrace(); } } } }); JMenuItem importItem = new JMenuItem("Import preferences"); menu.add(importItem); importItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { if (chooser.showOpenDialog(PreferencesFrame.this) == JFileChooser.APPROVE_OPTION) { try { InputStream in = new FileInputStream(chooser.getSelectedFile()); Preferences.importPreferences(in); in.close(); } catch (Exception e) { e.printStackTrace(); } } } }); JMenuItem exitItem = new JMenuItem("Exit"); menu.add(exitItem); exitItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { node.putInt("left", getX()); node.putInt("top", getY()); node.putInt("width", getWidth()); node.putInt("height", getHeight()); node.put("title", getTitle()); System.exit(0); } }); }
From source file:org.domainmath.gui.MainFrame.java
public void saveFrameSize(int w, int h) { Preferences pr2 = Preferences.userNodeForPackage(this.getClass()); pr2.putInt("Frame_width", w); pr2.putInt("Frame_height", h); }
From source file:org.esa.snap.smart.configurator.PerformanceParameters.java
/** * Save the actual configuration//ww w. j av a2s . com * * @param confToSave The configuration to save */ synchronized static void saveConfiguration(PerformanceParameters confToSave) throws IOException, BackingStoreException { if (!loadConfiguration().getVMParameters().equals(confToSave.getVMParameters())) { confToSave.vmParameters.save(); } Config configuration = EngineConfig.instance().load(); Preferences preferences = configuration.preferences(); Path cachePath = confToSave.getCachePath(); if (!Files.exists(cachePath)) { Files.createDirectories(cachePath); } if (Files.exists(cachePath)) { preferences.put(SystemUtils.SNAP_CACHE_DIR_PROPERTY_NAME, cachePath.toAbsolutePath().toString()); } else { SystemUtils.LOG.severe("Directory for cache path does not exist"); } JAI ff = JAI.getDefaultInstance(); int parallelism = confToSave.getNbThreads(); //int defaultTileSize = confToSave.getDefaultTileSize(); int jaiCacheSize = confToSave.getCacheSize(); String tileWidth = confToSave.getTileWidth(); String tileHeight = confToSave.getTileHeight(); preferences.putInt(SystemUtils.SNAP_PARALLELISM_PROPERTY_NAME, parallelism); /*if(tileWidth == null) { preferences.remove(SYSPROP_READER_TILE_WIDTH); } else { preferences.put(SYSPROP_READER_TILE_WIDTH,tileWidth); } if(tileHeight == null) { preferences.remove(SYSPROP_READER_TILE_HEIGHT); } else { preferences.put(SYSPROP_READER_TILE_HEIGHT,tileHeight); }*/ preferences.putInt(PROPERTY_JAI_CACHE_SIZE, jaiCacheSize); preferences.flush(); // effective change of jai parameters JAIUtils.setDefaultTileCacheCapacity(jaiCacheSize); JAI.getDefaultInstance().getTileScheduler().setParallelism(parallelism); }
From source file:org.kuali.test.creator.TestCreator.java
private void savePreferences() { try {/* www .j a v a2s .c o m*/ Preferences proot = Preferences.userRoot(); Preferences node = proot.node(Constants.PREFS_ROOT_NODE); Rectangle rect = getBounds(); node.putInt(Constants.PREFS_MAINFRAME_LEFT, rect.x); node.putInt(Constants.PREFS_MAINFRAME_TOP, rect.y); node.putInt(Constants.PREFS_MAINFRAME_WIDTH, rect.width); node.putInt(Constants.PREFS_MAINFRAME_HEIGHT, rect.height); node.putInt(Constants.PREFS_HORIZONTAL_DIVIDER_LOCATION, hsplitPane.getDividerLocation()); node.putInt(Constants.PREFS_VERTICAL_DIVIDER_LOCATION, vsplitPane.getDividerLocation()); node.putInt(Constants.PREFS_MAINFRAME_WINDOW_STATE, getState()); node.flush(); } catch (BackingStoreException ex) { LOG.error(ex.toString(), ex); } }
From source file:org.kuali.test.ui.base.BaseTable.java
/** * */// w ww .j a va2 s . c o m public void saveTablePreferences() { TableConfiguration config = (TableConfiguration) getConfig(); Preferences proot = Preferences.userRoot(); Preferences node = proot.node(Constants.PREFS_TABLE_NODE); for (int i = 0; i < config.getPropertyNames().length; ++i) { String key = getColumnPreferenceKey(i, "width"); if (StringUtils.isNotBlank(key)) { node.putInt(key, getColumnModel().getColumn(i).getPreferredWidth()); } } }
From source file:org.LexGrid.LexBIG.gui.LB_GUI.java
License:asdf
private void init() throws LBInvocationException { try {//www . j ava 2 s . co m logViewer_ = new LogViewer(shell_); } catch (Exception e1) { log.error("There was a problem starting the log viewer", e1); System.err.println(e1); } codeSets = new ArrayList<CodeSet>(); shell_.addShellListener(new ShellAdapter() { public void shellClosed(ShellEvent e) { /* * Save the size and location of the main window. */ int width = shell_.getSize().x; int height = shell_.getSize().y; int locX = shell_.getLocation().x; int locY = shell_.getLocation().y; Preferences p = Preferences.systemNodeForPackage(LB_GUI.this.getClass()); p.putInt("console_width", width); p.putInt("console_height", height); p.putInt("console_loc_x", locX); p.putInt("console_loc_y", locY); } }); GridLayout layout = new GridLayout(1, true); shell_.setLayout(layout); shell_.setImage(new Image(shell_.getDisplay(), this.getClass().getResourceAsStream("/icons/icon.gif"))); errorHandler = new DialogHandler(shell_); SashForm topBottom = new SashForm(shell_, SWT.VERTICAL); topBottom.SASH_WIDTH = 5; topBottom.setLayout(new GridLayout()); GridData gd = new GridData(GridData.FILL_BOTH); topBottom.setLayoutData(gd); topBottom.setVisible(true); // topBottom.setWeights(new int[] {5, 5}); buildCodeSystemComposite(topBottom); SashForm leftRightBottom = new SashForm(topBottom, SWT.HORIZONTAL); leftRightBottom.SASH_WIDTH = 5; buildSetComposite(leftRightBottom); buildRestrictionComposite(leftRightBottom); buildMenus(); PropertiesUtility.systemVariable = "LG_CONFIG_FILE"; String filePath = PropertiesUtility.locatePropFile("config/" + SystemVariables.CONFIG_FILE_NAME, SystemResourceService.class.getName()); if (filePath != null) { File file = new File(filePath); if (file.exists()) { refreshCodingSchemeList(); try { PropertiesUtility.propertiesLocationKey = "CONFIG_FILE_LOCATION"; currentProperties_ = PropertiesUtility.loadPropertiesFromFileOrURL(file.getAbsolutePath()); } catch (IOException e) { log.error("Unexpected Error", e); } } } else { new Configure(LB_GUI.this, currentProperties_); } }
From source file:org.LexGrid.LexBIG.gui.LB_VSD_GUI.java
private void init() throws LBInvocationException { try {//from w w w. j a va2s .c o m logViewer_ = new LogViewer(shell_); } catch (Exception e1) { log.error("There was a problem starting the log viewer", e1); System.err.println(e1); } codeSets = new ArrayList<CodeSet>(); shell_.addShellListener(new ShellAdapter() { public void shellClosed(ShellEvent e) { /* * Save the size and location of the main window. */ int width = shell_.getSize().x; int height = shell_.getSize().y; int locX = shell_.getLocation().x; int locY = shell_.getLocation().y; Preferences p = Preferences.systemNodeForPackage(LB_VSD_GUI.this.getClass()); p.putInt("console_width", width); p.putInt("console_height", height); p.putInt("console_loc_x", locX); p.putInt("console_loc_y", locY); } }); GridLayout layout = new GridLayout(1, true); shell_.setLayout(layout); shell_.setImage(new Image(shell_.getDisplay(), this.getClass().getResourceAsStream("/icons/icon.gif"))); errorHandler = new DialogHandler(shell_); SashForm topBottom = new SashForm(shell_, SWT.VERTICAL); topBottom.SASH_WIDTH = 5; topBottom.setLayout(new GridLayout()); GridData gd = new GridData(GridData.FILL_BOTH); topBottom.setLayoutData(gd); topBottom.setVisible(true); buildValueSetDefComposite(topBottom); SashForm leftRightBottom = new SashForm(topBottom, SWT.HORIZONTAL); leftRightBottom.SASH_WIDTH = 5; gd = new GridData(GridData.FILL_BOTH); leftRightBottom.setLayoutData(gd); leftRightBottom.setVisible(true); buildPickListComposite(leftRightBottom); buildMenus(); PropertiesUtility.systemVariable = "LG_CONFIG_FILE"; String filePath = PropertiesUtility.locatePropFile("config/" + SystemVariables.CONFIG_FILE_NAME, SystemResourceService.class.getName()); if (filePath != null) { File file = new File(filePath); if (file.exists()) { refreshValueSetDefList(); try { PropertiesUtility.propertiesLocationKey = "CONFIG_FILE_LOCATION"; currentProperties_ = PropertiesUtility.loadPropertiesFromFileOrURL(file.getAbsolutePath()); } catch (IOException e) { log.error("Unexpected Error", e); } } } else { new Configure(LB_VSD_GUI.this, currentProperties_); } }