Save current UserPreferences for given project or workspace.

@param project
the project or null for workspace
@throws CoreException
328337
public static void saveUserPreferences(IProject project, final UserPreferences userPrefs) throws CoreException {

        FileOutput userPrefsOutput = new FileOutput() {
            @Override
            public void writeFile(OutputStream os) throws IOException {
                userPrefs.write(os);
            }

            @Override
            public String getTaskDescription() {
                return "writing user preferences";
            }
        };

        if (project != null) {
            // Make the new user preferences current for the project
            project.setSessionProperty(SESSION_PROPERTY_USERPREFS, userPrefs);
            IFile userPrefsFile = getUserPreferencesFile(project);
            ensureReadWrite(userPrefsFile);
            IO.writeFile(userPrefsFile, userPrefsOutput, null);
            if (project.getFile(DEPRECATED_PREFS_PATH).equals(userPrefsFile)) {
                String message = "Found old style FindBugs preferences for project '" + project.getName()
                        + "'. This preferences are not at the default location: '" + DEFAULT_PREFS_PATH + "'." + " Please move '"
                        + DEPRECATED_PREFS_PATH + "' to '" + DEFAULT_PREFS_PATH + "'.";
                getDefault().logWarning(message);
            }
        } else {
            // write the workspace preferences to the eclipse preference store
            ByteArrayOutputStream bos = new ByteArrayOutputStream(10000);
            try {
                userPrefs.write(bos);
            } catch (IOException e) {
                getDefault().logException(e, "Failed to write user preferences");
                return;
            }
            Properties props = new Properties();
            try {
                props.load(new ByteArrayInputStream(bos.toByteArray()));
            } catch (IOException e) {
                getDefault().logException(e, "Failed to save user preferences");
                return;
            }
            IPreferenceStore store = getDefault().getPreferenceStore();
            // Reset any existing custom group entries
            resetStore(store, UserPreferences.KEY_PLUGIN);
            resetStore(store, UserPreferences.KEY_EXCLUDE_BUGS);
            resetStore(store, UserPreferences.KEY_EXCLUDE_FILTER);
            resetStore(store, UserPreferences.KEY_INCLUDE_FILTER);
            for (Entry<Object, Object> entry : props.entrySet()) {
                store.putValue((String) entry.getKey(), (String) entry.getValue());
            }
            if(store instanceof IPersistentPreferenceStore){
                IPersistentPreferenceStore store2 = (IPersistentPreferenceStore) store;
                try {
                    store2.save();
                } catch (IOException e) {
                    getDefault().logException(e, "Failed to save user preferences");
                }
            }
        }
    }
