protected void init()
{
super.init();
{
// Organization
final FieldsetPanel fs = gridBuilder.newFieldset(getString("organization"));
final PFAutoCompleteMaxLengthTextField organizationField = new PFAutoCompleteMaxLengthTextField(InputPanel.WICKET_ID,
new PropertyModel<String>(data, "organization")) {
@Override
protected List<String> getChoices(final String input)
{
return getBaseDao().getAutocompletion("organization", input);
}
};
organizationField.withMatchContains(true).withMinChars(2).withFocus(true);
WicketUtils.setStrong(organizationField);
fs.add(organizationField);
}
{
// Product
final FieldsetPanel fs = gridBuilder.newFieldset(getString("plugins.licensemanagement.product"));
final PFAutoCompleteMaxLengthTextField productField = new PFAutoCompleteMaxLengthTextField(InputPanel.WICKET_ID,
new PropertyModel<String>(data, "product")) {
@Override
protected List<String> getChoices(final String input)
{
return getBaseDao().getAutocompletion("product", input);
}
};
productField.withMatchContains(true).withMinChars(2);
productField.setRequired(true);
WicketUtils.setStrong(productField);
fs.add(productField);
}
{
// Version
final FieldsetPanel fs = gridBuilder.newFieldset(getString("plugins.licensemanagement.version"));
final RequiredMaxLengthTextField versionField = new RequiredMaxLengthTextField(fs.getTextFieldId(), new PropertyModel<String>(data,
"version"));
WicketUtils.setStrong(versionField);
fs.add(versionField);
}
{
// UpdateFromVersion
final FieldsetPanel fs = gridBuilder.newFieldset(getString("plugins.licensemanagement.updateFromVersion"));
fs.add(new MaxLengthTextField(fs.getTextFieldId(), new PropertyModel<String>(data, "updateFromVersion")));
fs.addHelpIcon(getString("plugins.licensemanagement.updateFromVersion.tooltip"));
}
{
// Device
final FieldsetPanel fs = gridBuilder.newFieldset(getString("plugins.licensemanagement.device"));
fs.add(new MaxLengthTextField(fs.getTextFieldId(), new PropertyModel<String>(data, "device")));
fs.addHelpIcon(getString("plugins.licensemanagement.device.tooltip"));
}
{
// Number of license:
final FieldsetPanel fs = gridBuilder.newFieldset(getString("plugins.licensemanagement.numberOfLicenses"));
final MinMaxNumberField<Integer> maxNumberField = new MinMaxNumberField<Integer>(InputPanel.WICKET_ID, new PropertyModel<Integer>(
data, "numberOfLicenses"), 0, 999999);
WicketUtils.setSize(maxNumberField, 6);
fs.add(maxNumberField);
}
{
// Owners
final FieldsetPanel fs = gridBuilder.newFieldset(getString("plugins.licensemanagement.owner")).setLabelSide(false);
final UsersProvider usersProvider = new UsersProvider();
assignOwnersListHelper = new MultiChoiceListHelper<PFUserDO>().setComparator(new UsersComparator()).setFullList(
usersProvider.getSortedUsers());
final Collection<PFUserDO> owners = ((LicenseDao) getBaseDao()).getSortedOwners(data);
if (owners != null) {
for (final PFUserDO owner : owners) {
assignOwnersListHelper.addOriginalAssignedItem(owner).assignItem(owner);
}
}
final Select2MultiChoice<PFUserDO> ownersChoice = new Select2MultiChoice<PFUserDO>(fs.getSelect2MultiChoiceId(),
new PropertyModel<Collection<PFUserDO>>(this.assignOwnersListHelper, "assignedItems"), usersProvider);
fs.add(ownersChoice);
}
gridBuilder.newSplitPanel(GridSize.COL50);
{
// Valid since
final FieldsetPanel fs = gridBuilder.newFieldset(getString("plugins.licensemanagement.validSince"));
final DatePanel validSinceDatePanel = new DatePanel(fs.newChildId(), new PropertyModel<Date>(data, "validSince"), DatePanelSettings
.get().withTargetType(java.sql.Date.class).withSelectProperty("validSince"));
fs.add(validSinceDatePanel);
}
gridBuilder.newSplitPanel(GridSize.COL33);
{
// Valid until
final FieldsetPanel fs = gridBuilder.newFieldset(getString("plugins.licensemanagement.validUntil"));
final DatePanel validUntilDatePanel = new DatePanel(fs.newChildId(), new PropertyModel<Date>(data, "validUntil"), DatePanelSettings
.get().withTargetType(java.sql.Date.class).withSelectProperty("validUntil"));
fs.add(validUntilDatePanel);
}
gridBuilder.newGridPanel();
{
// License holder
final FieldsetPanel fs = gridBuilder.newFieldset(getString("plugins.licensemanagement.licenseHolder"));
fs.add(new MaxLengthTextField(fs.getTextFieldId(), new PropertyModel<String>(data, "licenseHolder")));
}
final LicenseManagementRight right = (LicenseManagementRight) UserRights.instance().getRight(LicenseDao.USER_RIGHT_ID);
{
// Text key
final FieldsetPanel fs = gridBuilder.newFieldset(getString("plugins.licensemanagement.key"));
if (right.isLicenseKeyVisible(getUser(), data) == true) {
fs.add(new MaxLengthTextArea(fs.getTextAreaId(), new PropertyModel<String>(data, "key"))).setAutogrow();
} else {
fs.add(new DivTextPanel(fs.newChildId(), getString("plugins.licensemanagement.key.notvisible")));
fs.addHelpIcon(getString("plugins.licensemanagement.key.notvisible.tooltip"));
}
}
if ((isNew() == true && right.hasInsertAccess(getUser()) == true) //
|| (right.hasUpdateAccess(getUser(), data, null) == true && right.isLicenseKeyVisible(getUser(), data) == true)) {
gridBuilder.newSplitPanel(GridSize.COL50);
FieldsetPanel fs = gridBuilder.newFieldset(gridBuilder.getString("plugins.licensemanagement.file1"));
fileUploadPanel1 = new FileUploadPanel(fs.newChildId(), fs, this, true, new PropertyModel<String>(data, "filename1"),
new PropertyModel<byte[]>(data, "file1"));
if (isNew() == false && (data.getFile1() != null || data.getFile2() != null)) {
// Swap files:
fs.add(new IconButtonPanel(fs.newChildId(), IconType.SWAP, getString("plugins.licensemanagement.swapFiles")) {
/**
* @see org.projectforge.web.wicket.flowlayout.IconButtonPanel#onSubmit()
*/
@Override
protected void onSubmit()
{
final byte[] swap = data.getFile1();
final String swapFilename = data.getFilename1();
data.setFile1(data.getFile2());
data.setFilename1(data.getFilename2());
data.setFile2(swap);
data.setFilename2(swapFilename);
}
});
}
gridBuilder.newSplitPanel(GridSize.COL50);
fs = gridBuilder.newFieldset(gridBuilder.getString("plugins.licensemanagement.file2"));
fileUploadPanel2 = new FileUploadPanel(fs.newChildId(), fs, this, true, new PropertyModel<String>(data, "filename2"),
new PropertyModel<byte[]>(data, "file2"));
gridBuilder.newGridPanel();
} else if (right.isLicenseKeyVisible(getUser(), data) == true) {
}
{
// Text comment
final FieldsetPanel fs = gridBuilder.newFieldset(getString("comment"));
fs.add(new MaxLengthTextArea(fs.getTextAreaId(), new PropertyModel<String>(data, "comment"))).setAutogrow();
}
addCloneButton();
}