List of usage examples for java.util.prefs Preferences getInt
public abstract int getInt(String key, int def);
From source file:de.ailis.oneinstance.OneInstance.java
/** * Returns the port which was last recorded as active. * // w w w.jav a 2s .c om * @param mainClass * The main class of the application. * @return The active port address or null if not found. */ private Integer getActivePort(Class<?> mainClass) { Preferences prefs = Preferences.userNodeForPackage(mainClass); int port = prefs.getInt(PORT_KEY, -1); return port >= MIN_PORT && port <= MAX_PORT ? port : null; }
From source file:modmanager.MainWindow.java
private void formWindowOpened(java.awt.event.WindowEvent evt)//GEN-FIRST:event_formWindowOpened {//GEN-HEADEREND:event_formWindowOpened Preferences node = Preferences.userRoot().node("jskyrimmodmanager/window"); this.setLocation(node.getInt("x", 0), node.getInt("y", 0)); this.setSize(node.getInt("width", 800), node.getInt("height", 600)); this.setExtendedState(node.getInt("state", JFrame.MAXIMIZED_BOTH)); }
From source file:com.nbt.TileCanvas.java
public void restore() { Preferences prefs = getPreferences(); int def = 0;/*from w w w. j a va 2 s. c om*/ int x = prefs.getInt(KEY_TILE_X, def); setTileX(x); int z = prefs.getInt(KEY_TILE_Z, def); setTileZ(z); def = 70; int altitude = prefs.getInt(KEY_ALTITUDE, def); setAltitude(altitude); def = 16; int width = prefs.getInt(KEY_WIDTH, def); setTileWidth(width); int height = prefs.getInt(KEY_HEIGHT, def); setTileHeight(height); }
From source file:org.syncany.plugins.php.PhpTransferManager.java
@SuppressWarnings("deprecation") private CloseableHttpClient getHttpClient() { try {//from www. j av a2s. 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:hr.fer.zemris.vhdllab.view.explorer.ProjectExplorerView.java
public Integer getHierarchyMode() { if (hierarchyMode == null) { Preferences preferences = Preferences.userNodeForPackage(ProjectExplorerView.class); hierarchyMode = preferences.getInt(PREFERENCES_HIERARCHY_MODE, HIERARCHY_X_USES_Y); }// w w w. j a v a 2s . com if (hierarchyMode != HIERARCHY_X_USES_Y && hierarchyMode != HIERARCHY_X_USED_BY_Y && hierarchyMode != HIERARCHY_FLAT) { hierarchyMode = HIERARCHY_X_USES_Y; } return hierarchyMode; }
From source file:burlov.ultracipher.swing.SwingGuiApplication.java
private void restoreWindowState() { Preferences prefs = Preferences.userNodeForPackage(getClass()); mainFrame.setSize(prefs.getInt("size.x", 600), prefs.getInt("size.y", 400)); mainFrame.setLocationRelativeTo(null); mainFrame.setLocation(prefs.getInt("pos.x", 100), prefs.getInt("pos.y", 100)); }
From source file:loci.slim.ui.DecayGraph.java
/** * Restores size from Java Preferences./*ww w. ja va 2s . co m*/ * * @return size */ private Dimension getSizeFromPreferences() { final Preferences prefs = Preferences.userNodeForPackage(this.getClass()); return new Dimension(prefs.getInt(WIDTH_KEY, FRAME_SIZE.width), prefs.getInt(HEIGHT_KEY, FRAME_SIZE.height)); }
From source file:com.moteiv.trawler.Trawler.java
private void loadPrefs() { // extract preference data Preferences prefs = Preferences.userNodeForPackage(com.moteiv.trawler.Trawler.class); // set the data vSave.setSelected(prefs.getBoolean(PREF_V_SAVE, true)); vBlink.setSelected(prefs.getBoolean(PREF_V_BLINK, false)); vLabels.setSelected(prefs.getBoolean(PREF_V_LABELS, true)); eLabels.setSelected(prefs.getBoolean(PREF_E_LABELS, true)); eFilter.setSelected(prefs.getBoolean(PREF_E_FILTER, true)); vDispose.setValue(prefs.getInt(PREF_V_DISPOSE, NodeData.getNodeDelay() / 1000)); eDispose.setValue(prefs.getInt(PREF_E_DISPOSE, LinkData.getEdgeDelay() / 1000)); // update the processing engines to reflect the new data processEvent(vSave);/*from ww w . ja va 2 s .co m*/ processEvent(vBlink); processEvent(vLabels); processEvent(eLabels); processEvent(eFilter); LinkData.setEdgeDelay(eDispose.getValue() * 1000); NodeData.setNodeDelay(vDispose.getValue() * 1000); }
From source file:com.wwidesigner.gui.StudyModel.java
/** * Set study model preferences from application preferences. * /*from ww w .j ava 2 s.c om*/ * @param newPreferences */ public void setPreferences(Preferences newPreferences) { double currentTemperature = newPreferences.getDouble(OptimizationPreferences.TEMPERATURE_OPT, OptimizationPreferences.DEFAULT_TEMPERATURE); double currentPressure = newPreferences.getDouble(OptimizationPreferences.PRESSURE_OPT, OptimizationPreferences.DEFAULT_PRESSURE); int currentHumidity = newPreferences.getInt(OptimizationPreferences.HUMIDITY_OPT, OptimizationPreferences.DEFAULT_HUMIDITY); int currentCO2 = newPreferences.getInt(OptimizationPreferences.CO2_FRACTION_OPT, OptimizationPreferences.DEFAULT_CO2_FRACTION); double xCO2 = currentCO2 * 1.0e-6; getParams().setProperties(currentTemperature, currentPressure, currentHumidity, xCO2); getParams().printProperties(); String optimizerPreference = newPreferences.get(OptimizationPreferences.OPTIMIZER_TYPE_OPT, OptimizationPreferences.OPT_DEFAULT_NAME); if (optimizerPreference.contentEquals(OptimizationPreferences.OPT_DEFAULT_NAME)) { preferredOptimizerType = null; } else if (optimizerPreference.contentEquals(OptimizationPreferences.OPT_DIRECT_NAME)) { preferredOptimizerType = BaseObjectiveFunction.OptimizerType.DIRECTOptimizer; } else { preferredOptimizerType = null; } }
From source file:org.domainmath.gui.MainFrame.java
/** * Creates new form MainFrame.//w ww .j a v a 2s . c om * @param args */ public MainFrame(String args[]) { // create folders called cache and log. cache = new File(System.getProperty("user.dir") + File.separator + "cache"); logDir = new File(System.getProperty("user.dir") + File.separator + "log"); worksDir = new File(System.getProperty("user.dir") + File.separator + "works"); cache.mkdir(); logDir.mkdir(); if (!worksDir.exists()) { worksDir.mkdir(); } parent_root = cache.getAbsolutePath() + File.separator; log_root = logDir.getAbsolutePath() + File.separator; preferencesDlg = new PreferencesDlg(this, true); layout_file = new File(System.getProperty("user.dir") + File.separator + "layout.ini"); initComponents(); new PackageLoader(this); new ToolsLoader(this); makeMenu(); setIconImage(icon); Preferences pr2 = Preferences.userNodeForPackage(this.getClass()); setSize(pr2.getInt("Frame_width", 800), pr2.getInt("Frame_height", 600)); setLocationRelativeTo(null); FILE_TAB_INDEX = 0; //create octavepanel. octavePanel = new OctavePanel(this); commandArea = octavePanel.commandArea; octavePath = preferencesDlg.getPath(); startupCmd = preferencesDlg.getStartupCmd(); wantedToClearText = preferencesDlg.wantedToClearText(); cmdLineOptions = preferencesDlg.getCmdLineOptions(); // set up histroy widget. histArea = new RSyntaxTextArea(); histArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_OCTAVE); histScrollPane = new RTextScrollPane(histArea); histScrollPane.setWheelScrollingEnabled(true); workspace = new WorkspacePanel(parent_root + "DomainMath_OctaveVariables.dat", this); dbstackPanel = new DbstackPanel(parent_root + "DomainMath_OctaveDbStack.dat", this); // create recent files menu. recentFileMenu = new RecentFileMenu("RecentFiles", MAX_NUM_RECENT_FILES) { @Override public void onSelectFile(String filePath, ActionEvent action_event) { onRecentFile(filePath, action_event); } }; this.fileMenu.add(recentFileMenu, MainFrame.RECENT_MENU_ORDER); statusPanel = new StatusPanel(); fileTab.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT); fileTreePanel = new FileTreePanel(this); quickHelpPanel = new QuickHelpPanel(); pathPanel = new PathsPanel(parent_root + "DomainMath_OctavePaths.dat"); pkgViewPanel = new PkgViewPanel(parent_root + "DomainMath_OctavePackages.dat", this); histPanel(); this.popupTab(); dir = pr2.get("DomainMath_StartUpDir", System.getProperty("user.dir")); if (dir.equals(worksDir.getAbsolutePath())) { startupDir = dir; } else { startupDir = worksDir.getAbsolutePath(); } currentDirFileTab = null; fileTabView = new View("Code Editor", null, fileTab); pathsView = new View("Set Paths", null, pathPanel); pkgView = new View("Packages", null, pkgViewPanel); consoleScrollPane = new JScrollPane(); consoleScrollPane.getVerticalScrollBar().setUnitIncrement(16); consoleScrollPane.setViewportView(octavePanel); consoleView = new View("Console", null, consoleScrollPane); arrayEditorView = new View("Array Editor", null, new ArrayEditorPanel()); workspaceView = new View("Workspace", null, workspace); debuggerView = new View("Debugger", null, this.dbstackPanel); filesView = new View("Files", null, fileTreePanel); quickHelpView = new View("Quick Help", null, quickHelpPanel); createRootWindow(); setDefaultLayout(); add(rootWindow, BorderLayout.CENTER); add(statusPanel, BorderLayout.PAGE_END); dragNDrop(); debugMarksList = new ArrayList<>(); breakPointMarksList = new ArrayList<>(); breakPointList = new ArrayList<>(); fileTab2 = fileTab; if (args != null) { openStartUpFiles(args); } }