1352659
private void writeProjectProperties()
   {
      m_project = m_factory.createProjectType();
      m_apibo.getProject().add(m_project);

      ProjectProperties mpxj = m_projectFile.getProjectProperties();
      Task rootTask = m_projectFile.getTaskByUniqueID(Integer.valueOf(0));
      UUID guid = rootTask == null ? null : rootTask.getGUID();

      m_project.setActivityDefaultActivityType("Task Dependent");
      m_project.setActivityDefaultCalendarObjectId(getCalendarUniqueID(m_projectFile.getDefaultCalendar()));
      m_project.setActivityDefaultDurationType("Fixed Duration and Units");
      m_project.setActivityDefaultPercentCompleteType("Duration");
      m_project.setActivityDefaultPricePerUnit(NumberHelper.DOUBLE_ZERO);
      m_project.setActivityIdBasedOnSelectedActivity(Boolean.TRUE);
      m_project.setActivityIdIncrement(Integer.valueOf(10));
      m_project.setActivityIdPrefix("A");
      m_project.setActivityIdSuffix(Integer.valueOf(1000));
      m_project.setActivityPercentCompleteBasedOnActivitySteps(Boolean.FALSE);
      m_project.setAddActualToRemaining(Boolean.FALSE);
      m_project.setAllowNegativeActualUnitsFlag(Boolean.FALSE);
      m_project.setAssignmentDefaultDrivingFlag(Boolean.TRUE);
      m_project.setAssignmentDefaultRateType("Price / Unit");
      m_project.setCheckOutStatus(Boolean.FALSE);
      m_project.setCostQuantityRecalculateFlag(Boolean.FALSE);
      m_project.setCreateDate(mpxj.getCreationDate());
      m_project.setCriticalActivityFloatLimit(NumberHelper.DOUBLE_ZERO);
      m_project.setCriticalActivityPathType("Critical Float");
      m_project.setDataDate(m_projectFile.getProjectProperties().getStatusDate());
      m_project.setDefaultPriceTimeUnits("Hour");
      m_project.setDiscountApplicationPeriod("Month");
      m_project.setEarnedValueComputeType("Activity Percent Complete");
      m_project.setEarnedValueETCComputeType("ETC = Remaining Cost for Activity");
      m_project.setEarnedValueETCUserValue(Double.valueOf(0.88));
      m_project.setEarnedValueUserPercent(Double.valueOf(0.06));
      m_project.setEnableSummarization(Boolean.TRUE);
      m_project.setFiscalYearStartMonth(Integer.valueOf(1));
      m_project.setFinishDate(mpxj.getFinishDate());
      m_project.setGUID(DatatypeConverter.printUUID(guid));
      m_project.setId(PROJECT_ID);
      m_project.setLastUpdateDate(mpxj.getLastSaved());
      m_project.setLevelingPriority(Integer.valueOf(10));
      m_project.setLinkActualToActualThisPeriod(Boolean.TRUE);
      m_project.setLinkPercentCompleteWithActual(Boolean.TRUE);
      m_project.setLinkPlannedAndAtCompletionFlag(Boolean.TRUE);
      m_project.setName(mpxj.getName() == null ? PROJECT_ID : mpxj.getName());
      m_project.setObjectId(PROJECT_OBJECT_ID);
      m_project.setPlannedStartDate(mpxj.getStartDate());
      m_project.setPrimaryResourcesCanMarkActivitiesAsCompleted(Boolean.TRUE);
      m_project.setResetPlannedToRemainingFlag(Boolean.FALSE);
      m_project.setResourceCanBeAssignedToSameActivityMoreThanOnce(Boolean.TRUE);
      m_project.setResourcesCanAssignThemselvesToActivities(Boolean.TRUE);
      m_project.setResourcesCanEditAssignmentPercentComplete(Boolean.FALSE);
      m_project.setResourcesCanMarkAssignmentAsCompleted(Boolean.FALSE);
      m_project.setResourcesCanViewInactiveActivities(Boolean.FALSE);
      m_project.setRiskLevel("Medium");
      m_project.setStartDate(mpxj.getStartDate());
      m_project.setStatus("Active");
      m_project.setStrategicPriority(Integer.valueOf(500));
      m_project.setSummarizeToWBSLevel(Integer.valueOf(2));
      m_project.setSummaryLevel("Assignment Level");
      m_project.setUseProjectBaselineForEarnedValue(Boolean.TRUE);
      m_project.setWBSCodeSeparator(".");
      m_project.getUDF().addAll(writeUDFType(FieldTypeClass.PROJECT, mpxj));
   }
1014023
private void processProjectProperties() throws SQLException
   {
      List<ResultSetRow> rows = getRows("SELECT * FROM MSP_PROJECTS WHERE PROJ_ID=?", m_projectID);
      if (rows.isEmpty() == false)
      {
         processProjectProperties(rows.get(0));
      }
   }
