Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2023 BSI Business Systems Integration AG
* Copyright (c) 2010, 2026 BSI Business Systems Integration AG
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
Expand All @@ -12,22 +12,39 @@
import org.eclipse.scout.contacts.client.ConfigProperties.ReadOnlyProperty;
import org.eclipse.scout.rt.client.ui.action.menu.AbstractMenu;
import org.eclipse.scout.rt.client.ui.action.menu.IMenu;
import org.eclipse.scout.rt.client.ui.form.fields.button.AbstractOkButton;
import org.eclipse.scout.rt.client.ui.form.AbstractForm;
import org.eclipse.scout.rt.client.ui.form.fields.button.IButton;
import org.eclipse.scout.rt.platform.ApplicationScoped;
import org.eclipse.scout.rt.platform.Order;
import org.eclipse.scout.rt.platform.classid.ClassId;
import org.eclipse.scout.rt.platform.config.CONFIG;
import org.eclipse.scout.rt.platform.text.TEXTS;
import org.eclipse.scout.rt.platform.util.Assertions;
import org.eclipse.scout.rt.platform.util.collection.OrderedCollection;

@ApplicationScoped
public class ContactsHelper {

public void handleReadOnly(AbstractOkButton okButton) {
public void handleReadOnly(AbstractForm form) {
if (!CONFIG.getPropertyValue(ReadOnlyProperty.class)) {
return;
}

form.visit(b -> {
switch (b.getSystemType()) {
case IButton.SYSTEM_TYPE_CANCEL -> b.setSystemType(IButton.SYSTEM_TYPE_CLOSE);
case IButton.SYSTEM_TYPE_OK -> {
b.setLabel(TEXTS.get("CloseButton"));
b.setSystemType(IButton.SYSTEM_TYPE_CLOSE);
}
case IButton.SYSTEM_TYPE_SAVE, IButton.SYSTEM_TYPE_SAVE_WITHOUT_MARKER_CHANGE -> b.setSystemType(IButton.SYSTEM_TYPE_NONE);
}
}, IButton.class);
}

public void failIfReadOnly() {
if (CONFIG.getPropertyValue(ReadOnlyProperty.class)) {
okButton.setLabel(TEXTS.get("CloseButton"));
okButton.setSystemType(IButton.SYSTEM_TYPE_CLOSE);
Assertions.fail("Not allowed in read only mode");
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2023 BSI Business Systems Integration AG
* Copyright (c) 2010, 2026 BSI Business Systems Integration AG
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -156,7 +156,7 @@ public PhoneField getPhoneField() {

@Override
protected void execInitForm() {
BEANS.get(ContactsHelper.class).handleReadOnly(getOkButton());
BEANS.get(ContactsHelper.class).handleReadOnly(this);
}

// tag::layout[]
Expand Down Expand Up @@ -348,6 +348,7 @@ protected void execLoad() {

@Override
protected void execStore() {
BEANS.get(ContactsHelper.class).failIfReadOnly();
OrganizationFormData formData = new OrganizationFormData();
exportFormData(formData);
BEANS.get(IOrganizationService.class).store(formData);
Expand All @@ -368,6 +369,7 @@ public class NewHandler extends AbstractDirtyFormHandler {

@Override
protected void execStore() {
BEANS.get(ContactsHelper.class).failIfReadOnly();
OrganizationFormData formData = new OrganizationFormData();
exportFormData(formData);
formData = BEANS.get(IOrganizationService.class).create(formData);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2023 BSI Business Systems Integration AG
* Copyright (c) 2010, 2026 BSI Business Systems Integration AG
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -643,7 +643,7 @@ public class EmailField extends AbstractStringField {
// http://www.mkyong.com/regular-expressions/how-to-validate-email-address-with-regular-expression/
// tag::email[]
private static final String EMAIL_PATTERN = // <1>
"^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@" +
"^[_A-Za-z0-9-+]+(\\.[_A-Za-z0-9-]+)*@" +
"[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$";

@Override
Expand Down Expand Up @@ -796,6 +796,7 @@ protected void execLoad() {

@Override
protected void execStore() {
BEANS.get(ContactsHelper.class).failIfReadOnly();
IPersonService service = BEANS.get(IPersonService.class);
PersonFormData formData = new PersonFormData();
exportFormData(formData);
Expand All @@ -807,6 +808,7 @@ public class NewHandler extends AbstractFormHandler {

@Override
protected void execStore() {
BEANS.get(ContactsHelper.class).failIfReadOnly();
IPersonService service = BEANS.get(IPersonService.class);
PersonFormData formData = new PersonFormData();
exportFormData(formData);
Expand All @@ -816,7 +818,7 @@ protected void execStore() {
}
// end::handler[]

//This modify handler is used in the application:
//This modify-handler is used in the application:
public class ModifyDirtyHandler extends AbstractDirtyFormHandler {

@Override
Expand All @@ -832,6 +834,7 @@ protected void execLoad() {

@Override
protected void execStore() {
BEANS.get(ContactsHelper.class).failIfReadOnly();
IPersonService service = BEANS.get(IPersonService.class);
PersonFormData formData = new PersonFormData();
exportFormData(formData);
Expand All @@ -854,6 +857,7 @@ public class NewDirtyHandler extends AbstractDirtyFormHandler {

@Override
protected void execStore() {
BEANS.get(ContactsHelper.class).failIfReadOnly();
IPersonService service = BEANS.get(IPersonService.class);
PersonFormData formData = new PersonFormData();
exportFormData(formData);
Expand All @@ -869,7 +873,7 @@ protected void execDirtyStatusChanged(boolean dirty) {

@Override
protected void execInitForm() {
BEANS.get(ContactsHelper.class).handleReadOnly(getOkButton());
BEANS.get(ContactsHelper.class).handleReadOnly(this);
}


Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2023 BSI Business Systems Integration AG
* Copyright (c) 2010, 2026 BSI Business Systems Integration AG
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -184,7 +184,7 @@ public Object computeExclusiveKey() {

@Override
protected void execInitForm() {
BEANS.get(ContactsHelper.class).handleReadOnly(getOkButton());
BEANS.get(ContactsHelper.class).handleReadOnly(this);
}

@Order(1)
Expand Down Expand Up @@ -333,11 +333,6 @@ protected String getConfiguredLabel() {
@ClassId("627f6a0e-349f-4846-8449-1ec41156657d")
public class ParticipantTableFieldField extends AbstractTableField<Table> {

@Override
protected int getConfiguredGridH() {
return 3;
}

@Override
protected boolean getConfiguredLabelVisible() {
return false;
Expand Down Expand Up @@ -562,6 +557,7 @@ protected void execLoad() {

@Override
protected void execStore() {
BEANS.get(ContactsHelper.class).failIfReadOnly();
EventFormData formData = new EventFormData();
exportFormData(formData);
BEANS.get(IEventService.class).store(formData);
Expand Down Expand Up @@ -590,6 +586,7 @@ protected void execLoad() {

@Override
protected void execStore() {
BEANS.get(ContactsHelper.class).failIfReadOnly();
EventFormData formData = new EventFormData();
exportFormData(formData);
formData = BEANS.get(IEventService.class).create(formData);
Expand Down