Skip to content

Commit 120ef67

Browse files
committed
Merge branch 'nb80'
2 parents ceb1f1a + 6cdb48d commit 120ef67

8 files changed

Lines changed: 72 additions & 36 deletions

File tree

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ This plugin provides support for GitHub Issue Tracker.
3030

3131
If you want to enable/disable these queries, Please change them on the Options panel.(Tools > Options > Team > GitHub Issues)
3232

33+
## GitHub OAuth Token
34+
35+
You can get a your OAuth token from the following: Settings > Applications > Personal access tokens > Generate new token
36+
37+
- Check `repo`
38+
- Input token description
39+
- Click generate token
40+
3341
## Resources
3442

3543
- [egit-github](https://github.com/eclipse/egit-github)

pom.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>com.junichi11</groupId>
55
<artifactId>netbeans-github-issues</artifactId>
6-
<version>0.0.2-SNAPSHOT</version>
6+
<version>0.0.3-SNAPSHOT</version>
77
<packaging>nbm</packaging>
88
<build>
99
<plugins>
@@ -17,6 +17,8 @@
1717
<verifyRuntime>warn</verifyRuntime>
1818
<licenseName>Common Development and Distribution License (CDDL) v1.0 and GNU General Public License (GPL) v2</licenseName>
1919
<licenseFile>license.txt</licenseFile>
20+
<author>junichi11(Junichi Yamamoto)</author>
21+
<homePageUrl>https://github.com/junichi11/netbeans-github-issues-plugin</homePageUrl>
2022
</configuration>
2123
</plugin>
2224
<plugin>

src/main/java/com/junichi11/netbeans/modules/github/issues/GitHubIssuesConnector.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,11 @@ public Repository createRepository() {
7878
@Override
7979
public Repository createRepository(RepositoryInfo info) {
8080
GitHubRepository repository = new GitHubRepository(info);
81+
GitHubRepositoryManager.getInstance().add(repository);
8182
return createRepository(repository);
8283
}
8384

8485
private Repository createRepository(GitHubRepository repository) {
85-
GitHubRepositoryManager.getInstance().add(repository);
8686
GitHubIssues githubIssues = GitHubIssues.getInstance();
8787
BugtrackingSupport<GitHubRepository, GitHubQuery, GitHubIssue> bugtrackingSupport = githubIssues.getBugtrackingSupport();
8888
return bugtrackingSupport.createRepository(

src/main/java/com/junichi11/netbeans/modules/github/issues/issue/GitHubIssueController.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,7 @@ private CloseReopenAction getCloseReopenAction() {
181181
public void propertyChange(PropertyChangeEvent evt) {
182182
switch (evt.getPropertyName()) {
183183
case CommentsPanel.PROP_COMMENT_QUOTE:
184-
GitHubIssuePanel p = getPanel();
185-
String quoteComment = StringUtils.toQuoteComment(p.getQuoteComment()) + "\n"; // NOI18N
186-
p.appendNewComment(quoteComment);
184+
quoteComment();
187185
break;
188186
case CommentsPanel.PROP_COMMENT_EDITED:
189187
editComment();
@@ -196,6 +194,18 @@ public void propertyChange(PropertyChangeEvent evt) {
196194
}
197195
}
198196

197+
private void quoteComment() {
198+
SwingUtilities.invokeLater(new Runnable() {
199+
200+
@Override
201+
public void run() {
202+
GitHubIssuePanel p = getPanel();
203+
String quoteComment = StringUtils.toQuoteComment(p.getQuoteComment()) + "\n"; // NOI18N
204+
p.appendNewComment(quoteComment);
205+
}
206+
});
207+
}
208+
199209
@NbBundle.Messages({
200210
"GitHubIssueController.edit.comment.title=Edit Comment",
201211
"GitHubIssueController.edit.comment.fail=Can't edit this comment."

src/main/java/com/junichi11/netbeans/modules/github/issues/repository/GitHubRepository.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ public Collection<GitHubQuery> getQueries() {
655655
* @param query a query
656656
*/
657657
public void addQuery(GitHubQuery query) {
658-
queries.add(query);
658+
getQueries().add(query);
659659
}
660660

661661
/**
@@ -668,7 +668,7 @@ public void removeQuery(GitHubQuery query) {
668668
if (!GitHubDefaultQueries.isDefaultQuery(query)) {
669669
removeQueryConfig(query);
670670
}
671-
queries.remove(query);
671+
getQueries().remove(query);
672672
fireQueryListChanged();
673673
}
674674

@@ -706,12 +706,12 @@ public void optionsChanged() {
706706

707707
private void setDefaultQuery(GitHubQuery query, boolean isEnabled) {
708708
if (isEnabled) {
709-
if (!queries.contains(query)) {
710-
queries.add(query);
709+
if (!getQueries().contains(query)) {
710+
getQueries().add(query);
711711
}
712712
} else {
713-
if (queries.contains(query)) {
714-
queries.remove(query);
713+
if (getQueries().contains(query)) {
714+
getQueries().remove(query);
715715
}
716716
}
717717
}

src/main/java/com/junichi11/netbeans/modules/github/issues/repository/GitHubRepositoryController.java

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ public void applyChanges() {
104104
.setRepositoryAuthor(p.getRepositoryAuthor())
105105
.setRepositoryName(p.getRepositoryName());
106106
repository.setRepositoryInfo(gitHubRepositoryInfo);
107+
GitHubRepositoryManager.getInstance().add(repository);
107108
}
108109

109110
@Override
@@ -148,6 +149,20 @@ private GitHubRepositoryPanel getPanel() {
148149
"GithubRepositoryController.label.repositoryName=Repository Name",})
149150
private void validate() {
150151
GitHubRepositoryPanel repositoryPanel = getPanel();
152+
if (!repositoryPanel.isPropertyFile()) {
153+
// oauth token
154+
if (StringUtils.isEmpty(repositoryPanel.getOAuthToken())) {
155+
errorMessage = Bundle.GithubRepositoryController_message_empty_error(Bundle.GithubRepositoryController_label_oauthToken());
156+
return;
157+
}
158+
159+
// user name
160+
if (StringUtils.isEmpty(repositoryPanel.getUserName())) {
161+
errorMessage = Bundle.GithubRepositoryController_message_empty_error(Bundle.GithubRepositoryController_label_userName());
162+
return;
163+
}
164+
}
165+
151166
// display name
152167
String displayName = repositoryPanel.getDisplayName();
153168
if (StringUtils.isEmpty(displayName)) {
@@ -169,20 +184,6 @@ private void validate() {
169184
}
170185
}
171186

172-
if (!repositoryPanel.isPropertyFile()) {
173-
// user name
174-
if (StringUtils.isEmpty(repositoryPanel.getUserName())) {
175-
errorMessage = Bundle.GithubRepositoryController_message_empty_error(Bundle.GithubRepositoryController_label_userName());
176-
return;
177-
}
178-
179-
// oauth token
180-
if (StringUtils.isEmpty(repositoryPanel.getOAuthToken())) {
181-
errorMessage = Bundle.GithubRepositoryController_message_empty_error(Bundle.GithubRepositoryController_label_oauthToken());
182-
return;
183-
}
184-
}
185-
186187
// repository
187188
if (StringUtils.isEmpty(repositoryPanel.getRepositoryAuthor())) {
188189
errorMessage = Bundle.GithubRepositoryController_message_empty_error(Bundle.GithubRepositoryController_label_repositoryAuthor());

src/main/java/com/junichi11/netbeans/modules/github/issues/repository/ui/GitHubRepositoryPanel.form

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,17 +69,17 @@
6969
<Component id="oauthTokenTextField" alignment="3" min="-2" max="-2" attributes="0"/>
7070
<Component id="addRepositoryButton" alignment="3" min="-2" max="-2" attributes="0"/>
7171
</Group>
72-
<EmptySpace max="-2" attributes="0"/>
73-
<Group type="103" groupAlignment="3" attributes="0">
74-
<Component id="displayNameLabel" alignment="3" min="-2" max="-2" attributes="0"/>
75-
<Component id="displayNameTextField" alignment="3" min="-2" max="-2" attributes="0"/>
76-
</Group>
77-
<EmptySpace max="-2" attributes="0"/>
72+
<EmptySpace min="-2" max="-2" attributes="0"/>
7873
<Group type="103" groupAlignment="3" attributes="0">
7974
<Component id="userNameLabel" alignment="3" min="-2" max="-2" attributes="0"/>
8075
<Component id="userNameTextField" alignment="3" min="-2" max="-2" attributes="0"/>
8176
</Group>
8277
<EmptySpace max="-2" attributes="0"/>
78+
<Group type="103" groupAlignment="3" attributes="0">
79+
<Component id="displayNameTextField" alignment="3" min="-2" max="-2" attributes="0"/>
80+
<Component id="displayNameLabel" alignment="3" min="-2" max="-2" attributes="0"/>
81+
</Group>
82+
<EmptySpace min="-2" max="-2" attributes="0"/>
8383
<Group type="103" groupAlignment="3" attributes="0">
8484
<Component id="repositoryAuthorTextField" alignment="3" min="-2" max="-2" attributes="0"/>
8585
<Component id="repositoryLabel" alignment="3" min="-2" max="-2" attributes="0"/>

src/main/java/com/junichi11/netbeans/modules/github/issues/repository/ui/GitHubRepositoryPanel.java

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -404,14 +404,14 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
404404
.addComponent(oauthTokenTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
405405
.addComponent(addRepositoryButton))
406406
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
407-
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
408-
.addComponent(displayNameLabel)
409-
.addComponent(displayNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
410-
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
411407
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
412408
.addComponent(userNameLabel)
413409
.addComponent(userNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
414410
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
411+
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
412+
.addComponent(displayNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
413+
.addComponent(displayNameLabel))
414+
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
415415
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
416416
.addComponent(repositoryAuthorTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
417417
.addComponent(repositoryLabel)
@@ -444,6 +444,9 @@ private void propertyFileCheckBoxActionPerformed(java.awt.event.ActionEvent evt)
444444
fireChange();
445445
}//GEN-LAST:event_propertyFileCheckBoxActionPerformed
446446

447+
@NbBundle.Messages({
448+
"GitHubRepositoryPanel.addRepositoryButtonAction.error.empty.token=Please set OAuth token.",
449+
"GitHubRepositoryPanel.addRepositoryButtonAction.error.wrong.token=There is no repository or your OAuth token is wrong.",})
447450
private void addRepositoryButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addRepositoryButtonActionPerformed
448451
RequestProcessor rp = GitHubIssues.getInstance().getRequestProcessor();
449452
rp.post(new Runnable() {
@@ -452,11 +455,23 @@ private void addRepositoryButtonActionPerformed(java.awt.event.ActionEvent evt)
452455
public void run() {
453456
String oAuthToken = getOAuthToken();
454457
if (StringUtils.isEmpty(oAuthToken)) {
455-
UiUtils.showErrorDialog("Please set OAuth token");
458+
UiUtils.showErrorDialog(Bundle.GitHubRepositoryPanel_addRepositoryButtonAction_error_empty_token());
456459
return;
457460
}
458461
setAddRepositoryButtonEnabled(false);
459462
List<Repository> repositories = GitHubRepository.getRepositories(oAuthToken);
463+
if (repositories.isEmpty()) {
464+
SwingUtilities.invokeLater(new Runnable() {
465+
466+
@Override
467+
public void run() {
468+
UiUtils.showErrorDialog(Bundle.GitHubRepositoryPanel_addRepositoryButtonAction_error_wrong_token());
469+
setAddRepositoryButtonEnabled(true);
470+
}
471+
});
472+
return;
473+
}
474+
460475
final Repository repository = GitHubRepositoryListPanel.showDialog(repositories);
461476

462477
SwingUtilities.invokeLater(new Runnable() {

0 commit comments

Comments
 (0)