private void saveFile(boolean saveAs) { final CacheListController clc = CacheListController.getTopViewCacheController(desktopPane); String strPath = null; try { strPath = clc.getPath().toString(); } catch (Exception e) { saveAs = true; } if (saveAs) { if (strPath == null) strPath = Settings.getS(Settings.Key.FILE_CHOOSER_LOAD_GPX); final JFileChooser chooser = new JFileChooser(strPath); chooser.setFileFilter(new FileNameExtensionFilter("ZIP Archive", "zip")); if (chooser.showSaveDialog(THIS) != JFileChooser.APPROVE_OPTION) return; strPath = chooser.getSelectedFile().getAbsolutePath(); } if (!FileHelper.getFileExtension(strPath).equals("zip")) strPath += ".zip"; if (saveAs) { File f = new File(strPath); if (f.exists() && !f.isDirectory()) { int dialogResult = JOptionPane.showConfirmDialog( THIS, "The choosen file already exists. Overwrite it?", "Warning", JOptionPane.YES_NO_OPTION); if (dialogResult == JOptionPane.NO_OPTION) { return; } } Settings.set(Settings.Key.FILE_CHOOSER_LOAD_GPX, Paths.get(strPath).getParent().toString()); } actionWithWaitDialog( new Runnable() { private Path path; public Runnable setPath(Path path) { this.path = path; return this; } public void run() { try { clc.store(path); } catch (Throwable e) { ExceptionPanel.showErrorDialog(e); } } }.setPath(Paths.get(strPath)), THIS); }
private void saveSettings() { Dimension resolution = DefaultSettings.RESOLUTIONS[cbxResolution.getSelectedIndex()]; Settings.set("resolution_width", (int) resolution.getWidth()); Settings.set("resolution_height", (int) resolution.getHeight()); Settings.set("fullscreen", cbxFullscreen.isSelected()); Settings.set( "antialiasing", DefaultSettings.ANTIALIASING_SAMPLES[cbxAntialiasing.getSelectedIndex()]); Settings.set("vsync", cbxVSync.isSelected()); Settings.set("hardware_skinning", cbxHardwareSkinning.isSelected()); Settings.set("shadow_quality", sldShadowQuality.getValue()); Settings.saveFile(); }
private void readSettings(Handler handler, int length, byte flags, int streamId) throws IOException { if (streamId != 0) throw ioException("TYPE_SETTINGS streamId != 0"); if ((flags & FLAG_ACK) != 0) { if (length != 0) throw ioException("FRAME_SIZE_ERROR ack frame should be empty!"); handler.ackSettings(); return; } if (length % 6 != 0) throw ioException("TYPE_SETTINGS length %% 6 != 0: %s", length); Settings settings = new Settings(); for (int i = 0; i < length; i += 6) { short id = source.readShort(); int value = source.readInt(); switch (id) { case 1: // SETTINGS_HEADER_TABLE_SIZE break; case 2: // SETTINGS_ENABLE_PUSH if (value != 0 && value != 1) { throw ioException("PROTOCOL_ERROR SETTINGS_ENABLE_PUSH != 0 or 1"); } break; case 3: // SETTINGS_MAX_CONCURRENT_STREAMS id = 4; // Renumbered in draft 10. break; case 4: // SETTINGS_INITIAL_WINDOW_SIZE id = 7; // Renumbered in draft 10. if (value < 0) { throw ioException("PROTOCOL_ERROR SETTINGS_INITIAL_WINDOW_SIZE > 2^31 - 1"); } break; case 5: // SETTINGS_MAX_FRAME_SIZE if (value < INITIAL_MAX_FRAME_SIZE || value > 16777215) { throw ioException("PROTOCOL_ERROR SETTINGS_MAX_FRAME_SIZE: %s", value); } break; case 6: // SETTINGS_MAX_HEADER_LIST_SIZE break; // Advisory only, so ignored. default: throw ioException("PROTOCOL_ERROR invalid settings id: %s", id); } settings.set(id, 0, value); } handler.settings(false, settings); if (settings.getHeaderTableSize() >= 0) { hpackReader.headerTableSizeSetting(settings.getHeaderTableSize()); } }
private void openFile(final boolean createNewList) { String lastPath = Settings.getS(Settings.Key.FILE_CHOOSER_LOAD_GPX); final JFileChooser chooser = new JFileChooser(lastPath); chooser.setDialogType(JFileChooser.OPEN_DIALOG); chooser.setFileFilter( new FileNameExtensionFilter("GPS Exchange Format | ZIP Archive", "gpx", "zip")); if (chooser.showOpenDialog(THIS) == JFileChooser.APPROVE_OPTION) { lastPath = chooser.getSelectedFile().getPath(); Settings.set(Settings.Key.FILE_CHOOSER_LOAD_GPX, Paths.get(lastPath).getParent().toString()); actionWithWaitDialog( new Runnable() { public void run() { try { if (createNewList) CacheListController.newCLC( desktopPane, mnWindows, (Location) comboBox.getSelectedItem(), chooser.getSelectedFile().getAbsolutePath(), new CacheListView.RunLocationDialogI() { public void openDialog(Geocache g) { openLocationDialog(g); } }); else CacheListController.getTopViewCacheController(desktopPane) .addFromFile(chooser.getSelectedFile().getAbsolutePath()); } catch (Throwable e) { // Main.gc(); ExceptionPanel.showErrorDialog(e); } } }, THIS); } }
public static void set(Settings settings, int id, int value) { settings.set(id, 0, value); }