Package edu.umd.cs.findbugs

Examples of edu.umd.cs.findbugs.Project


     */
    public NewProjectWizard(Project curProject) {
        project = curProject;
        if (project == null) {
            ProjectSettings.newInstance();
            project = new Project();
            isNewProject = true;
        }
        boolean temp = false;

        if (curProject == null) {
            setTitle(edu.umd.cs.findbugs.L10N.getLocalString("dlg.new_item", "New Project"));
        } else {
            setTitle(edu.umd.cs.findbugs.L10N.getLocalString("dlg.reconfig", "Reconfigure"));
            temp = true;
        }

        final boolean reconfig = temp;

        JPanel mainPanel = new JPanel();
        mainPanel.setBorder(new EmptyBorder(5,5,5,5));
        mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));

        wizardComponents[0] = createFilePanel(
                edu.umd.cs.findbugs.L10N.getLocalString("dlg.class_jars_dirs_lbl", "Class archives and directories to analyze:"),
                analyzeList, analyzeModel, JFileChooser.FILES_AND_DIRECTORIES, directoryOrArchive,
                "Choose Class Archives and Directories to Analyze", false,
                "http://findbugs.sourceforge.net/manual/gui.html#d0e1087");

        wizardComponents[1] = createFilePanel(
                edu.umd.cs.findbugs.L10N.getLocalString("dlg.aux_class_lbl", "Auxiliary class locations:"), auxList, auxModel,
                JFileChooser.FILES_AND_DIRECTORIES, directoryOrArchive, "Choose Auxilliary Class Archives and Directories", false,
                "http://findbugs.sourceforge.net/FAQ.html#q4");

        wizardComponents[2] = createFilePanel(
                edu.umd.cs.findbugs.L10N.getLocalString("dlg.source_dirs_lbl", "Source directories:"), sourceList, sourceModel,
                JFileChooser.FILES_AND_DIRECTORIES, null, "Choose Source Directories", true,
                "http://findbugs.sourceforge.net/manual/gui.html#d0e1087");

        JPanel cloudPanel = new JPanel(new BorderLayout());
        cloudPanel.add(new JLabel("Store bug reviews in:"), BorderLayout.NORTH);
        cloudPanel.add(cloudSelector, BorderLayout.CENTER);

        wizardComponents[3] = cloudPanel;
        @SuppressWarnings("unchecked")
        ListCellRenderer<CloudPlugin>  aRenderer = new CloudComboBoxRenderer();
        cloudSelector.setRenderer(aRenderer);
        cloudSelector.addItem(null);
        String cloudId = project.getCloudId();

        for (CloudPlugin c : DetectorFactoryCollection.instance().getRegisteredClouds().values()) {
            String fbid = c.getFindbugsPluginId();
            Plugin plugin = Plugin.getByPluginId(fbid);
            if (plugin == null) {
                continue;
            }
            Boolean fbPluginStatus = project.getPluginStatus(plugin);
            if ((!c.isHidden() || c.getId().equals(cloudId)) && !Boolean.FALSE.equals(fbPluginStatus)) {
                cloudSelector.addItem(c);
            }
        }

        if (cloudId != null) {
            CloudPlugin c = DetectorFactoryCollection.instance().getRegisteredClouds().get(project.getCloudId());
            cloudSelector.setSelectedItem(c);
        }
        JPanel buttons = new JPanel();
        buttons.setLayout(new BoxLayout(buttons, BoxLayout.X_AXIS));
        if (MainFrameHelper.isMacLookAndFeel()) {
            buttons.add(Box.createHorizontalStrut(5));
            buttons.add(cancelButton);
            buttons.add(Box.createHorizontalStrut(5));
            buttons.add(finishButton);
        } else {
            buttons.add(Box.createHorizontalStrut(5));
            buttons.add(finishButton);
            buttons.add(Box.createHorizontalStrut(5));
            buttons.add(cancelButton);
        }
        finishButton.addActionListener(new ActionListener() {
            boolean keepGoing = false;

            private boolean displayWarningAndAskIfWeShouldContinue(String msg, String title) {
                if (keepGoing) {
                    return true;
                }
                boolean result = JOptionPane.showConfirmDialog(NewProjectWizard.this, msg, title, JOptionPane.OK_CANCEL_OPTION,
                        JOptionPane.WARNING_MESSAGE) == JOptionPane.OK_OPTION;
                if (result) {
                    keepGoing = true;
                }
                return result;

            }

            @Override
            public void actionPerformed(ActionEvent evt) {

                if (displayWarnings()) {
                    return;
                }
                Project p;
                String oldCloudId = null;
                p = project;
                oldCloudId = project.getCloudId();
                p.setGuiCallback(MainFrame.getInstance().getGuiCallback());
                clearProjectSettings(p);


                // Now that p is cleared, we can add in all the correct files.
                for (int i = 0; i < analyzeModel.getSize(); i++) {
                    p.addFile(analyzeModel.get(i));
                }
                for (int i = 0; i < auxModel.getSize(); i++) {
                    p.addAuxClasspathEntry(auxModel.get(i));
                }
                for (int i = 0; i < sourceModel.getSize(); i++) {
                    p.addSourceDir(sourceModel.get(i));
                }
                p.setProjectName(projectName.getText());
                CloudPlugin cloudPlugin = (CloudPlugin) cloudSelector.getSelectedItem();
                String newCloudId;
                if (cloudPlugin == null || cloudSelector.getSelectedIndex() == 0) {
                    newCloudId = null;
                } else {
                    newCloudId = cloudPlugin.getId();
                }
                p.setCloudId(newCloudId);

                MainFrame mainFrame = MainFrame.getInstance();
                if (keepGoing) {
                    mainFrame.setProject(p);
                }
                if (projectChanged && (isNewProject
                        || JOptionPane.showConfirmDialog(NewProjectWizard.this, edu.umd.cs.findbugs.L10N
                                .getLocalString("dlg.project_settings_changed_lbl",
                                        "Project settings have been changed.  Perform a new analysis with the changed files?"),
                                        edu.umd.cs.findbugs.L10N.getLocalString("dlg.redo_analysis_question_lbl", "Redo analysis?"),
                                        JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION)) {
                    AnalyzingDialog.show(p);
                } else if (!Util.nullSafeEquals(newCloudId, oldCloudId)) {
                    BugCollection bugs = mainFrame.getBugCollection();
                    try {
                        bugs.reinitializeCloud();
                        mainFrame.getComments().updateCloud();
                    } catch (Exception e) {
                        JOptionPane.showMessageDialog(NewProjectWizard.this, "Error loading " + newCloudId + "\n\n"
                                + e.getClass().getSimpleName() + ": " + e.getMessage(),
                                "FindBugs Cloud Error", JOptionPane.ERROR_MESSAGE);
                        return;
                    }
                    mainFrame.getComments().updateCommentsFromLeafInformation(mainFrame.getCurrentSelectedBugLeaf());

                }
                if (reconfig) {
                    mainFrame.setProjectChanged(true);
                }

                String name = p.getProjectName();
                if (name == null) {
                    name = Project.UNNAMED_PROJECT;
                    Debug.println("PROJECT NAME IS NULL!!");
                }
                if (projectNameChanged) {
View Full Code Here


            final NewProjectWizard thisGUI = this;
            myPanel.add(wizardButton, gbc);
            wizardButton.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent evt) {
                    final Project tempProject = new Project();
                    for (int i = 0; i < analyzeModel.getSize(); i++) {
                        tempProject.addFile(analyzeModel.get(i));
                    }
                    for (int i = 0; i < auxModel.getSize(); i++) {
                        tempProject.addAuxClasspathEntry(auxModel.get(i));
                    }

                    java.awt.EventQueue.invokeLater(new Runnable() {
                        @Override
                        public void run() {
View Full Code Here

     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                final SourceDirectoryWizard dialog = new SourceDirectoryWizard(new javax.swing.JFrame(), true, new Project(),
                        null);
                dialog.setVisible(true);
            }
        });
    }
View Full Code Here

    private void handleWindowClose() {
        TreeModel bt = (MainFrame.getInstance().getTree().getModel());
        if (bt instanceof BugTreeModel) {
            ((BugTreeModel) bt).checkSorter();
        }
        Project project = getCurrentProject();

        boolean changed = pluginsAdded;
        pluginsAdded = false;
        List<String> enabledPlugins = new ArrayList<String>();
        List<String> disabledPlugins = new ArrayList<String>();
        for (Map.Entry<Plugin, EnabledSettings> entry : pluginEnabledStatus.entrySet()) {
            Plugin plugin = entry.getKey();
            EnabledSettings enabled = entry.getValue();
            if (project != null) {
                Boolean newSetting = enabled.project;
                Boolean existingSetting = project.getPluginStatus(plugin);
                boolean sameSettings = Objects.equals(existingSetting, newSetting);
                if (!sameSettings) {
                    project.setPluginStatusTrinary(plugin.getPluginId(), newSetting);
                    changed = true;
                }
            }
            if (enabled.global) {
                enabledPlugins.add(plugin.getPluginId());
View Full Code Here

    EnabledSettings isEnabled(@CheckForNull Project project, Plugin plugin) {
        return new EnabledSettings(plugin.isGloballyEnabled(), project == null ? null : project.getPluginStatus(plugin));
    }

    private void rebuildPluginCheckboxes() {
        Project currentProject = getCurrentProject();
        pluginPanelCenter.removeAll();
        if (currentProject != null) {
            GridBagConstraints g = new GridBagConstraints();
            g.fill = GridBagConstraints.NONE;
            g.insets = new Insets(5,5,5,5);
View Full Code Here

        markBugCollectionDirty(project, false);
    }

    private static SortedBugCollection createDefaultEmptyBugCollection(IProject project) throws CoreException {
        SortedBugCollection bugCollection = new SortedBugCollection();
        Project fbProject = bugCollection.getProject();

        UserPreferences userPrefs = getUserPreferences(project);

        String cloudId = userPrefs.getCloudId();
        if (cloudId != null) {
            fbProject.setCloudId(cloudId);
        }
        cacheBugCollectionAndProject(project, bugCollection, fbProject);
        return bugCollection;
    }
View Full Code Here

            if (item != null) {
                currentUserPreferences.setCloudId(item.getId());

                SortedBugCollection collection = FindbugsPlugin.getBugCollectionIfSet(eclipseProj);
                if (collection != null) {
                    Project fbProject = collection.getProject();
                    if (fbProject != null && !item.getId().equals(fbProject.getCloudId())) {
                        fbProject.setCloudId(item.getId());
                        collection.reinitializeCloud();
                        IWorkbenchPage page = FindbugsPlugin.getActiveWorkbenchWindow().getActivePage();
                        if (page != null) {
                            IViewPart view = page.findView(FindbugsPlugin.TREE_VIEW_ID);
                            if (view instanceof CommonNavigator) {
View Full Code Here

        // clear markers
        clearMarkers(resources);

        st.newPoint("configureOutputFiles");

        final Project findBugsProject = new Project();
        findBugsProject.setProjectName(javaProject.getElementName());
        final Reporter bugReporter = new Reporter(javaProject, findBugsProject, monitor);
        if (FindBugsConsole.getConsole() != null) {
            bugReporter.setReportingStream(FindBugsConsole.getConsole().newOutputStream());
        }
        bugReporter.setPriorityThreshold(userPrefs.getUserDetectorThreshold());

        FindBugs.setHome(FindbugsPlugin.getFindBugsEnginePluginLocation());

        Map<IPath, IPath> outLocations = createOutputLocations();

        // collect all related class/jar/war etc files for analysis
        collectClassFiles(resources, outLocations, findBugsProject);

        // attach source directories (can be used by some detectors, see
        // SwitchFallthrough)
        configureSourceDirectories(findBugsProject, outLocations);

        if (findBugsProject.getFileCount() == 0) {
            if (DEBUG) {
                FindbugsPlugin.getDefault().logInfo("No resources to analyse for project " + project);
            }
            return;
        }

        st.newPoint("createAuxClasspath");

        String[] classPathEntries = createAuxClasspath();
        // add to findbugs classpath
        for (String entry : classPathEntries) {
            findBugsProject.addAuxClasspathEntry(entry);
        }
        String cloudId = userPrefs.getCloudId();
        if (cloudId != null) {
            findBugsProject.setCloudId(cloudId);
        }


        st.newPoint("configureProps");
        IPreferenceStore store = FindbugsPlugin.getPluginPreferences(project);
View Full Code Here

        st = new StopTimer();

        // clear markers
        clearMarkers(null);

        final Project findBugsProject = new Project();
        final Reporter bugReporter = new Reporter(javaProject, findBugsProject, monitor);
        bugReporter.setPriorityThreshold(userPrefs.getUserDetectorThreshold());

        reportFromXml(fileName, findBugsProject, bugReporter);
        // Merge new results into existing results.
View Full Code Here

TOP

Related Classes of edu.umd.cs.findbugs.Project

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.