本文整理汇总了Java中edu.umd.cs.findbugs.config.UserPreferences类的典型用法代码示例。如果您正苦于以下问题:Java UserPreferences类的具体用法?Java UserPreferences怎么用?Java UserPreferences使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UserPreferences类属于edu.umd.cs.findbugs.config包,在下文中一共展示了UserPreferences类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: openProjectItemActionPerformed
import edu.umd.cs.findbugs.config.UserPreferences; //导入依赖的package包/类
private void openProjectItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_openProjectItemActionPerformed
if (!closeProjectHook(getCurrentProject(), L10N.getLocalString("msg.openproject_txt", "Open Project")))
return;
JFileChooser chooser = createFileChooser();
chooser.setFileFilter(projectFileFilter);
int result = chooseFileToOpen(chooser);
if (result == JFileChooser.CANCEL_OPTION)
return;
try {
File file = chooser.getSelectedFile();
Project project = new Project();
project.read(file.getPath());
setProject(project);
UserPreferences.getUserPreferences().useProject(file.getPath());
rebuildRecentProjectsMenu();
} catch (IOException e) {
logger.logMessage(ConsoleLogger.ERROR, MessageFormat.format( L10N.getLocalString("msg.couldnotopenproject_txt", "Could not open project: {0}"), new Object[]{e.getMessage()}));
}
}
示例2: openRecentProjectItemActionPerformed
import edu.umd.cs.findbugs.config.UserPreferences; //导入依赖的package包/类
private void openRecentProjectItemActionPerformed(java.awt.event.ActionEvent evt) {
if (!closeProjectHook(getCurrentProject(), L10N.getLocalString("msg.openproject_txt", "Open Project")))
return;
JMenuItem recentProjectItem = (JMenuItem) evt.getSource();
File file = new File(recentProjectItem.getText());
try {
System.setProperty("user.dir", file.getParent());
Project project = new Project();
project.read(file.getPath());
setProject(project);
UserPreferences.getUserPreferences().useProject(file.getPath());
} catch (IOException e) {
UserPreferences.getUserPreferences().removeProject(file.getPath());
logger.logMessage(ConsoleLogger.ERROR, MessageFormat.format(L10N.getLocalString("msg.couldnotopenproject_txt", "Could not open project: {0}"), new Object[]{e.getMessage()}));
} finally {
rebuildRecentProjectsMenu();
}
}
示例3: doAnalysis
import edu.umd.cs.findbugs.config.UserPreferences; //导入依赖的package包/类
public edu.umd.cs.findbugs.BugCollection doAnalysis(Project p, FindBugsProgress progressCallback)
throws IOException, InterruptedException {
StringWriter stringWriter = new StringWriter();
BugCollectionBugReporter pcb =
new BugCollectionBugReporter(p, new PrintWriter(stringWriter, true));
pcb.setPriorityThreshold(Priorities.LOW_PRIORITY);
IFindBugsEngine fb = createEngine(p, pcb);
fb.setUserPreferences(UserPreferences.createDefaultUserPreferences());
fb.setProgressCallback(progressCallback);
fb.setProjectName(p.getProjectName());
fb.execute();
String warnings = stringWriter.toString();
if (warnings.length() > 0) {
logger.warn("analysis warnings:", warnings);
}
return pcb.getBugCollection();
}
示例4: openProjectItemActionPerformed
import edu.umd.cs.findbugs.config.UserPreferences; //导入依赖的package包/类
private void openProjectItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_openProjectItemActionPerformed
if (!closeProjectHook(getCurrentProject(), L10N.getLocalString("msg.openproject_txt", "Open Project")))
return;
JFileChooser chooser = createFileChooser();
chooser.setFileFilter(projectFileFilter);
int result = chooseFileToOpen(chooser);
if (result == JFileChooser.CANCEL_OPTION)
return;
try {
File file = chooser.getSelectedFile();
Project project = new Project();
project.read(file.getPath());
setProject(project);
UserPreferences.getUserPreferences().useProject(file.getPath());
rebuildRecentProjectsMenu();
} catch (IOException e) {
logger.logMessage(Logger.ERROR, MessageFormat.format( L10N.getLocalString("msg.couldnotopenproject_txt", "Could not open project: {0}"), new Object[]{e.getMessage()}));
}
}
示例5: openRecentProjectItemActionPerformed
import edu.umd.cs.findbugs.config.UserPreferences; //导入依赖的package包/类
private void openRecentProjectItemActionPerformed(java.awt.event.ActionEvent evt) {
if (!closeProjectHook(getCurrentProject(), L10N.getLocalString("msg.openproject_txt", "Open Project")))
return;
JMenuItem recentProjectItem = (JMenuItem) evt.getSource();
File file = new File(recentProjectItem.getText());
try {
System.setProperty("user.dir", file.getParent());
Project project = new Project();
project.read(file.getPath());
setProject(project);
UserPreferences.getUserPreferences().useProject(file.getPath());
} catch (IOException e) {
UserPreferences.getUserPreferences().removeProject(file.getPath());
logger.logMessage(Logger.ERROR, MessageFormat.format(L10N.getLocalString("msg.couldnotopenproject_txt", "Could not open project: {0}"), new Object[]{e.getMessage()}));
} finally {
rebuildRecentProjectsMenu();
}
}
示例6: execute
import edu.umd.cs.findbugs.config.UserPreferences; //导入依赖的package包/类
/**
* Run the analysis.
* This should be done in a separate thread (not the GUI event thread).
* The progress callback can be used to update the user interface to
* reflect the progress of the analysis. The GUI may cancel the analysis
* by interrupting the analysis thread, in which case InterruptedException
* will be thrown by this method.
*
* @param progressCallback the progress callback
* @throws IOException if an I/O error occurs during the analysis
* @throws InterruptedException if the analysis thread is interrupted
*/
public void execute(FindBugsProgress progressCallback) throws IOException, InterruptedException {
findBugs.setProgressCallback(progressCallback);
// Honor current UserPreferences
findBugs.setUserPreferences(UserPreferences.getUserPreferences());
// Set analysis feature settings
findBugs.setAnalysisFeatureSettings(frame.getSettingList());
// Run the analysis!
findBugs.execute();
if (!SystemProperties.getBoolean("findbugs.noSummary")) {
// Get the summary!
createSummary(reporter.getProjectStats());
}
}
示例7: populateTable
import edu.umd.cs.findbugs.config.UserPreferences; //导入依赖的package包/类
/**
* populates the Detector JTable model with all available detectors
* Due to Netbeans form builder, populate table gets called before the tablesorter is installed,
* so it is correct for the model retrieved from the table to be assumed to be the base DefaultTableModel.
*/
private void populateTable() {
Iterator<DetectorFactory> i = DetectorFactoryCollection.instance().factoryIterator();
while (i.hasNext()) {
DetectorFactory factory = i.next();
if (factory.isHidden())
continue;
DefaultTableModel model = (DefaultTableModel) detectorTable.getModel();
model.addRow(new Object[]{
factory.getShortName(),
factory.getSpeed(),
UserPreferences.getUserPreferences().isDetectorEnabled(factory)
? Boolean.TRUE : Boolean.FALSE
});
factoryList.add(factory);
}
}
示例8: run
import edu.umd.cs.findbugs.config.UserPreferences; //导入依赖的package包/类
public void run(IProgressMonitor monitor) throws CoreException {
UserPreferences userPrefs = FindbugsPlugin.getUserPreferences(project);
ProjectFilterSettings filterSettings = userPrefs.getFilterSettings();
IPreferenceStore store = FindbugsPlugin.getPluginPreferences(project);
for (MarkerParameter mp : mpList) {
if (mp.markerType == null) {
continue;
}
if (!MarkerUtil.shouldDisplayWarning(mp.bug, filterSettings)) {
continue;
}
updateMarkerSeverity(store, mp);
// This triggers resource update on IResourceChangeListener's (BugTreeView)
addMarker(mp);
}
}
示例9: refreshUI
import edu.umd.cs.findbugs.config.UserPreferences; //导入依赖的package包/类
void refreshUI(UserPreferences prefs) {
IPreferenceStore store = propertyPage.getPreferenceStore();
scariestRankCombo.setText(MarkerSeverity.get(store.getString(FindBugsConstants.RANK_SCARIEST_MARKER_SEVERITY)).name());
scaryRankCombo.setText(MarkerSeverity.get(store.getString(FindBugsConstants.RANK_SCARY_MARKER_SEVERITY)).name());
troublingRankCombo.setText(MarkerSeverity.get(store.getString(FindBugsConstants.RANK_TROUBLING_MARKER_SEVERITY)).name());
ofConcernRankCombo.setText(MarkerSeverity.get(store.getString(FindBugsConstants.RANK_OFCONCERN_MARKER_SEVERITY)).name());
ProjectFilterSettings filterSettings = prefs.getFilterSettings();
minRankSlider.setSelection(filterSettings.getMinRank());
updateRankValueLabel();
minPriorityCombo.setText(filterSettings.getMinPriority());
for (Button checkBox : chkEnableBugCategoryList) {
checkBox.setSelection(filterSettings.containsCategory((String) checkBox.getData()));
}
syncSelectedCategories();
}
示例10: createDefaultUserPreferences
import edu.umd.cs.findbugs.config.UserPreferences; //导入依赖的package包/类
public static UserPreferences createDefaultUserPreferences() {
UserPreferences prefs = UserPreferences.createDefaultUserPreferences();
IPreferenceStore store = FindbugsPlugin.getDefault().getPreferenceStore();
String categoriesStr = store.getString(DISABLED_CATEGORIES);
Set<String> ids = decodeIds(categoriesStr);
for (String categoryId : ids) {
prefs.getFilterSettings().removeCategory(categoryId);
}
prefs.setRunAtFullBuild(false);
// Do not need, as per default the factory default is used if key is
// missing
// TODO later we can use custom workspace settings to disable detectors
// here
// Iterator<DetectorFactory> iterator =
// DetectorFactoryCollection.instance().factoryIterator();
// while (iterator.hasNext()) {
// DetectorFactory factory = iterator.next();
// prefs.enableDetector(factory, factory.isDefaultEnabled());
// }
return prefs;
}
示例11: getProjectPreferences
import edu.umd.cs.findbugs.config.UserPreferences; //导入依赖的package包/类
/**
* 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 FindBugs preferences for project");
return getWorkspacePreferences().clone();
}
}
示例12: getWorkspacePreferences
import edu.umd.cs.findbugs.config.UserPreferences; //导入依赖的package包/类
private static UserPreferences getWorkspacePreferences() {
// create initially default settings
UserPreferences userPrefs = FindBugsPreferenceInitializer.createDefaultUserPreferences();
File prefsFile = WORKSPACE_PREFS_PATH.toFile();
if (!prefsFile.isFile()) {
return userPrefs;
}
// load custom settings over defaults
FileInputStream in;
try {
in = new FileInputStream(prefsFile);
userPrefs.read(in);
} catch (IOException e) {
FindbugsPlugin.getDefault().logException(e, "Error reading custom FindBugs preferences for workspace");
}
return userPrefs;
}
示例13: readUserPreferences
import edu.umd.cs.findbugs.config.UserPreferences; //导入依赖的package包/类
/**
* Read UserPreferences for project from the file in the project directory.
* Returns null if the preferences have not been saved to a file, or if
* there is an error reading the preferences file.
*
* @param project
* the project to get the UserPreferences for
* @return the UserPreferences, or null if the UserPreferences file could
* not be read
* @throws CoreException
*/
private static UserPreferences readUserPreferences(IProject project) throws CoreException {
IFile userPrefsFile = getUserPreferencesFile(project);
if (!userPrefsFile.exists()) {
return null;
}
try {
// force is preventing us for out-of-sync exception if file was
// changed externally
InputStream in = userPrefsFile.getContents(true);
UserPreferences userPrefs = FindBugsPreferenceInitializer.createDefaultUserPreferences();
userPrefs.read(in);
return userPrefs;
} catch (IOException e) {
FindbugsPlugin.getDefault().logException(e, "Could not read user preferences for project");
return null;
}
}
示例14: loadFilesThatNeedFixing
import edu.umd.cs.findbugs.config.UserPreferences; //导入依赖的package包/类
public static void loadFilesThatNeedFixing() throws CoreException, IOException {
makeJavaProject();
TestingUtils.copyBrokenFiles(testIProject.getFolder(SRC_FOLDER_NAME), new File("classesToFix/"), new File("mockLibraries/"));
// Compiles the code
testIProject.refreshLocal(IResource.DEPTH_INFINITE, null);
testIProject.build(IncrementalProjectBuilder.FULL_BUILD, null);
FindbugsPlugin.setProjectSettingsEnabled(testIProject, null, true);
UserPreferences userPrefs = FindbugsPlugin.getUserPreferences(testIProject);
// enables categories like Security, which are disabled by default
userPrefs.getFilterSettings().clearAllCategories();
checkFBContribInstalled();
checkFindSecurityBugsInstalled();
TestingUtils.waitForUiEvents(100);
}
示例15: FindBugsFrame
import edu.umd.cs.findbugs.config.UserPreferences; //导入依赖的package包/类
/**
* Creates new form FindBugsFrame.
*/
public FindBugsFrame() {
String dirProp = System.getProperty("user.dir");
if (dirProp != null) {
currentDirectory = new File(dirProp);
}
UserPreferences prefs = UserPreferences.getUserPreferences();
prefs.read();
prefs.loadUserDetectorPreferences();
initComponents();
postInitComponents();
}