From faa145eedec208e7123a34ea636e6b4f9af9039d Mon Sep 17 00:00:00 2001 From: Victor Herrera Date: Tue, 3 May 2016 01:11:08 -0500 Subject: [PATCH] Fixes when retrieving list of projects and authentication is required. --- .../java/qubexplorer/ui/ProjectChooser.form | 1 + .../java/qubexplorer/ui/ProjectChooser.java | 1 + .../ui/SonarIssuesTopComponent.java | 21 +++++++++++-------- .../qubexplorer/ui/task/TaskExecutor.java | 8 +++++-- 4 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/main/java/qubexplorer/ui/ProjectChooser.form b/src/main/java/qubexplorer/ui/ProjectChooser.form index 32e8271..472bdcf 100644 --- a/src/main/java/qubexplorer/ui/ProjectChooser.form +++ b/src/main/java/qubexplorer/ui/ProjectChooser.form @@ -6,6 +6,7 @@ + diff --git a/src/main/java/qubexplorer/ui/ProjectChooser.java b/src/main/java/qubexplorer/ui/ProjectChooser.java index 103c44f..ea8d6a3 100644 --- a/src/main/java/qubexplorer/ui/ProjectChooser.java +++ b/src/main/java/qubexplorer/ui/ProjectChooser.java @@ -119,6 +119,7 @@ private void initComponents() { setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); setTitle(org.openide.util.NbBundle.getMessage(ProjectChooser.class, "ProjectChooser.title")); // NOI18N + setModal(true); addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent evt) { formWindowClosing(evt); diff --git a/src/main/java/qubexplorer/ui/SonarIssuesTopComponent.java b/src/main/java/qubexplorer/ui/SonarIssuesTopComponent.java index 92042a6..a2d467c 100644 --- a/src/main/java/qubexplorer/ui/SonarIssuesTopComponent.java +++ b/src/main/java/qubexplorer/ui/SonarIssuesTopComponent.java @@ -696,7 +696,6 @@ private void openIssueLocation(IssueLocation issueLocation) { LOGGER.log(Level.WARNING, ex.getMessage(), ex); Exceptions.printStackTrace(ex); } catch (ProjectNotFoundException ex) { - LOGGER.log(Level.WARNING, ex.getMessage(), ex); String message = org.openide.util.NbBundle.getMessage(SonarIssuesTopComponent.class, "ProjectNotFound", ex.getShortProjectKey()); DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(message, NotifyDescriptor.ERROR_MESSAGE)); } @@ -789,16 +788,20 @@ private void addEditorAnnotations(RadarIssue[] issues) { private void tryToAtachEditorAnnotation(RadarIssue issue) throws DataObjectNotFoundException { IssueLocation issueLocation = issue.getLocation(); - FileObject fileObject = issueLocation.getFileObject(projectContext.getProject(), projectContext.getConfiguration()); - if (fileObject != null) { - if (isFileOpen(fileObject)) { - Annotation atachedAnnotation = issue.getLocation().attachAnnotation(issue, fileObject); - if (atachedAnnotation != null) { - attachedAnnotations.add(atachedAnnotation); + try{ + FileObject fileObject = issueLocation.getFileObject(projectContext.getProject(), projectContext.getConfiguration()); + if (fileObject != null) { + if (isFileOpen(fileObject)) { + Annotation atachedAnnotation = issue.getLocation().attachAnnotation(issue, fileObject); + if (atachedAnnotation != null) { + attachedAnnotations.add(atachedAnnotation); + } + } else { + fileOpenedNotifier.registerFileOpenedListener(fileObject, new AnnotationAttacher(issue)); } - } else { - fileOpenedNotifier.registerFileOpenedListener(fileObject, new AnnotationAttacher(issue)); } + }catch(ProjectNotFoundException ex){ + } } diff --git a/src/main/java/qubexplorer/ui/task/TaskExecutor.java b/src/main/java/qubexplorer/ui/task/TaskExecutor.java index 0c8752c..0c1c0b9 100644 --- a/src/main/java/qubexplorer/ui/task/TaskExecutor.java +++ b/src/main/java/qubexplorer/ui/task/TaskExecutor.java @@ -73,7 +73,11 @@ protected final void done() { handle = null; if (task.getUserCredentials() != null) { assert task.getServerUrl() != null; - authenticationRepository.saveAuthentication(task.getServerUrl(), task.getProjectContext().getConfiguration().getKey().toString(), task.getUserCredentials()); + String contextResourceKey=null; + if (task.getProjectContext() != null && task.getProjectContext().getConfiguration() != null) { + task.getProjectContext().getConfiguration().getKey().toString(); + } + authenticationRepository.saveAuthentication(task.getServerUrl(), contextResourceKey, task.getUserCredentials()); } } catch (ExecutionException ex) { LOGGER.log(Level.INFO, ex.getMessage(), ex); @@ -83,7 +87,7 @@ protected final void done() { if (cause instanceof AuthorizationException) { assert task.getServerUrl() != null; String resourceKey = null; - if (task.getProjectContext() != null) { + if (task.getProjectContext() != null && task.getProjectContext().getConfiguration() != null) { resourceKey = task.getProjectContext().getConfiguration().getKey().toString(); } UserCredentials auth = authenticationRepository.getAuthentication(task.getServerUrl(), resourceKey);