Get values from the GUI and save them in preference file.
188547
def get_values(self):
        """"""
        for value_name, widget in self.index.items():
            self.value[value_name] = widget.get_value(self.value[value_name])

            setting_name = self.widget + '/' + value_name
            settings.setValue(setting_name, self.value[value_name])
1209622
def save(self, filename, verbose=False):
        
        with open(filename, 'w') as fid:
            json.dump(self._conf, fid, indent=4)
        if verbose:
            print('Saved settings in ' + filename)
1247943
private void storeOriginal(Pair<String, Object> keyValue) {
		String key = SharedPreferenceUtils.keyTestMode + keyValue.first;

		if (!preferenceUtils.isValueExistForKey(key)) {
			preferenceUtils.put(key, keyValue.second);

		}
	}
43946
private void restoreData() {
		Map<String, ?> map = preferenceUtils.getAll();
		Set<String> strings = map.keySet();

		for (String string : strings) {
			if (string.startsWith(SharedPreferenceUtils.keyTestMode)) {
				preferenceUtils.restoreKey(string);
			}
		}

		refreshKeyValues();

	}
685510
def retrieveVals(self):
        """"""
        if self._diskList:
            self._fetchDevAll('disk', self._diskList, 
                              self._info.getDiskStats)
        if self._mdList:
            self._fetchDevAll('md', self._mdList, 
                              self._info.getMDstats)
        if self._partList:
            self._fetchDevAll('part', self._partList, 
                              self._info.getPartitionStats) 
        if self._lvList:
            self._fetchDevAll('lv', self._lvList, 
                              self._info.getLVstats)
        self._fetchDevAll('fs', self._fsList, 
                          self._info.getFilesystemStats)
882076
def get_preferences(self):
        
        pref_list = self.request('GetPrefs')['pref']

        out = {}
        for pref in pref_list:
            out[pref['name']] = utils.auto_type(pref['_content'])

        return out
540444
def _saveGuiSettings(self):
        
        # Put the settings into a ConfigObj dict (don't use a config-spec)
        rcFile = self._rcDir+os.sep+APP_NAME.lower()+'.cfg'
        #
        if os.path.exists(rcFile): os.remove(rcFile)
        co = configobj.ConfigObj(rcFile) # can skip try-block, won't read file

        co['showHelpInBrowser']       = self._showHelpInBrowser
        co['saveAndCloseOnExec']      = self._saveAndCloseOnExec
        co['writeProtectOnSaveAsOpt'] = self._writeProtectOnSaveAs
        co['flagNonDefaultVals']      = self._flagNonDefaultVals
        co['frameColor']              = self._frmeColor
        co['taskBoxColor']            = self._taskColor
        co['buttonBoxColor']          = self._bboxColor
        co['entriesColor']            = self._entsColor
        co['flaggedColor']            = self._flagColor

        co.initial_comment = ['Automatically generated by '+\
            APP_NAME+'.  All edits will eventually be overwritten.']
        co.initial_comment.append('To use platform default colors, delete each color line below.')
        co.final_comment = [''] # ensure \n at EOF
        co.write()
1234165
def saveInputs(self, fname):
        
        # save current inputs to file for loading next time
        if not fname:
            return
            
        appdir = systools.get_appdir()
        if not os.path.isdir(appdir):
            os.makedirs(appdir)
        fname = os.path.join(appdir, fname)

        savedict = {}
        savedict['binsz'] = self.ui.binszSpnbx.value()
        savedict['aifs'] = self.ui.aifsSpnbx.value()
        savedict['tscale'] = self.tscale
        savedict['fscale'] = self.fscale
        savedict['saveformat'] = self.saveformat
        savedict['ex_nreps'] = self.ui.exploreStimEditor.repCount()
        savedict['reprate'] = self.ui.reprateSpnbx.value()
        savedict['windowsz'] = self.ui.windowszSpnbx.value()
        savedict['specargs'] = self.specArgs
        savedict['viewSettings'] = self.viewSettings
        savedict['calvals'] = self.calvals
        savedict['calparams'] = self.acqmodel.calibration_template()
        savedict['calreps'] = self.ui.calibrationWidget.ui.nrepsSpnbx.value()
        savedict['mphonesens'] = self.ui.mphoneSensSpnbx.value()
        savedict['mphonedb'] = self.ui.mphoneDBSpnbx.value()
        savedict['vocalpaths'] = Vocalization.paths
        savedict['aichans'] = self._aichans
        savedict['aichan_details'] = self._aichan_details

        # parameter settings -- save all tracks present
        savedict['explorestims'] = self.ui.exploreStimEditor.saveTemplate()

        savedict['advanced_options'] = self.advanced_options
        savedict['stim_view_defaults'] = StimulusView.getDefaults()

        savedict['tuning_curve'] = TCFactory.defaultInputs

        # filter out and non-native python types that are not json serializable
        savedict = convert2native(savedict)
        try:
            with open(fname, 'w') as jf:
                json.dump(savedict, jf)
        except:
            logger = logging.getLogger('main')
            logger.exception("Unable to save app data to file: {}".format(fname))
