import java.util.TreeSet;\r
\r
import org.apache.wicket.PageParameters;\r
+import org.apache.wicket.ajax.AjaxRequestTarget;\r
+import org.apache.wicket.ajax.markup.html.form.AjaxButton;\r
import org.apache.wicket.markup.html.basic.Label;\r
import org.apache.wicket.markup.html.form.Button;\r
import org.apache.wicket.markup.html.form.DropDownChoice;\r
setStatelessHint(false);\r
setOutputMarkupId(true);\r
\r
- Form<Void> form = new Form<Void>("editForm") {\r
-\r
- private static final long serialVersionUID = 1L;\r
-\r
- @Override\r
- protected void onSubmit() {\r
- long ticketId = 0L;\r
- try {\r
- String h = WicketUtils.getObject(getPageParameters());\r
- ticketId = Long.parseLong(h);\r
- } catch (Exception e) {\r
- setResponsePage(TicketsPage.class, WicketUtils.newRepositoryParameter(repositoryName));\r
- }\r
-\r
- TicketModel ticket = app().tickets().getTicket(getRepositoryModel(), ticketId);\r
-\r
- String createdBy = GitBlitWebSession.get().getUsername();\r
- Change change = new Change(createdBy);\r
-\r
- String title = titleModel.getObject();\r
- if (!StringUtils.isEmpty(title) && !ticket.title.equals(title)) {\r
- // title change\r
- change.setField(Field.title, title);\r
- }\r
-\r
- String description = descriptionEditor.getText();\r
- if ((StringUtils.isEmpty(ticket.body) && !StringUtils.isEmpty(description))\r
- || (!StringUtils.isEmpty(ticket.body) && !ticket.body.equals(description))) {\r
- // description change\r
- change.setField(Field.body, description);\r
- }\r
-\r
- Status status = statusModel.getObject();\r
- if (!ticket.status.equals(status)) {\r
- // status change\r
- change.setField(Field.status, status);\r
- }\r
-\r
- Type type = typeModel.getObject();\r
- if (!ticket.type.equals(type)) {\r
- // type change\r
- change.setField(Field.type, type);\r
- }\r
-\r
- String topic = topicModel.getObject();\r
- if ((StringUtils.isEmpty(ticket.topic) && !StringUtils.isEmpty(topic))\r
- || (!StringUtils.isEmpty(topic) && !topic.equals(ticket.topic))) {\r
- // topic change\r
- change.setField(Field.topic, topic);\r
- }\r
-\r
- TicketResponsible responsible = responsibleModel == null ? null : responsibleModel.getObject();\r
- if (responsible != null && !responsible.username.equals(ticket.responsible)) {\r
- // responsible change\r
- change.setField(Field.responsible, responsible.username);\r
- if (!StringUtils.isEmpty(responsible.username)) {\r
- if (!ticket.isWatching(responsible.username)) {\r
- change.watch(responsible.username);\r
- }\r
- }\r
- }\r
-\r
- TicketMilestone milestone = milestoneModel == null ? null : milestoneModel.getObject();\r
- if (milestone != null && !milestone.name.equals(ticket.milestone)) {\r
- // milestone change\r
- if (NIL.equals(milestone.name)) {\r
- change.setField(Field.milestone, "");\r
- } else {\r
- change.setField(Field.milestone, milestone.name);\r
- }\r
- }\r
-\r
- String mergeTo = mergeToModel.getObject();\r
- if ((StringUtils.isEmpty(ticket.mergeTo) && !StringUtils.isEmpty(mergeTo))\r
- || (!StringUtils.isEmpty(mergeTo) && !mergeTo.equals(ticket.mergeTo))) {\r
- // integration branch change\r
- change.setField(Field.mergeTo, mergeTo);\r
- }\r
-\r
- if (change.hasFieldChanges()) {\r
- if (!ticket.isWatching(createdBy)) {\r
- change.watch(createdBy);\r
- }\r
- ticket = app().tickets().updateTicket(getRepositoryModel(), ticket.number, change);\r
- if (ticket != null) {\r
- TicketNotifier notifier = app().tickets().createNotifier();\r
- notifier.sendMailing(ticket);\r
- setResponsePage(TicketsPage.class, WicketUtils.newObjectParameter(getRepositoryModel().name, "" + ticket.number));\r
- } else {\r
- // TODO error\r
- }\r
- } else {\r
- // nothing to change?!\r
- setResponsePage(TicketsPage.class, WicketUtils.newObjectParameter(getRepositoryModel().name, "" + ticket.number));\r
- }\r
- }\r
- };\r
+ Form<Void> form = new Form<Void>("editForm");\r
add(form);\r
\r
List<Type> typeChoices;\r
form.add(new Label("milestone").setVisible(false));\r
form.add(new Label("mergeto").setVisible(false));\r
}\r
- form.add(new Button("update"));\r
+\r
+ form.add(new AjaxButton("update") {\r
+\r
+ private static final long serialVersionUID = 1L;\r
+\r
+ @Override\r
+ protected void onSubmit(AjaxRequestTarget target, Form<?> form) {\r
+ long ticketId = 0L;\r
+ try {\r
+ String h = WicketUtils.getObject(getPageParameters());\r
+ ticketId = Long.parseLong(h);\r
+ } catch (Exception e) {\r
+ setResponsePage(TicketsPage.class, WicketUtils.newRepositoryParameter(repositoryName));\r
+ }\r
+\r
+ TicketModel ticket = app().tickets().getTicket(getRepositoryModel(), ticketId);\r
+\r
+ String createdBy = GitBlitWebSession.get().getUsername();\r
+ Change change = new Change(createdBy);\r
+\r
+ String title = titleModel.getObject();\r
+ if (StringUtils.isEmpty(title)) {\r
+ return;\r
+ }\r
+\r
+ if (!ticket.title.equals(title)) {\r
+ // title change\r
+ change.setField(Field.title, title);\r
+ }\r
+\r
+ String description = descriptionEditor.getText();\r
+ if ((StringUtils.isEmpty(ticket.body) && !StringUtils.isEmpty(description))\r
+ || (!StringUtils.isEmpty(ticket.body) && !ticket.body.equals(description))) {\r
+ // description change\r
+ change.setField(Field.body, description);\r
+ }\r
+\r
+ Status status = statusModel.getObject();\r
+ if (!ticket.status.equals(status)) {\r
+ // status change\r
+ change.setField(Field.status, status);\r
+ }\r
+\r
+ Type type = typeModel.getObject();\r
+ if (!ticket.type.equals(type)) {\r
+ // type change\r
+ change.setField(Field.type, type);\r
+ }\r
+\r
+ String topic = topicModel.getObject();\r
+ if ((StringUtils.isEmpty(ticket.topic) && !StringUtils.isEmpty(topic))\r
+ || (!StringUtils.isEmpty(topic) && !topic.equals(ticket.topic))) {\r
+ // topic change\r
+ change.setField(Field.topic, topic);\r
+ }\r
+\r
+ TicketResponsible responsible = responsibleModel == null ? null : responsibleModel.getObject();\r
+ if (responsible != null && !responsible.username.equals(ticket.responsible)) {\r
+ // responsible change\r
+ change.setField(Field.responsible, responsible.username);\r
+ if (!StringUtils.isEmpty(responsible.username)) {\r
+ if (!ticket.isWatching(responsible.username)) {\r
+ change.watch(responsible.username);\r
+ }\r
+ }\r
+ }\r
+\r
+ TicketMilestone milestone = milestoneModel == null ? null : milestoneModel.getObject();\r
+ if (milestone != null && !milestone.name.equals(ticket.milestone)) {\r
+ // milestone change\r
+ if (NIL.equals(milestone.name)) {\r
+ change.setField(Field.milestone, "");\r
+ } else {\r
+ change.setField(Field.milestone, milestone.name);\r
+ }\r
+ }\r
+\r
+ String mergeTo = mergeToModel.getObject();\r
+ if ((StringUtils.isEmpty(ticket.mergeTo) && !StringUtils.isEmpty(mergeTo))\r
+ || (!StringUtils.isEmpty(mergeTo) && !mergeTo.equals(ticket.mergeTo))) {\r
+ // integration branch change\r
+ change.setField(Field.mergeTo, mergeTo);\r
+ }\r
+\r
+ if (change.hasFieldChanges()) {\r
+ if (!ticket.isWatching(createdBy)) {\r
+ change.watch(createdBy);\r
+ }\r
+ ticket = app().tickets().updateTicket(getRepositoryModel(), ticket.number, change);\r
+ if (ticket != null) {\r
+ TicketNotifier notifier = app().tickets().createNotifier();\r
+ notifier.sendMailing(ticket);\r
+ setResponsePage(TicketsPage.class, WicketUtils.newObjectParameter(getRepositoryModel().name, "" + ticket.number));\r
+ } else {\r
+ // TODO error\r
+ }\r
+ } else {\r
+ // nothing to change?!\r
+ setResponsePage(TicketsPage.class, WicketUtils.newObjectParameter(getRepositoryModel().name, "" + ticket.number));\r
+ }\r
+ }\r
+ });\r
+\r
Button cancel = new Button("cancel") {\r
private static final long serialVersionUID = 1L;\r
\r
import java.util.List;\r
\r
import org.apache.wicket.PageParameters;\r
+import org.apache.wicket.ajax.AjaxRequestTarget;\r
+import org.apache.wicket.ajax.markup.html.form.AjaxButton;\r
import org.apache.wicket.markup.html.basic.Label;\r
import org.apache.wicket.markup.html.form.Button;\r
import org.apache.wicket.markup.html.form.DropDownChoice;\r
setStatelessHint(false);\r
setOutputMarkupId(true);\r
\r
- Form<Void> form = new Form<Void>("editForm") {\r
-\r
- private static final long serialVersionUID = 1L;\r
-\r
- @Override\r
- protected void onSubmit() {\r
- String createdBy = GitBlitWebSession.get().getUsername();\r
- Change change = new Change(createdBy);\r
- change.setField(Field.title, titleModel.getObject());\r
- change.setField(Field.body, descriptionEditor.getText());\r
- String topic = topicModel.getObject();\r
- if (!StringUtils.isEmpty(topic)) {\r
- change.setField(Field.topic, topic);\r
- }\r
-\r
- // type\r
- TicketModel.Type type = TicketModel.Type.defaultType;\r
- if (typeModel.getObject() != null) {\r
- type = typeModel.getObject();\r
- }\r
- change.setField(Field.type, type);\r
-\r
- // responsible\r
- TicketResponsible responsible = responsibleModel == null ? null : responsibleModel.getObject();\r
- if (responsible != null) {\r
- change.setField(Field.responsible, responsible.username);\r
- }\r
-\r
- // milestone\r
- TicketMilestone milestone = milestoneModel == null ? null : milestoneModel.getObject();\r
- if (milestone != null) {\r
- change.setField(Field.milestone, milestone.name);\r
- }\r
-\r
- // integration branch\r
- String mergeTo = mergeToModel.getObject();\r
- if (!StringUtils.isEmpty(mergeTo)) {\r
- change.setField(Field.mergeTo, mergeTo);\r
- }\r
-\r
- TicketModel ticket = app().tickets().createTicket(getRepositoryModel(), 0L, change);\r
- if (ticket != null) {\r
- TicketNotifier notifier = app().tickets().createNotifier();\r
- notifier.sendMailing(ticket);\r
- setResponsePage(TicketsPage.class, WicketUtils.newObjectParameter(getRepositoryModel().name, "" + ticket.number));\r
- } else {\r
- // TODO error\r
- }\r
- }\r
- };\r
+ Form<Void> form = new Form<Void>("editForm");\r
add(form);\r
\r
form.add(new DropDownChoice<TicketModel.Type>("type", typeModel, Arrays.asList(TicketModel.Type.choices())));\r
form.add(new Label("mergeto").setVisible(false));\r
}\r
\r
- form.add(new Button("create"));\r
+ form.add(new AjaxButton("create") {\r
+\r
+ private static final long serialVersionUID = 1L;\r
+\r
+ @Override\r
+ protected void onSubmit(AjaxRequestTarget target, Form<?> form) {\r
+ String title = titleModel.getObject();\r
+ if (StringUtils.isEmpty(title)) {\r
+ return;\r
+ }\r
+\r
+ String createdBy = GitBlitWebSession.get().getUsername();\r
+ Change change = new Change(createdBy);\r
+ change.setField(Field.title, title);\r
+ change.setField(Field.body, descriptionEditor.getText());\r
+ String topic = topicModel.getObject();\r
+ if (!StringUtils.isEmpty(topic)) {\r
+ change.setField(Field.topic, topic);\r
+ }\r
+\r
+ // type\r
+ TicketModel.Type type = TicketModel.Type.defaultType;\r
+ if (typeModel.getObject() != null) {\r
+ type = typeModel.getObject();\r
+ }\r
+ change.setField(Field.type, type);\r
+\r
+ // responsible\r
+ TicketResponsible responsible = responsibleModel == null ? null : responsibleModel.getObject();\r
+ if (responsible != null) {\r
+ change.setField(Field.responsible, responsible.username);\r
+ }\r
+\r
+ // milestone\r
+ TicketMilestone milestone = milestoneModel == null ? null : milestoneModel.getObject();\r
+ if (milestone != null) {\r
+ change.setField(Field.milestone, milestone.name);\r
+ }\r
+\r
+ // integration branch\r
+ String mergeTo = mergeToModel.getObject();\r
+ if (!StringUtils.isEmpty(mergeTo)) {\r
+ change.setField(Field.mergeTo, mergeTo);\r
+ }\r
+\r
+ TicketModel ticket = app().tickets().createTicket(getRepositoryModel(), 0L, change);\r
+ if (ticket != null) {\r
+ TicketNotifier notifier = app().tickets().createNotifier();\r
+ notifier.sendMailing(ticket);\r
+ setResponsePage(TicketsPage.class, WicketUtils.newObjectParameter(getRepositoryModel().name, "" + ticket.number));\r
+ } else {\r
+ // TODO error\r
+ }\r
+ }\r
+ });\r
+\r
Button cancel = new Button("cancel") {\r
private static final long serialVersionUID = 1L;\r
\r