624408
public void setViewerPreferences(int preferences) {
		this.pageLayoutAndMode |= preferences;
		// for backwards compatibility, it is also possible
		// to set the following viewer preferences with this method:
		if ((preferences & viewerPreferencesMask) != 0) {
			pageLayoutAndMode = ~viewerPreferencesMask & pageLayoutAndMode;
			if ((preferences & PdfWriter.HideToolbar) != 0)
				viewerPreferences.put(PdfName.HIDETOOLBAR, PdfBoolean.PDFTRUE);
			if ((preferences & PdfWriter.HideMenubar) != 0)
				viewerPreferences.put(PdfName.HIDEMENUBAR, PdfBoolean.PDFTRUE);
			if ((preferences & PdfWriter.HideWindowUI) != 0)
				viewerPreferences.put(PdfName.HIDEWINDOWUI, PdfBoolean.PDFTRUE);
			if ((preferences & PdfWriter.FitWindow) != 0)
				viewerPreferences.put(PdfName.FITWINDOW, PdfBoolean.PDFTRUE);
			if ((preferences & PdfWriter.CenterWindow) != 0)
				viewerPreferences.put(PdfName.CENTERWINDOW, PdfBoolean.PDFTRUE);
			if ((preferences & PdfWriter.DisplayDocTitle) != 0)
				viewerPreferences.put(PdfName.DISPLAYDOCTITLE, PdfBoolean.PDFTRUE);
			
			if ((preferences & PdfWriter.NonFullScreenPageModeUseNone) != 0)
				viewerPreferences.put(PdfName.NONFULLSCREENPAGEMODE, PdfName.USENONE);
			else if ((preferences & PdfWriter.NonFullScreenPageModeUseOutlines) != 0)
				viewerPreferences.put(PdfName.NONFULLSCREENPAGEMODE, PdfName.USEOUTLINES);
			else if ((preferences & PdfWriter.NonFullScreenPageModeUseThumbs) != 0)
				viewerPreferences.put(PdfName.NONFULLSCREENPAGEMODE, PdfName.USETHUMBS);
			else if ((preferences & PdfWriter.NonFullScreenPageModeUseOC) != 0)
				viewerPreferences.put(PdfName.NONFULLSCREENPAGEMODE, PdfName.USEOC);

			if ((preferences & PdfWriter.DirectionL2R) != 0)
				viewerPreferences.put(PdfName.DIRECTION, PdfName.L2R);
			else if ((preferences & PdfWriter.DirectionR2L) != 0)
				viewerPreferences.put(PdfName.DIRECTION, PdfName.R2L);

			if ((preferences & PdfWriter.PrintScalingNone) != 0)
				viewerPreferences.put(PdfName.PRINTSCALING, PdfName.NONE);			
		}
	}
1199285
public void setNotificationProject(String notificationProject) {

        m_notificationProject = notificationProject;
        if (CmsLog.INIT.isInfoEnabled()) {
            CmsLog.INIT.info(
                Messages.get().getBundle().key(Messages.INIT_NOTIFICATION_PROJECT_1, m_notificationProject));
        }
    }
346911
protected synchronized void save() {
        try {
            JSONArray jsonArray = new JSONArray();
            for (Job job : mQueue) {
                if (!(job instanceof InternalJob)) continue;
                InternalJob internalJob = (InternalJob) job;
                jsonArray.put(internalJob.toJSON());
            }

            SharedPreferences prefs = WonderPushConfiguration.getSharedPreferences();
            SharedPreferences.Editor editor = prefs.edit();
            editor.putString(getPrefName(), jsonArray.toString());
            editor.apply();
        } catch (JSONException e) {
            Log.e(TAG, "Could not save job queue", e);
        } catch (Exception e) {
            Log.e(TAG, "Could not save job queue", e);
        }
    }
384727
def save_project(self, project):
        
        pid = project.pid

        # project created
        # project updated

        if project.is_active:
            # project is not deleted
            logger.debug("project is active")
            ds_project = self.get_project(pid)
            if ds_project is None:
                self._create_project(pid)

            # update project meta information
            name = self._truncate(project.name, 40)
            self._set_project(pid, name, project.institute)
        else:
            # project is deleted
            logger.debug("project is not active")
            ds_project = self.get_project(pid)
            if ds_project is not None:
                self._delete_project(pid)

        return
