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

The following examples show how to use org.eclipse.core.resources.IProject#getSessionProperty() . 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: FindbugsPlugin.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
private static boolean isBugCollectionDirty(IProject project) throws CoreException {
    Object dirty = project.getSessionProperty(SESSION_PROPERTY_BUG_COLLECTION_DIRTY);

    if (dirty == null) {
        return false;
    }
    return ((Boolean) dirty).booleanValue();
}
 
Example 3
Source File: FindbugsPlugin.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
@CheckForNull
public static SortedBugCollection getBugCollectionIfSet(IProject project) {
    try {
        return (SortedBugCollection) project.getSessionProperty(SESSION_PROPERTY_BUG_COLLECTION);
    } catch (CoreException ignored) {
        FindbugsPlugin.getDefault().logException(ignored, "IO Exception reading project bugs.");
        return null;
    }
}
 
Example 4
Source File: FindbugsPlugin.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * If necessary, save current bug collection for project to disk.
 *
 * @param project
 *            the project
 * @param monitor
 *            a progress monitor
 * @throws CoreException
 */
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);
        }
    }
}
 
Example 5
Source File: FindbugsPlugin.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static boolean isProjectSettingsEnabled(IProject project) {
    // fast path: read from session, if available
    Boolean enabled;
    try {
        enabled = (Boolean) project.getSessionProperty(SESSION_PROPERTY_SETTINGS_ON);
    } catch (CoreException e) {
        enabled = null;
    }
    if (enabled != null) {
        return enabled.booleanValue();
    }

    // legacy support: before 1.3.8, there was ONLY project preferences in
    // .fbprefs
    // so check if the file is there...
    IFile file = getUserPreferencesFile(project);
    boolean projectPropsEnabled = file.isAccessible();
    if (projectPropsEnabled) {
        ScopedPreferenceStore store = new ScopedPreferenceStore(new ProjectScope(project), PLUGIN_ID);
        // so if the file is there, we can check if after 1.3.8 the flag is
        // set
        // to use workspace properties instead
        projectPropsEnabled = !store.contains(FindBugsConstants.PROJECT_PROPS_DISABLED)
                || !store.getBoolean(FindBugsConstants.PROJECT_PROPS_DISABLED);
    }
    // remember in the session to speedup access, don't touch the store
    setProjectSettingsEnabled(project, null, projectPropsEnabled);
    return projectPropsEnabled;
}
 
Example 6
Source File: DerbyServerUtils.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
public boolean getRunning(IProject proj) throws CoreException {
	Object value = proj.getSessionProperty(new QualifiedName(CommonNames.UI_PATH, CommonNames.ISRUNNING));
	
	return value != null;
}
 
Example 7
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 8
Source File: DerbyServerUtils.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
public boolean getRunning(IProject proj) throws CoreException {
	Object value = proj.getSessionProperty(new QualifiedName(CommonNames.UI_PATH, CommonNames.ISRUNNING));
	
	return value != null;
}