fs.add(new MaxLengthTextArea(TextAreaPanel.WICKET_ID, new PropertyModel<String>(data, "message")));
}
{
// Actions
final FieldsetPanel fs = gridBuilder.newFieldset(getString("meb.actions")).suppressLabelForWarning();
fs.add(new SingleButtonPanel(fs.newChildId(), new Button(SingleButtonPanel.WICKET_ID, new Model<String>("createTimesheet")) {
@Override
public final void onSubmit()
{
parentPage.createTimesheet();
}
}, getString("timesheet.title.add"), SingleButtonPanel.NORMAL));
// DropDownChoice favorites
jiraProjectChoice = new FavoritesChoicePanel<JiraProject, JiraProject>(fs.newChildId(), UserPrefArea.JIRA_PROJECT) {
@Override
protected void select(final JiraProject favorite)
{
if (StringUtils.isNotEmpty(this.selected) == true) {
parentPage.putUserPrefEntry(USER_PREF_KEY_JIRA_PROJECT, this.selected, true);
}
}
@Override
protected JiraProject getCurrentObject()
{
return null;
}
@Override
protected JiraProject newFavoriteInstance(final JiraProject currentObject)
{
return new JiraProject();
}
};
jiraProjectChoice.setClearSelectionAfterSelection(false).setNullKey("jira.chooseProject");
fs.add(jiraProjectChoice);
final DropDownChoice<String> choice = jiraProjectChoice.init();
choice.setNullValid(false);
List<JiraIssueType> issueTypes;
if (jiraConfig != null && jiraConfig.getIssueTypes() != null) {
issueTypes = jiraConfig.getIssueTypes();
} else {
issueTypes = new ArrayList<JiraIssueType>();
}
// DropDownChoice issueType
final LabelValueChoiceRenderer<JiraIssueType> typeChoiceRenderer = new LabelValueChoiceRenderer<JiraIssueType>(issueTypes);
@SuppressWarnings({ "rawtypes", "unchecked"})
final DropDownChoice typeChoice = new DropDownChoice(fs.getDropDownChoiceId(), new PropertyModel(this, "jiraIssueType"),
typeChoiceRenderer.getValues(), typeChoiceRenderer) {
@Override
protected boolean wantOnSelectionChangedNotifications()
{
return true;
}
@Override
protected void onSelectionChanged(final Object newSelection)
{
if (newSelection != null && newSelection instanceof Integer) {
parentPage.putUserPrefEntry(USER_PREF_KEY_JIRA_ISSUE_TYPE, newSelection, true);
// refresh();
}
}
};
final Integer recentJiraIssueType = (Integer) parentPage.getUserPrefEntry(Integer.class, USER_PREF_KEY_JIRA_ISSUE_TYPE);
if (recentJiraIssueType != null) {
this.jiraIssueType = recentJiraIssueType;
}
typeChoice.setNullValid(false);
fs.add(typeChoice);
final AjaxButton createJiraIssueButton = new AjaxButton(SingleButtonPanel.WICKET_ID, new Model<String>("createJIRAIssue")) {
@Override
public void onSubmit(final AjaxRequestTarget target, final Form< ? > form)
{
// ...create result page, get the url path to it...
target.appendJavaScript("window.open('" + buildCreateJiraIssueUrl() + "','newWindow');");
}
/**
* @see org.apache.wicket.ajax.markup.html.form.AjaxButton#onError(org.apache.wicket.ajax.AjaxRequestTarget,
* org.apache.wicket.markup.html.form.Form)
*/
@Override
protected void onError(final AjaxRequestTarget target, final Form< ? > form)
{
}
};
WicketUtils.addTooltip(createJiraIssueButton, getString("tooltip.popups.mustBeAllowed"));
fs.add(new SingleButtonPanel(fs.newChildId(), createJiraIssueButton, getString("meb.actions.createJIRAIssue"), SingleButtonPanel.NORMAL));
if (jiraConfig == null || StringUtils.isEmpty(jiraConfig.getCreateIssueUrl()) == true) {
jiraProjectChoice.setVisible(false);
typeChoice.setVisible(false);
// jiraCreateIssueLink.setVisible(false);
createJiraIssueButton.setVisible(false);