669695
private void writeProjectProperties(Project project)
   {
      ProjectProperties properties = m_projectFile.getProjectProperties();

      project.setActualsInSync(Boolean.valueOf(properties.getActualsInSync()));
      project.setAdminProject(Boolean.valueOf(properties.getAdminProject()));
      project.setAuthor(properties.getAuthor());
      project.setAutoAddNewResourcesAndTasks(Boolean.valueOf(properties.getAutoAddNewResourcesAndTasks()));
      project.setAutolink(Boolean.valueOf(properties.getAutolink()));
      project.setBaselineForEarnedValue(NumberHelper.getBigInteger(properties.getBaselineForEarnedValue()));
      project.setCalendarUID(m_projectFile.getDefaultCalendar() == null ? BigInteger.ONE : NumberHelper.getBigInteger(m_projectFile.getDefaultCalendar().getUniqueID()));
      project.setCategory(properties.getCategory());
      project.setCompany(properties.getCompany());
      project.setCreationDate(properties.getCreationDate());
      project.setCriticalSlackLimit(NumberHelper.getBigInteger(properties.getCriticalSlackLimit()));
      project.setCurrencyCode(properties.getCurrencyCode());
      project.setCurrencyDigits(BigInteger.valueOf(properties.getCurrencyDigits().intValue()));
      project.setCurrencySymbol(properties.getCurrencySymbol());
      project.setCurrencySymbolPosition(properties.getSymbolPosition());
      project.setCurrentDate(properties.getCurrentDate());
      project.setDaysPerMonth(NumberHelper.getBigInteger(properties.getDaysPerMonth()));
      project.setDefaultFinishTime(properties.getDefaultEndTime());
      project.setDefaultFixedCostAccrual(properties.getDefaultFixedCostAccrual());
      project.setDefaultOvertimeRate(DatatypeConverter.printRate(properties.getDefaultOvertimeRate()));
      project.setDefaultStandardRate(DatatypeConverter.printRate(properties.getDefaultStandardRate()));
      project.setDefaultStartTime(properties.getDefaultStartTime());
      project.setDefaultTaskEVMethod(DatatypeConverter.printEarnedValueMethod(properties.getDefaultTaskEarnedValueMethod()));
      project.setDefaultTaskType(properties.getDefaultTaskType());
      project.setDurationFormat(DatatypeConverter.printDurationTimeUnits(properties.getDefaultDurationUnits(), false));
      project.setEarnedValueMethod(DatatypeConverter.printEarnedValueMethod(properties.getEarnedValueMethod()));
      project.setEditableActualCosts(Boolean.valueOf(properties.getEditableActualCosts()));
      project.setExtendedCreationDate(properties.getExtendedCreationDate());
      project.setFinishDate(properties.getFinishDate());
      project.setFiscalYearStart(Boolean.valueOf(properties.getFiscalYearStart()));
      project.setFYStartDate(NumberHelper.getBigInteger(properties.getFiscalYearStartMonth()));
      project.setHonorConstraints(Boolean.valueOf(properties.getHonorConstraints()));
      project.setInsertedProjectsLikeSummary(Boolean.valueOf(properties.getInsertedProjectsLikeSummary()));
      project.setLastSaved(properties.getLastSaved());
      project.setManager(properties.getManager());
      project.setMicrosoftProjectServerURL(Boolean.valueOf(properties.getMicrosoftProjectServerURL()));
      project.setMinutesPerDay(NumberHelper.getBigInteger(properties.getMinutesPerDay()));
      project.setMinutesPerWeek(NumberHelper.getBigInteger(properties.getMinutesPerWeek()));
      project.setMoveCompletedEndsBack(Boolean.valueOf(properties.getMoveCompletedEndsBack()));
      project.setMoveCompletedEndsForward(Boolean.valueOf(properties.getMoveCompletedEndsForward()));
      project.setMoveRemainingStartsBack(Boolean.valueOf(properties.getMoveRemainingStartsBack()));
      project.setMoveRemainingStartsForward(Boolean.valueOf(properties.getMoveRemainingStartsForward()));
      project.setMultipleCriticalPaths(Boolean.valueOf(properties.getMultipleCriticalPaths()));
      project.setName(properties.getName());
      project.setNewTasksEffortDriven(Boolean.valueOf(properties.getNewTasksEffortDriven()));
      project.setNewTasksEstimated(Boolean.valueOf(properties.getNewTasksEstimated()));
      project.setNewTaskStartDate(properties.getNewTaskStartIsProjectStart() == true ? BigInteger.ZERO : BigInteger.ONE);
      project.setProjectExternallyEdited(Boolean.valueOf(properties.getProjectExternallyEdited()));
      project.setRemoveFileProperties(Boolean.valueOf(properties.getRemoveFileProperties()));
      project.setRevision(NumberHelper.getBigInteger(properties.getRevision()));
      project.setSaveVersion(BigInteger.valueOf(m_saveVersion.getValue()));
      project.setScheduleFromStart(Boolean.valueOf(properties.getScheduleFrom() == ScheduleFrom.START));
      project.setSplitsInProgressTasks(Boolean.valueOf(properties.getSplitInProgressTasks()));
      project.setSpreadActualCost(Boolean.valueOf(properties.getSpreadActualCost()));
      project.setSpreadPercentComplete(Boolean.valueOf(properties.getSpreadPercentComplete()));
      project.setStartDate(properties.getStartDate());
      project.setStatusDate(properties.getStatusDate());
      project.setSubject(properties.getSubject());
      project.setTaskUpdatesResource(Boolean.valueOf(properties.getUpdatingTaskStatusUpdatesResourceStatus()));
      project.setTitle(properties.getProjectTitle());
      project.setUID(properties.getUniqueID());
      project.setWeekStartDay(DatatypeConverter.printDay(properties.getWeekStartDay()));
      project.setWorkFormat(DatatypeConverter.printWorkUnits(properties.getDefaultWorkUnits()));
   }
