Skip to content

Commit b03cac1

Browse files
committed
Merge branch 'nb80'
2 parents f6b1c50 + f95b325 commit b03cac1

15 files changed

Lines changed: 358 additions & 49 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
target/
2+
nbproject/private/
3+
nbactions-netbeans-ide.xml

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ This plugin provides support for GitHub Issue Tracker.
1212
- Search issues with issue number or keywords
1313
- Create a new label
1414
- Create a new milestone
15-
- Set a schedule for an issue
15+
- Add issues to schedule categories
1616

1717
## Usage
1818

@@ -25,6 +25,10 @@ This plugin provides support for GitHub Issue Tracker.
2525
5. Click Connect button (If you can't connect a repository, please try to check input values)
2626
6. Click OK button
2727

28+
### Schedules
29+
30+
If an issue has a milestone and it has a due date, the issue is added to schedule category.
31+
2832
## Default queries
2933

3034
1. Open

pom.xml

Lines changed: 1 addition & 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.6-SNAPSHOT</version>
6+
<version>0.1.0</version>
77
<packaging>nbm</packaging>
88
<build>
99
<plugins>

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

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,19 @@
4242
package com.junichi11.netbeans.modules.github.issues;
4343

4444
import com.junichi11.netbeans.modules.github.issues.repository.GitHubRepository;
45+
import java.awt.Image;
46+
import java.awt.image.BufferedImage;
4547
import java.io.IOException;
48+
import java.net.URL;
4649
import java.util.Collections;
4750
import java.util.HashMap;
4851
import java.util.List;
4952
import java.util.Map;
5053
import java.util.logging.Level;
5154
import java.util.logging.Logger;
55+
import javax.imageio.ImageIO;
56+
import javax.swing.Icon;
57+
import javax.swing.ImageIcon;
5258
import org.eclipse.egit.github.core.Label;
5359
import org.eclipse.egit.github.core.Milestone;
5460
import org.eclipse.egit.github.core.Repository;
@@ -58,6 +64,7 @@
5864
import org.eclipse.egit.github.core.service.LabelService;
5965
import org.eclipse.egit.github.core.service.MilestoneService;
6066
import org.eclipse.egit.github.core.service.UserService;
67+
import org.netbeans.api.annotations.common.CheckForNull;
6168
import org.netbeans.api.annotations.common.NonNull;
6269

6370
/**
@@ -71,6 +78,7 @@ public final class GitHubCache {
7178
private List<Milestone> milestones;
7279
private List<Label> labels;
7380
private User myself;
81+
private final Map<String, Icon> userIcons = new HashMap<>();
7482
private final GitHubRepository repository;
7583
private static final Logger LOGGER = Logger.getLogger(GitHubCache.class.getName());
7684

@@ -218,4 +226,43 @@ public User getMySelf() {
218226
return myself;
219227
}
220228

229+
/**
230+
* Get user icon. Icon size is 16x16.
231+
*
232+
* @param user User
233+
* @return user icon if it was got, otherwise {@code null}
234+
*/
235+
@CheckForNull
236+
public Icon getUserIcon(User user) {
237+
if (user == null) {
238+
return null;
239+
}
240+
String login = user.getLogin();
241+
Icon icon = userIcons.get(login);
242+
if (icon != null) {
243+
return icon;
244+
}
245+
GitHubClient client = repository.createGitHubClient();
246+
if (client == null) {
247+
return null;
248+
}
249+
UserService userService = new UserService(client);
250+
try {
251+
user = userService.getUser(login);
252+
String avatarUrl = user.getAvatarUrl();
253+
if (avatarUrl != null && !avatarUrl.isEmpty()) {
254+
URL url = new URL(avatarUrl);
255+
// resize to 16x16
256+
BufferedImage image = ImageIO.read(url);
257+
Image resizedImage = image.getScaledInstance(16, 16, Image.SCALE_SMOOTH);
258+
icon = new ImageIcon(resizedImage);
259+
userIcons.put(login, icon);
260+
return icon;
261+
}
262+
} catch (IOException ex) {
263+
LOGGER.log(Level.WARNING, ex.getMessage());
264+
}
265+
return null;
266+
}
267+
221268
}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,10 @@ public class GitHubIssueController implements IssueController, ChangeListener, P
7474

7575
private GitHubIssuePanel panel;
7676
private String errorMessage;
77+
private final String repositoryId;
7778

