Skip to content

Commit ded305a

Browse files
committed
Add an assignYourselfLinkButton #19
1 parent 2f58a59 commit ded305a

3 files changed

Lines changed: 65 additions & 22 deletions

File tree

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

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -254,21 +254,23 @@
254254
<Component id="descriptionTabbedPanel" pref="512" max="32767" attributes="0"/>
255255
<Component id="titleTextField" max="32767" attributes="0"/>
256256
</Group>
257-
<EmptySpace min="-2" max="-2" attributes="0"/>
257+
<EmptySpace max="-2" attributes="0"/>
258258
<Group type="103" groupAlignment="0" max="-2" attributes="0">
259259
<Component id="labelsLabel" min="-2" max="-2" attributes="0"/>
260+
<Component id="labelsScrollPane" alignment="0" max="32767" attributes="0"/>
260261
<Group type="102" alignment="0" attributes="0">
262+
<Component id="assigneeLabel" min="-2" max="-2" attributes="0"/>
263+
<EmptySpace min="-2" pref="19" max="-2" attributes="0"/>
261264
<Group type="103" groupAlignment="0" attributes="0">
262-
<Component id="milestoneLabel" min="-2" max="-2" attributes="0"/>
263-
<Component id="assigneeLabel" min="-2" max="-2" attributes="0"/>
264-
</Group>
265-
<EmptySpace max="-2" attributes="0"/>
266-
<Group type="103" groupAlignment="0" max="-2" attributes="0">
267-
<Component id="milestoneComboBox" pref="173" max="32767" attributes="0"/>
268-
<Component id="assigneeComboBox" max="32767" attributes="0"/>
265+
<Component id="assignYourselfLinkButton" min="-2" max="-2" attributes="0"/>
266+
<Component id="assigneeComboBox" min="-2" pref="173" max="-2" attributes="0"/>
269267
</Group>
270268
</Group>
271-
<Component id="labelsScrollPane" alignment="0" max="32767" attributes="0"/>
269+
<Group type="102" alignment="0" attributes="0">
270+
<Component id="milestoneLabel" min="-2" max="-2" attributes="0"/>
271+
<EmptySpace max="32767" attributes="0"/>
272+
<Component id="milestoneComboBox" min="-2" pref="173" max="-2" attributes="0"/>
273+
</Group>
272274
</Group>
273275
</Group>
274276
<Group type="102" alignment="0" attributes="0">
@@ -300,16 +302,18 @@
300302
<Component id="titleLabel" alignment="3" min="-2" max="-2" attributes="0"/>
301303
</Group>
302304
<EmptySpace max="-2" attributes="0"/>
303-
<Group type="103" groupAlignment="1" attributes="0">
304-
<Group type="102" alignment="1" attributes="0">
305+
<Group type="103" groupAlignment="1" max="-2" attributes="0">
306+
<Group type="102" alignment="0" attributes="0">
307+
<Component id="assignYourselfLinkButton" min="-2" max="-2" attributes="0"/>
308+
<EmptySpace min="-2" pref="10" max="-2" attributes="0"/>
305309
<Group type="103" groupAlignment="3" attributes="0">
306310
<Component id="milestoneLabel" alignment="3" min="-2" max="-2" attributes="0"/>
307311
<Component id="milestoneComboBox" alignment="3" min="-2" max="-2" attributes="0"/>
308312
</Group>
309313
<EmptySpace max="-2" attributes="0"/>
310314
<Component id="labelsLabel" min="-2" max="-2" attributes="0"/>
311315
<EmptySpace max="-2" attributes="0"/>
312-
<Component id="labelsScrollPane" min="-2" pref="244" max="-2" attributes="0"/>
316+
<Component id="labelsScrollPane" max="32767" attributes="0"/>
313317
</Group>
314318
<Group type="102" attributes="0">
315319
<Component id="descriptionLabel" min="-2" max="-2" attributes="0"/>
@@ -449,6 +453,16 @@
449453