1043708
private void processProjectProperties() throws SQLException
   {
      //
      // Process common attributes
      //
      List<Row> rows = getRows("select * from " + m_schema + "project where proj_id=?", m_projectID);
      m_reader.processProjectProperties(rows, m_projectID);

      //
      // Process PMDB-specific attributes
      //
      rows = getRows("select * from " + m_schema + "prefer where prefer.delete_date is null");
      if (!rows.isEmpty())
      {
         Row row = rows.get(0);
         ProjectProperties ph = m_reader.getProject().getProjectProperties();
         ph.setCreationDate(row.getDate("create_date"));
         ph.setLastSaved(row.getDate("update_date"));
         ph.setMinutesPerDay(Double.valueOf(row.getDouble("day_hr_cnt").doubleValue() * 60));
         ph.setMinutesPerWeek(Double.valueOf(row.getDouble("week_hr_cnt").doubleValue() * 60));
         ph.setWeekStartDay(Day.getInstance(row.getInt("week_start_day_num")));

         processDefaultCurrency(row.getInteger("curr_id"));
      }

      processSchedulingProjectProperties();
   }
1151791
public void setProjects(java.util.Collection<ProjectSummary> projects) {
        if (projects == null) {
            this.projects = null;
            return;
        }

        this.projects = new java.util.ArrayList<ProjectSummary>(projects);
    }
580702
private void updateProjectProperties(Task task)
   {
      ProjectProperties props = m_projectFile.getProjectProperties();
      props.setComments(task.getNotes());
   }
313703
public void configureCoreProperties(
      Project project,
      AppEngineCoreExtensionProperties appEngineCoreExtensionProperties,
      String taskGroup,
      boolean requiresAppEngineJava) {
    project
        .getLogger()
        .warn(
            "WARNING: You are a using release candidate "
                + getClass().getPackage().getImplementationVersion()
                + ". Behavior of this plugin has changed since 1.3.5. Please see release notes at: "
                + "https://github.com/GoogleCloudPlatform/app-gradle-plugin.");
    project
        .getLogger()
        .warn(
            "Missing a feature? Can't get it to work?, please file a bug at: "
                + "https://github.com/GoogleCloudPlatform/app-gradle-plugin/issues.");

    checkGradleVersion();

    this.project = project;
    this.taskGroup = taskGroup;
    this.toolsExtension = appEngineCoreExtensionProperties.getTools();
    this.deployExtension = appEngineCoreExtensionProperties.getDeploy();
    this.requiresAppEngineJava = requiresAppEngineJava;
    configureFactories();

    createDownloadCloudSdkTask();
    createCheckCloudSdkTask();
    createLoginTask();
    createDeployTask();
    createDeployCronTask();
    createDeployDispatchTask();
    createDeployDosTask();
    createDeployIndexTask();
    createDeployQueueTask();
    createDeployAllTask();
    createShowConfigurationTask();
  }