7879
public GitHubIssueController(GitHubIssue gitHubIssue) {
80+
repositoryId = gitHubIssue.getRepository().getID();
7981
getPanel().setIssue(gitHubIssue);
8082
getPanel().update();
8183
}
@@ -125,7 +127,7 @@ public void removePropertyChangeListener(PropertyChangeListener listener) {
125127

126128
private GitHubIssuePanel getPanel() {
127129
if (panel == null) {
128-
panel = new GitHubIssuePanel();
130+
panel = new GitHubIssuePanel(repositoryId);
129131
panel.addChangeListener(this);
130132
panel.addAction(getSubmitIssueAction());
131133
panel.addAction(getCommentAction());

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
*/
4242
package com.junichi11.netbeans.modules.github.issues.issue.ui;
4343

44+
import com.junichi11.netbeans.modules.github.issues.GitHubCache;
45+
import com.junichi11.netbeans.modules.github.issues.repository.GitHubRepository;
4446
import com.junichi11.netbeans.modules.github.issues.utils.DateUtils;
4547
import java.awt.Color;
4648
import java.awt.Font;
@@ -76,7 +78,7 @@ public AttributesViewPanel() {
7678
@NbBundle.Messages({
7779
"AttributesViewPanel.LBL.dueDate=Due date"
7880
})
79-
public void setAttributes(Issue issue) {
81+
public void setAttributes(Issue issue, GitHubRepository repository) {
8082
initAttributes();
8183
if (issue == null) {
8284
return;
@@ -88,6 +90,10 @@ public void setAttributes(Issue issue) {
8890
String login = assignee.getLogin();
8991
assigneeNameLabel.setText(login);
9092
assigneeNameLabel.setToolTipText(login);
93+
if (repository != null) {
94+
GitHubCache cache = GitHubCache.create(repository);
95+
assigneeNameLabel.setIcon(cache.getUserIcon(assignee));
96+
}
9197
}
9298

9399
// milestone

src/main/java/com/junichi11/netbeans/modules/github/issues/issue/ui/CommentPanel.form

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<Component id="contentTextPane" max="32767" attributes="0"/>
2323
<Group type="102" alignment="0" attributes="0">
2424
<Component id="userLinkButton" min="-2" max="-2" attributes="0"/>
25-
<EmptySpace pref="56" max="32767" attributes="0"/>
25+
<EmptySpace pref="66" max="32767" attributes="0"/>
2626
<Component id="createdLabel" min="-2" max="-2" attributes="0"/>
2727
<EmptySpace max="-2" attributes="0"/>
2828
<Component id="createdDateLabel" min="-2" max="-2" attributes="0"/>
@@ -31,6 +31,8 @@
3131
<EmptySpace max="-2" attributes="0"/>
3232
<Component id="updatedDateLabel" min="-2" max="-2" attributes="0"/>
3333
<EmptySpace max="-2" attributes="0"/>
34+
<Component id="previewLinkButton" min="-2" max="-2" attributes="0"/>
35+
<EmptySpace max="-2" attributes="0"/>
3436
<Component id="quoteLinkButton" min="-2" max="-2" attributes="0"/>
3537
<EmptySpace max="-2" attributes="0"/>
3638
<Component id="editLinkButton" min="-2" max="-2" attributes="0"/>
@@ -56,6 +58,7 @@
5658
<Component id="editLinkButton" alignment="3" min="-2" max="-2" attributes="0"/>
5759
<Component id="quoteLinkButton" alignment="3" min="-2" max="-2" attributes="0"/>
5860
<Component id="deleteLinkButton" alignment="3" min="-2" max="-2" attributes="0"/>
61+
<Component id="previewLinkButton" alignment="3" min="-2" max="-2" attributes="0"/>
5962
</Group>
6063
<EmptySpace min="-2" max="-2" attributes="0"/>
6164
<Component id="jSeparator1" min="-2" max="-2" attributes="0"/>
@@ -122,7 +125,6 @@
122125
<EmptyBorder bottom="3" left="5" right="5" top="3"/>
123126
</Border>
124127
</Property>
125-
<Property name="contentType" type="java.lang.String" value="text/html" noResource="true"/>
126128
</Properties>
127129
</Component>
128130
<Component class="org.netbeans.modules.bugtracking.commons.LinkButton" name="quoteLinkButton">
@@ -145,5 +147,15 @@
145147
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="deleteLinkButtonActionPerformed"/>
146148
</Events>
147149
</Component>
150+
<Component class="org.netbeans.modules.bugtracking.commons.LinkButton" name="previewLinkButton">
151+
<Properties>
152+
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
153+
<ResourceString bundle="com/junichi11/netbeans/modules/github/issues/issue/ui/Bundle.properties" key="CommentPanel.previewLinkButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
154+
</Property>
155+
</Properties>
156+
<Events>
157+
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="previewLinkButtonActionPerformed"/>
158+
</Events>
159+
</Component>
148160
</SubComponents>
149161
</Form>

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

Lines changed: 58 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@
4343

4444
import com.junichi11.netbeans.modules.github.issues.utils.DateUtils;
4545
import com.junichi11.netbeans.modules.github.issues.utils.UiUtils;
46+
import java.awt.Font;
4647
import java.util.Date;
48+
import javax.swing.Icon;
4749
import org.eclipse.egit.github.core.Comment;
4850
import org.openide.util.NbBundle;
4951

@@ -54,6 +56,8 @@
5456
public class CommentPanel extends javax.swing.JPanel {
5557

5658
private static final long serialVersionUID = -1191208334240462498L;
59+
private static final String HTML_MIME_TYPE = "text/html"; // NOI18N
60+
private static final String PLAIN_MIME_TYPE = "text/plain"; // NOI18N
5761

5862
private Comment comment;
5963
private boolean isQuote;
@@ -67,25 +71,39 @@ private CommentPanel() {
6771
initComponents();
6872
}
6973

70-
public CommentPanel(Comment comment) {
74+
public CommentPanel(Comment comment, Icon icon) {
7175
this.comment = comment;
7276
initComponents();
73-
load();
77+
init();
78+
load(icon);
7479
}
7580

76-
final void load() {
81+
private void init() {
82+
// set monospaced font
83+
Font contentFont = contentTextPane.getFont();
84+
contentTextPane.setFont(new Font(Font.MONOSPACED, contentFont.getStyle(), contentFont.getSize()));
85+
86+
previewLinkButton.setText(Bundle.CommentPanel_previewLinkButton_title_html());
87+
}
88+
89+
final void load(Icon icon) {
7790
if (comment != null) {
7891
setUserName(comment.getUser().getLogin());
92+
setUserIcon(icon);
7993
setCreatedDate(comment.getCreatedAt());
8094
setUpdatedDate(comment.getUpdatedAt());
81-
setContent(comment.getBodyHtml());
95+
setContent(comment.getBody());
8296
}
8397
}
8498

8599
private void setUserName(String name) {
86100
userLinkButton.setText(name);
87101
}
88102

103+
private void setUserIcon(Icon icon) {
104+
userLinkButton.setIcon(icon);
105+
}
106+
89107
private void setCreatedDate(Date date) {
90108
if (date != null) {
91109
createdDateLabel.setText(DateUtils.DEFAULT_DATE_TIME_FORMAT.format(date));
@@ -165,6 +183,7 @@ private void initComponents() {
165183
contentTextPane = new javax.swing.JTextPane();
166184
quoteLinkButton = new org.netbeans.modules.bugtracking.commons.LinkButton();
167185
deleteLinkButton = new org.netbeans.modules.bugtracking.commons.LinkButton();
186+
previewLinkButton = new org.netbeans.modules.bugtracking.commons.LinkButton();
168187

169188
org.openide.awt.Mnemonics.setLocalizedText(createdLabel, org.openide.util.NbBundle.getMessage(CommentPanel.class, "CommentPanel.createdLabel.text")); // NOI18N
170189

@@ -185,7 +204,6 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
185204

186205
contentTextPane.setEditable(false);
187206
contentTextPane.setBorder(javax.swing.BorderFactory.createEmptyBorder(3, 5, 3, 5));
188-
contentTextPane.setContentType("text/html"); // NOI18N
189207

190208
org.openide.awt.Mnemonics.setLocalizedText(quoteLinkButton, org.openide.util.NbBundle.getMessage(CommentPanel.class, "CommentPanel.quoteLinkButton.text")); // NOI18N
191209
quoteLinkButton.addActionListener(new java.awt.event.ActionListener() {
@@ -201,6 +219,13 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
201219
}
202220
});
203221

222+
org.openide.awt.Mnemonics.setLocalizedText(previewLinkButton, org.openide.util.NbBundle.getMessage(CommentPanel.class, "CommentPanel.previewLinkButton.text")); // NOI18N
223+
previewLinkButton.addActionListener(new java.awt.event.ActionListener() {
224+
public void actionPerformed(java.awt.event.ActionEvent evt) {
225+
previewLinkButtonActionPerformed(evt);
226+
}
227+
});
228+
204229
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
205230
this.setLayout(layout);
206231
layout.setHorizontalGroup(
@@ -211,7 +236,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
211236
.addComponent(contentTextPane)
212237
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
213238
.addComponent(userLinkButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
214-
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 56, Short.MAX_VALUE)
239+
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 66, Short.MAX_VALUE)
215240
.addComponent(createdLabel)
216241
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
217242
.addComponent(createdDateLabel)
@@ -220,6 +245,8 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
220245
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
221246
.addComponent(updatedDateLabel)
222247
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
248+
.addComponent(previewLinkButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
249+
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
223250
.addComponent(quoteLinkButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
224251
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
225252
.addComponent(editLinkButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
@@ -240,7 +267,8 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
240267
.addComponent(userLinkButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
241268
.addComponent(editLinkButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
242269
.addComponent(quoteLinkButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
243-
.addComponent(deleteLinkButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
270+
.addComponent(deleteLinkButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
271+
.addComponent(previewLinkButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
244272
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
245273
.addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
246274
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
@@ -270,13 +298,36 @@ private void editLinkButtonActionPerformed(java.awt.event.ActionEvent evt) {//GE
270298
firePropertyChange(CommentsPanel.PROP_COMMENT_EDITED, null, null);
271299
}//GEN-LAST:event_editLinkButtonActionPerformed
272300

301+
@NbBundle.Messages({
302+
"CommentPanel.previewLinkButton.title.html=HTML",
303+
"CommentPanel.previewLinkButton.title.plain=Plain"
304+
})
305+
private void previewLinkButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_previewLinkButtonActionPerformed
306+
String text = previewLinkButton.getText();
307+
if (text.equals(Bundle.CommentPanel_previewLinkButton_title_html())) {
308+
previewLinkButton.setText(Bundle.CommentPanel_previewLinkButton_title_plain());
309+
} else {
310+
previewLinkButton.setText(Bundle.CommentPanel_previewLinkButton_title_html());
311+
}
312+
313+
String contentType = contentTextPane.getContentType();
314+
if (contentType.equals(HTML_MIME_TYPE)) {
315+
contentTextPane.setContentType(PLAIN_MIME_TYPE);
316+
contentTextPane.setText(comment.getBody());
317+
return;
318+
}
319+
contentTextPane.setContentType(HTML_MIME_TYPE);
320+
contentTextPane.setText(comment.getBodyHtml());
321+
}//GEN-LAST:event_previewLinkButtonActionPerformed
322+
273323
// Variables declaration - do not modify//GEN-BEGIN:variables
274324
private javax.swing.JTextPane contentTextPane;
275325
private javax.swing.JLabel createdDateLabel;
276326
private javax.swing.JLabel createdLabel;
277327
private org.netbeans.modules.bugtracking.commons.LinkButton deleteLinkButton;
278328
private org.netbeans.modules.bugtracking.commons.LinkButton editLinkButton;
279329
private javax.swing.JSeparator jSeparator1;
330+
private org.netbeans.modules.bugtracking.commons.LinkButton previewLinkButton;
280331
private org.netbeans.modules.bugtracking.commons.LinkButton quoteLinkButton;
281332
private javax.swing.JLabel updatedDateLabel;
282333
private javax.swing.JLabel updatedLabel;

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import com.junichi11.netbeans.modules.github.issues.GitHubIssues;
4545
import java.awt.Component;
4646
import java.awt.Dialog;
47+
import java.awt.Font;
4748
import org.openide.DialogDescriptor;
4849
import org.openide.DialogDisplayer;
4950
import org.pegdown.PegDownProcessor;
@@ -61,6 +62,13 @@ public class CommentTabbedPanel extends javax.swing.JPanel {
6162
*/
6263
public CommentTabbedPanel() {
6364
initComponents();
65+
init();
66+
}
67+
68+
private void init() {
69+
// set monospaced font
70+
Font commentFont = commentWriteTextArea.getFont();
71+
commentWriteTextArea.setFont(new Font(Font.MONOSPACED, commentFont.getStyle(), commentFont.getSize()));
6472
}
6573

6674
public String getText() {

0 commit comments

Comments
 (0)