Java Code Examples for org.eclipse.core.resources.IProject#setSessionProperty()

The following examples show how to use org.eclipse.core.resources.IProject#setSessionProperty() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FindbugsPlugin.java    From spotbugs with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Get project own preferences set.
 *
 * @param project
 *            must be non null, exist and be opened
 * @param forceRead
 * @return current project preferences, independently if project preferences
 *         are enabled or disabled for given project.
 */
public static UserPreferences getProjectPreferences(IProject project, boolean forceRead) {
    try {
        UserPreferences prefs = (UserPreferences) project.getSessionProperty(SESSION_PROPERTY_USERPREFS);
        if (prefs == null || forceRead) {
            prefs = readUserPreferences(project);
            if (prefs == null) {
                prefs = getWorkspacePreferences().clone();
            }
            project.setSessionProperty(SESSION_PROPERTY_USERPREFS, prefs);
        }
        return prefs;
    } catch (CoreException e) {
        FindbugsPlugin.getDefault().logException(e, "Error getting SpotBugs preferences for project");
        return getWorkspacePreferences().clone();
    }
}
 
Example 2
Source File: DerbyServerUtils.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public void setRunning(IProject proj, Boolean value) throws CoreException {
	try{
		if (value != null && value.equals(Boolean.FALSE)){
			value = null;
		}
		if(proj.isOpen()){
			proj.setSessionProperty(new QualifiedName(CommonNames.UI_PATH,CommonNames.ISRUNNING ),value);
		}
	}catch(Exception e){
		Logger.log("DerbyServerUtils.setRunning() error: "+e, IStatus.ERROR);	
		
	}
	DerbyIsRunningDecorator.performUpdateDecor(proj);
}
 
Example 3
Source File: FindbugsPlugin.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static void setProjectSettingsEnabled(IProject project,
        @CheckForNull IPreferenceStore store, boolean enabled) {
    try {
        project.setSessionProperty(SESSION_PROPERTY_SETTINGS_ON, Boolean.valueOf(enabled));
    } catch (CoreException e) {
        FindbugsPlugin.getDefault().logException(e, "Error setting SpotBugs session property for project");
    }
    if (store != null) {
        store.setValue(FindBugsConstants.PROJECT_PROPS_DISABLED, !enabled);
    }
}
 
Example 4
Source File: DerbyServerUtils.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public void setRunning(IProject proj, Boolean value) throws CoreException {
	try{
		if (value != null && value.equals(Boolean.FALSE)){
			value = null;
		}
		if(proj.isOpen()){
			proj.setSessionProperty(new QualifiedName(CommonNames.UI_PATH,CommonNames.ISRUNNING ),value);
		}
	}catch(Exception e){
		Logger.log("DerbyServerUtils.setRunning() error: "+e, IStatus.ERROR);	
		
	}
	DerbyIsRunningDecorator.performUpdateDecor(proj);
}
 
Example 5
Source File: TexBuilder.java    From texlipse with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Opens a messabox where the user is asked wether he wants to continue the build
 * @param project
 * @return
 * @throws CoreException
 */
private boolean askUserForContinue(IProject project) throws CoreException{
    Object c = project.getSessionProperty(new QualifiedName(null, "AlwaysContinueBuilding"));
    if (c == null) {
        // ask the user if he wants to continue
        final Shell shell = TexlipsePlugin.getCurrentWorkbenchPage().getActiveEditor().getSite().getShell();
        final StringBuffer toggle = new StringBuffer();
        final StringBuffer returnCode = new StringBuffer();

        shell.getDisplay().syncExec(new Runnable() {
           public void run() {
               final MessageDialogWithToggle mess = MessageDialogWithToggle.openOkCancelConfirm(
                       TexlipsePlugin.getCurrentWorkbenchPage().getActiveEditor().getSite().getShell(), 
                       TexlipsePlugin.getResourceString("builderErrorDuringBuildTitle"), 
                       TexlipsePlugin.getResourceString("builderErrorDuringBuild"), 
                       TexlipsePlugin.getResourceString("builderErrorDuringBuildToggle"), false, null, null);
               if (mess.getToggleState()) {
                   toggle.append(true);
               }
               if (mess.getReturnCode() == MessageDialogWithToggle.CANCEL)
                   returnCode.append(false);
            } 
        });
        
        if (toggle.length() > 0) {
            if (returnCode.length() > 0) {
                project.setSessionProperty(new QualifiedName(null, "AlwaysContinueBuilding"), new Boolean(false));
            } else {
                project.setSessionProperty(new QualifiedName(null, "AlwaysContinueBuilding"), new Boolean(true));
            }
        }
        if (returnCode.length() > 0) {
            return false;
        }
    } else {
        //we have a saved state
        Boolean b = (Boolean) c;
        if (b.booleanValue() == true)
            return true;
        else
            return false;
    }
    return true;
}
 
Example 6
Source File: FindbugsPlugin.java    From spotbugs with GNU Lesser General Public License v2.1 4 votes vote down vote up
public static void markBugCollectionDirty(IProject project, boolean isDirty) throws CoreException {
    project.setSessionProperty(SESSION_PROPERTY_BUG_COLLECTION_DIRTY, isDirty ? Boolean.TRUE : Boolean.FALSE);
}
 
Example 7
Source File: FindbugsPlugin.java    From spotbugs with GNU Lesser General Public License v2.1 4 votes vote down vote up
private static void cacheBugCollectionAndProject(IProject project, SortedBugCollection bugCollection, Project fbProject)
        throws CoreException {
    project.setSessionProperty(SESSION_PROPERTY_BUG_COLLECTION, bugCollection);
    markBugCollectionDirty(project, false);
}
 
Example 8
Source File: FindbugsPlugin.java    From spotbugs with GNU Lesser General Public License v2.1 3 votes vote down vote up
/**
 * Store a new bug collection for a project. The collection is stored in the
 * session, and also in a file in the project.
 *
 * @param project
 *            the project
 * @param bugCollection
 *            the bug collection
 * @param monitor
 *            progress monitor
 * @throws IOException
 * @throws CoreException
 */
public static void storeBugCollection(IProject project, final SortedBugCollection bugCollection, IProgressMonitor monitor)
        throws IOException, CoreException {

    // Store the bug collection and findbugs project in the session
    project.setSessionProperty(SESSION_PROPERTY_BUG_COLLECTION, bugCollection);

    if (bugCollection != null) {
        writeBugCollection(project, bugCollection, monitor);
    }
}