348820
def save_config(self):
        
        self.set_option('recent_projects', self.recent_projects)
        self.set_option('expanded_state',
                        self.explorer.treewidget.get_expanded_state())
        self.set_option('scrollbar_position',
                        self.explorer.treewidget.get_scrollbar_position())
        if self.current_active_project and self.dockwidget:
            self.set_option('visible_if_project_open',
                            self.dockwidget.isVisible())
718606
public static void saveCurrentBugCollection(IProject project, IProgressMonitor monitor) throws CoreException {
        if (isBugCollectionDirty(project)) {
            SortedBugCollection bugCollection = (SortedBugCollection) project.getSessionProperty(SESSION_PROPERTY_BUG_COLLECTION);

            if (bugCollection != null) {
                writeBugCollection(project, bugCollection, monitor);
            }
        }
    }
580221
@Override
    public void addPreference(final U u, final I i, final Double d) {
        // update direct map
        Map<I, Double> userPreferences = userItemPreferences.get(u);
        if (userPreferences == null) {
            userPreferences = new HashMap<>();
            userItemPreferences.put(u, userPreferences);
        }
        Double preference = userPreferences.get(i);
        if (preference == null) {
            preference = 0.0;
        } else if (ignoreDuplicatePreferences) {
            // if duplicate preferences should be ignored, then we do not take into account the new value
            preference = null;
        }
        if (preference != null) {
            preference += d;
            userPreferences.put(i, preference);
        }
        // update items
        items.add(i);
    }
1202761
private void saveLayout(UserView view, IPerson owner) throws Exception {
        IUserProfile profile = new UserProfile();
        profile.setProfileId(view.getProfileId());
        userLayoutStore.setUserLayout(owner, profile, view.getLayout(), true, false);
    }
1118163
public static void setSpecificSARLConfigurationFor(
			IProject project,
			IPath outputPath) {
		final IPreferenceStore preferenceStore = getSARLPreferencesFor(project);
		// Force to use a specific configuration for the SARL
		preferenceStore.setValue(IS_PROJECT_SPECIFIC, true);

		// Loop on the Xtext configurations embedded in the SARL compiler.
		String key;
		for (final OutputConfiguration projectConfiguration : getXtextConfigurationsFor(project)) {
			//
			// OUTPUT PATH
			key = BuilderPreferenceAccess.getKey(
					projectConfiguration,
					EclipseOutputConfigurationProvider.OUTPUT_DIRECTORY);
			preferenceStore.setValue(key, outputPath.toOSString());

			//
			// CREATE THE OUTPUT DIRECTORY
			key = BuilderPreferenceAccess.getKey(
					projectConfiguration,
					EclipseOutputConfigurationProvider.OUTPUT_CREATE_DIRECTORY);
			preferenceStore.setValue(key, true);

			//
			// OVERWRITE THE EXISTING FILES
			key = BuilderPreferenceAccess.getKey(
					projectConfiguration,
					EclipseOutputConfigurationProvider.OUTPUT_OVERRIDE);
			preferenceStore.setValue(key, true);

			//
			// SET GENERATED FILES AS DERIVED
			key = BuilderPreferenceAccess.getKey(
					projectConfiguration,
					EclipseOutputConfigurationProvider.OUTPUT_DERIVED);
			preferenceStore.setValue(key, true);

			//
			// CLEAN THE GENERATED FILES
			key = BuilderPreferenceAccess.getKey(
					projectConfiguration,
					EclipseOutputConfigurationProvider.OUTPUT_CLEANUP_DERIVED);
			preferenceStore.setValue(key, true);

			//
			// CLEAN THE OUTPUT DIRECTORY
			key = BuilderPreferenceAccess.getKey(
					projectConfiguration,
					EclipseOutputConfigurationProvider.OUTPUT_CLEAN_DIRECTORY);
			preferenceStore.setValue(key, true);
		}
	}