450454
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
451455
</Container>
456+
<Component class="org.netbeans.modules.bugtracking.commons.LinkButton" name="assignYourselfLinkButton">
457+
<Properties>
458+
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
459+
<ResourceString bundle="com/junichi11/netbeans/modules/github/issues/issue/ui/Bundle.properties" key="GitHubIssuePanel.assignYourselfLinkButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
460+
</Property>
461+
</Properties>
462+
<Events>
463+
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="assignYourselfLinkButtonActionPerformed"/>
464+
</Events>
465+
</Component>
452466
</SubComponents>
453467
</Container>
454468
</SubComponents>

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

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
import java.util.Collections;
6565
import java.util.Enumeration;
6666
import java.util.List;
67+
import java.util.logging.Level;
6768
import java.util.logging.Logger;
6869
import javax.swing.DefaultComboBoxModel;
6970
import javax.swing.DefaultListModel;
@@ -580,6 +581,7 @@ private void initComponents() {
580581
newCommentCloseReopenIssueButton = new javax.swing.JButton();
581582
attributesViewPanel = new com.junichi11.netbeans.modules.github.issues.issue.ui.AttributesViewPanel();
582583
mainCommetnsPanel = new javax.swing.JPanel();
584+
assignYourselfLinkButton = new org.netbeans.modules.bugtracking.commons.LinkButton();
583585

584586
org.openide.awt.Mnemonics.setLocalizedText(headerSubmitButton, org.openide.util.NbBundle.getMessage(GitHubIssuePanel.class, "GitHubIssuePanel.headerSubmitButton.text")); // NOI18N
585587

@@ -722,6 +724,13 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
722724

723725
mainCommetnsPanel.setLayout(new java.awt.BorderLayout());
724726

727+
org.openide.awt.Mnemonics.setLocalizedText(assignYourselfLinkButton, org.openide.util.NbBundle.getMessage(GitHubIssuePanel.class, "GitHubIssuePanel.assignYourselfLinkButton.text")); // NOI18N
728+
assignYourselfLinkButton.addActionListener(new java.awt.event.ActionListener() {
729+
public void actionPerformed(java.awt.event.ActionEvent evt) {
730+
assignYourselfLinkButtonActionPerformed(evt);
731+
}
732+
});
733+
725734
javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);
726735
mainPanel.setLayout(mainPanelLayout);
727736
mainPanelLayout.setHorizontalGroup(
@@ -740,15 +749,17 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
740749
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
741750
.addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
742751
.addComponent(labelsLabel)
752+
.addComponent(labelsScrollPane)
743753
.addGroup(mainPanelLayout.createSequentialGroup()
754+
.addComponent(assigneeLabel)
755+
.addGap(19, 19, 19)
744756
.addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
745-
.addComponent(milestoneLabel)
746-
.addComponent(assigneeLabel))
747-
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
748-
.addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
749-
.addComponent(milestoneComboBox, 0, 173, Short.MAX_VALUE)
750-
.addComponent(assigneeComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
751-
.addComponent(labelsScrollPane)))
757+
.addComponent(assignYourselfLinkButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
758+
.addComponent(assigneeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 173, javax.swing.GroupLayout.PREFERRED_SIZE)))
759+
.addGroup(mainPanelLayout.createSequentialGroup()
760+
.addComponent(milestoneLabel)
761+
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
762+
.addComponent(milestoneComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 173, javax.swing.GroupLayout.PREFERRED_SIZE))))
752763
.addGroup(mainPanelLayout.createSequentialGroup()
753764
.addComponent(newCommentLabel)
754765
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
@@ -772,15 +783,17 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
772783
.addComponent(assigneeLabel)
773784
.addComponent(titleLabel))
774785
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
775-
.addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
776-
.addGroup(mainPanelLayout.createSequentialGroup()
786+
.addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
787+
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, mainPanelLayout.createSequentialGroup()
788+
.addComponent(assignYourselfLinkButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
789+
.addGap(10, 10, 10)
777790
.addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
778791
.addComponent(milestoneLabel)
779792
.addComponent(milestoneComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
780793
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
781794
.addComponent(labelsLabel)
782795
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
783-
.addComponent(labelsScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 244, javax.swing.GroupLayout.PREFERRED_SIZE))
796+
.addComponent(labelsScrollPane))
784797
.addGroup(mainPanelLayout.createSequentialGroup()
785798
.addComponent(descriptionLabel)
786799
.addGap(271, 271, 271))
@@ -903,7 +916,22 @@ private void newMilestoneButtonActionPerformed(java.awt.event.ActionEvent evt) {
903916
}
904917
}//GEN-LAST:event_newMilestoneButtonActionPerformed
905918

919+
private void assignYourselfLinkButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_assignYourselfLinkButtonActionPerformed
920+
GitHubRepository repository = getRepository();
921+
if (repository == null) {
922+
return;
923+
}
924+
GitHubCache cache = GitHubCache.create(repository);
925+
User myself = cache.getMySelf();
926+
if (myself == null) {
927+
LOGGER.log(Level.WARNING, "{0} : Can't get myself.", repository.getFullName()); // NOI18N
928+
return;
929+
}
930+
setAssigneeSelected(myself);
931+
}//GEN-LAST:event_assignYourselfLinkButtonActionPerformed
932+
906933
// Variables declaration - do not modify//GEN-BEGIN:variables
934+
private org.netbeans.modules.bugtracking.commons.LinkButton assignYourselfLinkButton;
907935
private javax.swing.JComboBox<User> assigneeComboBox;
908936
private javax.swing.JLabel assigneeLabel;
909937
private com.junichi11.netbeans.modules.github.issues.issue.ui.AttributesViewPanel attributesViewPanel;

src/main/resources/com/junichi11/netbeans/modules/github/issues/issue/ui/Bundle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,4 @@ GitHubIssuePanel.newMilestoneButton.text=New Milestone
4949
MilestonePanel.errorLabel.text=ERROR
5050
GitHubIssuePanel.newLabelButton.text=New Label
5151
CommentPanel.previewLinkButton.text=HTML
52+
GitHubIssuePanel.assignYourselfLinkButton.text=Assign yourself

0 commit comments

Comments
 (0)