299434
public void load(@Nonnull final Preferences preferences) {
    this.config.loadFrom(preferences);
    loadFrom(this.config, preferences);
    this.changeNotificationAllowed = false;
    try {
      // Common behaviour options
      this.checkBoxShowHiddenFiles.setSelected(preferences.getBoolean("showHiddenFiles", true)); //NOI18N
      this.checkboxTrimTopicText.setSelected(preferences.getBoolean("trimTopicText", false)); //NOI18N
      this.checkboxUseInsideBrowser.setSelected(preferences.getBoolean("useInsideBrowser", false)); //NOI18N
      this.checkboxRelativePathsForFilesInTheProject.setSelected(preferences.getBoolean("makeRelativePathToProject", true)); //NOI18N
      this.checkBoxUnfoldCollapsedTarget.setSelected(preferences.getBoolean("unfoldCollapsedTarget", true)); //NOI18N
      this.checkBoxCopyColorInfoToNewAllowed.setSelected(preferences.getBoolean("copyColorInfoToNewChildAllowed", true)); //NOI18N
      this.checkBoxKnowledgeFolderAutogenerationAllowed.setSelected(preferences.getBoolean(PREFERENCE_KEY_KNOWLEDGEFOLDER_ALLOWED, false));

      // third part options
      final String pathToGraphViz = preferences.get("plantuml.dotpath", null);
      this.textFieldPathToGraphvizDot.setText(pathToGraphViz == null ? "" : pathToGraphViz);

      // Metrics
      this.checkboxMetricsAllowed.setSelected(MetricsService.getInstance().isEnabled());
    } finally {
      this.changeNotificationAllowed = true;
    }
  }
1182780
def _do(name, gnome_kwargs, preferences):
    '''
    
    '''
    ret = {'name': name,
           'result': True,
           'changes': {},
           'comment': ''}

    messages = []

    for pref in preferences:
        key = pref
        value = preferences[pref]

        if isinstance(value, bool):
            ftype = 'boolean'

            # need to convert boolean values to strings and make lowercase to
            # pass to gsettings
            value = six.text_type(value).lower()

        elif isinstance(value, int):
            ftype = 'int'
        elif isinstance(value, six.string_types):
            ftype = 'string'
        else:
            ftype = 'string'

        gnome_kwargs.update({'key': key, 'value': value})

        if _check_current_value(gnome_kwargs, value):
            messages.append('{0} is already set to {1}'.format(key, value))
        else:
            result = __salt__['gnome.set'](**gnome_kwargs)
            if result['retcode'] == 0:
                messages.append('Setting {0} to {1}'.format(key, value))
                ret['changes'][key] = '{0}:{1}'.format(key, value)
                ret['result'] = True
            else:
                messages.append(result['stdout'])
                ret['result'] = False

        ret['comment'] = ', '.join(messages)

    return ret
633967
private void saveSettings() {
        mPinViewSettings = new PinViewSettings.Builder()
                .withColorSplit(mColorSplit)
                .withColorTextPinBox(mColorTextPinBoxes)
                .withColorTextTitles(mColorTextTitles)
                .withCustomDrawablePinBox(mCustomDrawablePinBox)
                .withDeleteOnClick(isDeleteOnClick())
                .withNativePinBox(isNativePinBox())
                .withSplit(getSplit())
                .withMaskPassword(isMaskPassword())
                .withKeyboardMandatory(isKeyboardMandatory())
                .withNumberCharacters(getNumberCharacters())
                .withSizeSplit(getSizeSplit())
                .withTextSizePinBox(getTextSizePinBoxes())
                .withTextSizeTitles(getTextSizeTitles())
                .withNumberPinBoxes(getNumberPinBoxes())
                .withPinTitles(getPinTitles())
                .build();
    }
