use of org.projectforge.web.task.TaskSelectPanel in project projectforge by micromata.
the class ToDoEditForm method init.
@SuppressWarnings("serial")
@Override
protected void init() {
super.init();
gridBuilder.newGridPanel();
if (isNew()) {
// Favorites
final String[] templateNames = userPrefDao.getPrefNames(ToDoPlugin.USER_PREF_AREA);
if (templateNames != null && templateNames.length > 0) {
// DropDownChoice templates
final FieldsetPanel fs = gridBuilder.newFieldset(getString("templates"));
final LabelValueChoiceRenderer<String> templateNamesChoiceRenderer = new LabelValueChoiceRenderer<>();
templateNamesChoiceRenderer.addValue("", getString("userPref.template.select"));
for (final String name : templateNames) {
templateNamesChoiceRenderer.addValue(name, name);
}
final DropDownChoice<String> templateNamesChoice = new DropDownChoice<String>(fs.getDropDownChoiceId(), new PropertyModel<>(this, "templateName"), templateNamesChoiceRenderer.getValues(), templateNamesChoiceRenderer) {
@Override
protected boolean wantOnSelectionChangedNotifications() {
return true;
}
@Override
protected CharSequence getDefaultChoice(final String selected) {
return "";
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
protected void onSelectionChanged(final String newSelection) {
if (StringUtils.isNotEmpty(newSelection)) {
// Fill fields with selected template values:
final UserPrefDO userPref = userPrefDao.getUserPref(ToDoPlugin.USER_PREF_AREA, newSelection);
if (userPref != null) {
userPrefDao.fillFromUserPrefParameters(userPref, data);
}
templateName = "";
// Mark all form components as model changed.
visitFormComponents(new IVisitor() {
@Override
public void component(final Object object, final IVisit visit) {
final FormComponent<?> fc = (FormComponent<?>) object;
fc.modelChanged();
visit.dontGoDeeper();
}
});
}
}
};
templateNamesChoice.setNullValid(true);
fs.add(templateNamesChoice);
}
}
{
// Subject
final FieldsetPanel fs = gridBuilder.newFieldset(ToDoDO.class, "subject");
final RequiredMaxLengthTextField subject = new RequiredMaxLengthTextField(fs.getTextFieldId(), new PropertyModel<>(data, "subject"));
if (isNew()) {
// Only focus for new to-do's:
subject.add(WicketUtils.setFocus());
}
fs.add(subject);
}
gridBuilder.newSplitPanel(GridSize.COL50);
{
// ToDo type
final FieldsetPanel fs = gridBuilder.newFieldset(ToDoDO.class, "type");
final LabelValueChoiceRenderer<ToDoType> typeChoiceRenderer = new LabelValueChoiceRenderer<>(this, ToDoType.values());
fs.addDropDownChoice(new PropertyModel<>(data, "type"), typeChoiceRenderer.getValues(), typeChoiceRenderer).setNullValid(true);
}
{
// Status
final FieldsetPanel fs = gridBuilder.newFieldset(ToDoDO.class, "status");
final LabelValueChoiceRenderer<ToDoStatus> statusChoiceRenderer = new LabelValueChoiceRenderer<>(this, ToDoStatus.values());
fs.addDropDownChoice(new PropertyModel<>(data, "status"), statusChoiceRenderer.getValues(), statusChoiceRenderer).setNullValid(true);
}
{
// Due date
final FieldProperties<LocalDate> props = getDueDateProperties();
final FieldsetPanel fs = gridBuilder.newFieldset(ToDoDO.class, "dueDate");
fs.add(new LocalDatePanel(fs.newChildId(), new LocalDateModel(props.getModel())));
}
gridBuilder.newSplitPanel(GridSize.COL50);
{
// Priority
final FieldsetPanel fs = gridBuilder.newFieldset(ToDoDO.class, "priority");
final LabelValueChoiceRenderer<Priority> priorityChoiceRenderer = new LabelValueChoiceRenderer<>(this, Priority.values());
fs.addDropDownChoice(new PropertyModel<>(data, "priority"), priorityChoiceRenderer.getValues(), priorityChoiceRenderer).setNullValid(true);
}
{
// Assignee
final FieldsetPanel fs = gridBuilder.newFieldset(ToDoDO.class, "assignee");
PFUserDO assignee = data.getAssignee();
if (!Hibernate.isInitialized(assignee)) {
assignee = UserGroupCache.getInstance().getUser(assignee.getId());
data.setAssignee(assignee);
}
final UserSelectPanel assigneeUserSelectPanel = new UserSelectPanel(fs.newChildId(), new PropertyModel<>(data, "assignee"), parentPage, "assigneeId");
fs.add(assigneeUserSelectPanel);
assigneeUserSelectPanel.setRequired(true);
assigneeUserSelectPanel.init();
}
{
// Reporter
final FieldsetPanel fs = gridBuilder.newFieldset(ToDoDO.class, "reporter");
PFUserDO reporter = data.getReporter();
if (!Hibernate.isInitialized(reporter)) {
reporter = UserGroupCache.getInstance().getUser(reporter.getId());
data.setReporter(reporter);
}
final UserSelectPanel reporterUserSelectPanel = new UserSelectPanel(fs.newChildId(), new PropertyModel<>(data, "reporter"), parentPage, "reporterId");
fs.add(reporterUserSelectPanel);
reporterUserSelectPanel.init();
}
gridBuilder.newGridPanel();
{
// Task
final FieldsetPanel fs = gridBuilder.newFieldset(ToDoDO.class, "task");
final TaskSelectPanel taskSelectPanel = new TaskSelectPanel(fs, new PropertyModel<>(data, "task"), parentPage, "taskId");
fs.add(taskSelectPanel);
taskSelectPanel.init();
fs.addHelpIcon(new ResourceModel("plugins.todo.task.tooltip.title"), new ResourceModel("plugins.todo.task.tooltip.content"));
}
{
// Group
final FieldsetPanel fs = gridBuilder.newFieldset(ToDoDO.class, "group");
groupSelectPanel = new NewGroupSelectPanel(fs.newChildId(), new PropertyModel<>(data, "group"), parentPage, "groupId");
fs.add(groupSelectPanel);
fs.setLabelFor(groupSelectPanel);
fs.addHelpIcon(new ResourceModel("plugins.todo.group.tooltip.title"), new ResourceModel("plugins.todo.group.tooltip.content"));
groupSelectPanel.init();
}
{
// Description
final FieldsetPanel fs = gridBuilder.newFieldset(ToDoDO.class, "description");
fs.add(new MaxLengthTextArea(fs.getTextAreaId(), new PropertyModel<>(data, "description"))).setAutogrow();
}
{
// Comment
final FieldsetPanel fs = gridBuilder.newFieldset(ToDoDO.class, "comment");
commentTextArea = new MaxLengthTextArea(fs.getTextAreaId(), new PropertyModel<>(data, "comment"));
fs.add(commentTextArea).setAutogrow();
}
{
// Options
final FieldsetPanel fs = gridBuilder.newFieldset(getString("label.options")).suppressLabelForWarning();
final DivPanel checkBoxButton = fs.addNewCheckBoxButtonDiv();
if (configurationService.isSendMailConfigured()) {
checkBoxButton.add(new CheckBoxButton(checkBoxButton.newChildId(), new PropertyModel<>(this, "sendNotification"), getString("label.sendEMailNotification")).setTooltip(getString("plugins.todo.notification.tooltip")));
}
// if (ConfigXml.getInstance().isSmsConfigured() == true) {
// checkBoxPanel.add(new CheckBoxPanel(checkBoxPanel.newChildId(), new PropertyModel<Boolean>(this, "sendShortMessage"),
// getString("label.sendShortMessage")));
// }
checkBoxButton.add(new CheckBoxButton(checkBoxButton.newChildId(), new PropertyModel<>(this, "saveAsTemplate"), getString("userPref.saveAsTemplate")));
}
if (!isNew() && getData().getStatus() != ToDoStatus.CLOSED && !getData().isDeleted() && getBaseDao().hasLoggedInUserUpdateAccess(getData(), getData(), false)) {
// Close button:
final AjaxButton closeButton = new AjaxButton(ButtonPanel.BUTTON_ID, this) {
@Override
protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
// repaint the feedback panel so that it is hidden:
target.add(((ToDoEditForm) form).getFeedbackPanel());
getData().setComment(commentTextArea.getConvertedInput());
closeToDoDialogCommentTextArea.modelChanged();
target.add(closeToDoDialogCommentTextArea);
closeToDoDialog.open(target);
// Focus doesn't yet work:
// + "$('#"
// + closeToDoDialog.getMainContainerMarkupId()
// + "').on('shown', function () { $('"
// + closeToDialogCommentTextArea.getMarkupId()
// + "').focus(); })");
}
@Override
protected void onError(final AjaxRequestTarget target, final Form<?> form) {
target.add(((ToDoEditForm) form).getFeedbackPanel());
}
};
final SingleButtonPanel closeButtonPanel = new SingleButtonPanel(actionButtons.newChildId(), closeButton, getString("plugins.todo.button.close"));
actionButtons.add(2, closeButtonPanel);
addCloseToDoDialog();
}
}
use of org.projectforge.web.task.TaskSelectPanel in project projectforge by micromata.
the class ToDoListForm method init.
@SuppressWarnings("serial")
@Override
protected void init() {
super.init();
gridBuilder.newSplitPanel(GridSize.COL66);
{
// Assignee
final FieldsetPanel fs = gridBuilder.newFieldset(getString("plugins.todo.assignee"));
final UserSelectPanel assigneeSelectPanel = new UserSelectPanel(fs.newChildId(), new Model<PFUserDO>() {
@Override
public PFUserDO getObject() {
return UserGroupCache.getInstance().getUser(getSearchFilter().getAssigneeId());
}
@Override
public void setObject(final PFUserDO object) {
if (object == null) {
getSearchFilter().setAssigneeId(null);
} else {
getSearchFilter().setAssigneeId(object.getId());
}
}
}, parentPage, "assigneeId");
fs.add(assigneeSelectPanel);
assigneeSelectPanel.setDefaultFormProcessing(false);
assigneeSelectPanel.init().withAutoSubmit(true);
}
gridBuilder.newSplitPanel(GridSize.COL33);
{
// Reporter
final FieldsetPanel fs = gridBuilder.newFieldset(getString("plugins.todo.reporter"));
final UserSelectPanel reporterSelectPanel = new UserSelectPanel(fs.newChildId(), new Model<PFUserDO>() {
@Override
public PFUserDO getObject() {
return UserGroupCache.getInstance().getUser(getSearchFilter().getReporterId());
}
@Override
public void setObject(final PFUserDO object) {
if (object == null) {
getSearchFilter().setReporterId(null);
} else {
getSearchFilter().setReporterId(object.getId());
}
}
}, parentPage, "reporterId");
fs.add(reporterSelectPanel);
reporterSelectPanel.setDefaultFormProcessing(false);
reporterSelectPanel.init().withAutoSubmit(true);
}
{
gridBuilder.newSplitPanel(GridSize.COL100);
final FieldsetPanel fs = gridBuilder.newFieldset(getString("task")).suppressLabelForWarning();
final TaskSelectPanel taskSelectPanel = new TaskSelectPanel(fs, new Model<TaskDO>() {
@Override
public TaskDO getObject() {
return getTaskTree().getTaskById(getSearchFilter().getTaskId());
}
@Override
public void setObject(final TaskDO task) {
if (task != null) {
getSearchFilter().setTaskId(task.getId());
} else {
getSearchFilter().setTaskId(null);
}
}
}, parentPage, "taskId");
fs.add(taskSelectPanel);
taskSelectPanel.init();
taskSelectPanel.setRequired(false);
}
}
use of org.projectforge.web.task.TaskSelectPanel in project projectforge by micromata.
the class AccessEditForm method init.
@SuppressWarnings("serial")
@Override
protected void init() {
super.init();
gridBuilder.newGridPanel();
{
// Task
final FieldsetPanel fs = gridBuilder.newFieldset(getString("task"));
final TaskSelectPanel taskSelectPanel = new TaskSelectPanel(fs, new PropertyModel<TaskDO>(data, "task"), parentPage, "taskId");
fs.add(taskSelectPanel.setRequired(true));
taskSelectPanel.init();
}
{
// Group
final FieldsetPanel fs = gridBuilder.newFieldset(getString("group")).suppressLabelForWarning();
groupSelectPanel = new NewGroupSelectPanel(fs.newChildId(), new PropertyModel<GroupDO>(data, "group"), parentPage, "groupId");
fs.add(groupSelectPanel.setRequired(true));
groupSelectPanel.init();
}
{
// Option recursive
gridBuilder.newFieldset(getString("recursive")).addCheckBox(new PropertyModel<Boolean>(data, "recursive"), null).setTooltip(getString("access.recursive.help"));
}
{
// Access entries table
final FieldsetPanel fs = gridBuilder.newFieldset(getString("access.accessTable")).suppressLabelForWarning();
final AccessEditTablePanel accessEditTablePanel = new AccessEditTablePanel(fs.newChildId(), data);
fs.add(accessEditTablePanel);
accessEditTablePanel.init();
}
{
// Templates
final FieldsetPanel fs = gridBuilder.newFieldset(getString("access.templates")).suppressLabelForWarning();
fs.add(new SingleButtonPanel(fs.newChildId(), new Button(SingleButtonPanel.WICKET_ID, new Model<String>("clear")) {
@Override
public final void onSubmit() {
data.clear();
}
}, getString("access.templates.clear"), SingleButtonPanel.NORMAL));
fs.add(new SingleButtonPanel(fs.newChildId(), new Button(SingleButtonPanel.WICKET_ID, new Model<String>("guest")) {
@Override
public final void onSubmit() {
data.guest();
}
}, getString("access.templates.guest"), SingleButtonPanel.NORMAL));
fs.add(new SingleButtonPanel(fs.newChildId(), new Button(SingleButtonPanel.WICKET_ID, new Model<String>("employee")) {
@Override
public final void onSubmit() {
data.employee();
}
}, getString("access.templates.employee"), SingleButtonPanel.NORMAL));
fs.add(new SingleButtonPanel(fs.newChildId(), new Button(SingleButtonPanel.WICKET_ID, new Model<String>("leader")) {
@Override
public final void onSubmit() {
data.leader();
}
}, getString("access.templates.leader"), SingleButtonPanel.NORMAL));
fs.add(new SingleButtonPanel(fs.newChildId(), new Button(SingleButtonPanel.WICKET_ID, new Model<String>("administrator")) {
@Override
public final void onSubmit() {
data.administrator();
}
}, getString("access.templates.administrator"), SingleButtonPanel.DANGER));
}
{
// Description
final FieldsetPanel fs = gridBuilder.newFieldset(getString("description"));
fs.add(new MaxLengthTextArea(fs.getTextAreaId(), new PropertyModel<String>(data, "description")), true);
}
}
use of org.projectforge.web.task.TaskSelectPanel in project projectforge by micromata.
the class AccessListForm method init.
@SuppressWarnings("serial")
@Override
protected void init() {
super.init();
gridBuilder.newSplitPanel(GridSize.COL66);
{
// Group
final FieldsetPanel fs = gridBuilder.newFieldset(getString("group")).suppressLabelForWarning();
groupSelectPanel = new NewGroupSelectPanel(fs.newChildId(), new Model<GroupDO>() {
@Override
public GroupDO getObject() {
return groupService.getGroup(getSearchFilter().getGroupId());
}
@Override
public void setObject(final GroupDO object) {
if (object == null) {
getSearchFilter().setGroupId(null);
} else {
getSearchFilter().setGroupId(object.getId());
}
}
}, parentPage, "groupId");
fs.add(groupSelectPanel);
groupSelectPanel.setDefaultFormProcessing(false);
groupSelectPanel.init();
}
gridBuilder.newSplitPanel(GridSize.COL33);
{
// User
final FieldsetPanel fs = gridBuilder.newFieldset(getString("user")).suppressLabelForWarning();
final UserSelectPanel assigneeSelectPanel = new UserSelectPanel(fs.newChildId(), new Model<PFUserDO>() {
@Override
public PFUserDO getObject() {
return userGroupCache.getUser(getSearchFilter().getUserId());
}
@Override
public void setObject(final PFUserDO object) {
if (object == null) {
getSearchFilter().setUserId(null);
} else {
getSearchFilter().setUserId(object.getId());
}
}
}, parentPage, "userId");
fs.add(assigneeSelectPanel);
assigneeSelectPanel.setDefaultFormProcessing(false);
assigneeSelectPanel.init().withAutoSubmit(true);
fs.addHelpIcon(getString("access.tooltip.filter.user"));
}
gridBuilder.newGridPanel();
{
final FieldsetPanel fs = gridBuilder.newFieldset(getString("task")).suppressLabelForWarning();
final TaskSelectPanel taskSelectPanel = new TaskSelectPanel(fs, new Model<TaskDO>() {
@Override
public TaskDO getObject() {
return taskTree.getTaskById(getSearchFilter().getTaskId());
}
@Override
public void setObject(final TaskDO task) {
if (task != null) {
getSearchFilter().setTaskId(task.getId());
} else {
getSearchFilter().setTaskId(null);
}
}
}, parentPage, "taskId");
fs.add(taskSelectPanel);
taskSelectPanel.init();
taskSelectPanel.setRequired(false);
}
}
use of org.projectforge.web.task.TaskSelectPanel in project projectforge by micromata.
the class TaskWizardForm method init.
@Override
@SuppressWarnings("serial")
protected void init() {
super.init();
int number = 1;
{
gridBuilder.newFormHeading(getString("wizard"));
final DivPanel section = gridBuilder.getPanel();
section.add(new DivTextPanel(section.newChildId(), getString("task.wizard.intro")));
}
gridBuilder.newGridPanel();
{
final DivPanel section = gridBuilder.getPanel();
section.add(new Heading3Panel(section.newChildId(), String.valueOf(number++) + ". " + getString("task")));
final FieldsetPanel fs = gridBuilder.newFieldset(getString("task"));
final TaskSelectPanel taskSelectPanel = new TaskSelectPanel(fs, new PropertyModel<TaskDO>(this, "task"), parentPage, "taskId");
fs.add(taskSelectPanel);
taskSelectPanel.setShowFavorites(false).init();
taskSelectPanel.setRequired(true);
AjaxSubmitLink createTaskLink = new AjaxSubmitLink(IconLinkPanel.LINK_ID) {
@Override
protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
final PageParameters params = new PageParameters();
params.add(TaskEditPage.PARAM_PARENT_TASK_ID, TaskTree.getInstance().getRootTaskNode().getId());
final TaskEditPage editPage = new TaskEditPage(params);
editPage.setReturnToPage(parentPage);
setResponsePage(editPage);
}
};
createTaskLink.setDefaultFormProcessing(false);
fs.add(new IconLinkPanel(fs.newChildId(), IconType.PLUS_SIGN, new Model<String>(getString("task.wizard.button.createTask")), createTaskLink));
}
// Team
groupSelectPanelTeam = createGroupComponents(number++, "team");
// Manager group
groupSelectPanelManager = createGroupComponents(number++, "managerGroup");
gridBuilder.newGridPanel();
{
final DivPanel section = gridBuilder.getPanel();
section.add(new Heading3Panel(section.newChildId(), getString("task.wizard.action")));
section.add(new DivTextPanel(section.newChildId(), new Model<String>() {
/**
* @see org.apache.wicket.model.Model#getObject()
*/
@Override
public String getObject() {
if (parentPage.actionRequired() == true) {
return getString("task.wizard.action.taskAndgroupsGiven");
} else {
return getString("task.wizard.action.noactionRequired");
}
}
}));
addCancelButton(new Button(SingleButtonPanel.WICKET_ID, new Model<String>("cancel")) {
@Override
public final void onSubmit() {
setResponsePage(TaskTreePage.class);
}
});
}
final Button finishButton = new Button(SingleButtonPanel.WICKET_ID, new Model<String>("finish")) {
@Override
public final void onSubmit() {
parentPage.create();
}
};
final SingleButtonPanel finishButtonPanel = new SingleButtonPanel(actionButtons.newChildId(), finishButton, getString("task.wizard.finish"), SingleButtonPanel.DEFAULT_SUBMIT);
actionButtons.add(finishButtonPanel);
this.setDefaultButton(finishButton);
}
Aggregations