Skip to content

Commit

Permalink
Fixes when retrieving list of projects and authentication is required.
Browse files Browse the repository at this point in the history
  • Loading branch information
hmvictor committed May 3, 2016
1 parent 9f9d2d9 commit faa145e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 11 deletions.
1 change: 1 addition & 0 deletions src/main/java/qubexplorer/ui/ProjectChooser.form
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<Property name="title" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="qubexplorer/ui/Bundle.properties" key="ProjectChooser.title" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="modal" type="boolean" value="true"/>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
Expand Down
1 change: 1 addition & 0 deletions src/main/java/qubexplorer/ui/ProjectChooser.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
21 changes: 12 additions & 9 deletions src/main/java/qubexplorer/ui/SonarIssuesTopComponent.java
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down Expand Up @@ -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){

}
}

Expand Down
8 changes: 6 additions & 2 deletions src/main/java/qubexplorer/ui/task/TaskExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit faa145e

Please sign in to comment.