758907
public void savePreferences() {
        FOKLogger.info(Prefs.class.getName(), "Saving preference file as: " + file.getAbsolutePath());
        if (!file.getParentFile().exists() && !file.getParentFile().mkdirs())
            throw new IllegalStateException("Unable to create the folder to save the Prefs in");

        try (FileOutputStream out = new FileOutputStream(file)){
            props.store(out, "This is a preference file of the app " + Common.getInstance().getAppName() + ". If you delete this file, the specified app will be (partly or entirely) reset to its factory settings.");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
1117983
def GetValue(self):
    '''
    
    '''
    if not self._widget.GetValue() or len(self._widget.GetValue()) <= 0:
        return None
    else:
        return self._action.option_strings[0]
907096
@SuppressWarnings({ "unchecked", "rawtypes" })
	public static void load(Preferences preferences, Object data) {
		for (Entry<String, PropertyInterface> entry : FlatProperties.getProperties(data.getClass()).entrySet()) {
			String key = entry.getKey();
			Class<?> clazz = entry.getValue().getClazz();
			Object value = null;
			if (String.class.equals(clazz)) {
				String presetValue = (String) FlatProperties.getValue(data, key);
				value = preferences.get(key, presetValue);
			} else if (Integer.class.equals(clazz) || Integer.TYPE.equals(clazz)) {
				Integer presetValue = (Integer) FlatProperties.getValue(data, key);
				value = preferences.getInt(key, presetValue != null ? presetValue.intValue() : 0);
			} else if (Boolean.class.equals(clazz) || Boolean.TYPE.equals(clazz)) {
				Boolean presetValue = (Boolean) FlatProperties.getValue(data, key);
				value = preferences.getBoolean(key, presetValue != null ? presetValue.booleanValue() : false);
			} else if (clazz == LocalDate.class) {
				LocalDate presetValue = (LocalDate) FlatProperties.getValue(data, key);
				String formattedDate = preferences.get(key, presetValue != null ? presetValue.toString() : null);
				value = LocalDate.parse(formattedDate, DateTimeFormatter.ISO_DATE);
			} else if (Enum.class.isAssignableFrom(clazz)) {
				Enum<?> presetValue = (Enum<?>) FlatProperties.getValue(data, key);
				int ordinal = preferences.getInt(key, presetValue != null ? presetValue.ordinal() : 0);
				value = EnumUtils.valueList((Class<Enum>) presetValue.getClass()).get(ordinal);
			} else if (Code.class.isAssignableFrom(clazz)) {
				Code presetValue = (Code) FlatProperties.getValue(data, key);
				PropertyInterface property = FlatProperties.getProperty(clazz, "id");
				if (property.getClazz() == String.class) {
					String id = preferences.get(key, null);
					if (id != null) {
						Class clazz2 = clazz;
						value = Codes.findCode(clazz2, id);
					} else {
						value = presetValue;
					}
				} else if (property.getClazz() == Integer.class) {
					Integer id = preferences.getInt(key, 0);
					if (id != 0) {
						Class clazz2 = clazz;
						value = Codes.findCode(clazz2, id);
					} else {
						value = presetValue;
					}
				}
			} else {
				logger.warning("Preference Field with unsupported Class: " + key + " of class " + clazz.getSimpleName()
						+ " in " + data.getClass().getSimpleName());
			}
			FlatProperties.set(data, key, value);
		}
	}
10384
def _store_gui_setting(self, databox, name):
        
        try:    databox.insert_header(name, eval(name + ".get_value()"))
        except: print("ERROR: Could not store gui setting "+repr(name))
694461
def _getGuiSettings(self):
        
        # Put the settings into a ConfigObj dict (don't use a config-spec)
        rcFile = self._rcDir+os.sep+APP_NAME.lower()+'.cfg'
        if os.path.exists(rcFile):
            try:
                return configobj.ConfigObj(rcFile)
            except:
                raise RuntimeError('Error parsing: '+os.path.realpath(rcFile))

            # tho, for simple types, unrepr=True eliminates need for .cfgspc
            # also, if we turn unrepr on, we don't need cfgGetBool
        else:
            return {}
949514
private void save() {
		int resp = saveChooser.showSaveDialog(this);
		if (resp == JFileChooser.APPROVE_OPTION) {
			File out = saveChooser.getSelectedFile();
			
			ArrayList list = new ArrayList();
			for (int i=0;i<sprites.size();i++) {
				list.add(sprites.elementAt(i));
			}
			
			try {
				int b = ((Integer) border.getValue()).intValue();
				pack.packImages(list, twidth, theight, b, out);
			} catch (IOException e) {
				// shouldn't happen 
				e.printStackTrace();
				JOptionPane.showMessageDialog(this, "Failed to write output");
			}
		}
	}