Skip to content

Commit

Permalink
FIPS-11531/FIPS-11568 :: validation dialog is now scrollable
Browse files Browse the repository at this point in the history
Change-Id: Ib8561897e780381c4e9a44a1bbd78cef5da1f44b
(cherry picked from commit 3f67428)
  • Loading branch information
hookyAt authored and S3bB0 committed May 8, 2024
1 parent 2cd4973 commit c8d2d4f
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .ci/review.Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ pipeline {

post {
always {
parentReference referenceJob: "${JOB_NAME}", defaultBranch: 'hotfix/22.12', targetBranch: '$GERRIT_BRANCH', latestBuildIfNotFound: false, latestCommitFallback: false, mergeOnlyJob: false, maxBuilds: 10, maxCommits: 500
parentReference referenceJob: "${JOB_NAME}", mergeBranch: 'hotfix/22.12', targetBranch: '$GERRIT_BRANCH', latestBuildIfNotFound: false, latestCommitFallback: false, mergeOnlyJob: false, maxBuilds: 10, maxCommits: 500


junit testResults: "**/target/surefire-reports/*.xml", allowEmptyResults: true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*******************************************************************************
* Copyright (c) Faktor Zehn GmbH - faktorzehn.org
*
*
* This source code is available under the terms of the AGPL Affero General Public License version
* 3.
*
*
* Please see LICENSE.txt for full license terms, including the additional permissions and
* restrictions as well as the possibility of alternative license terms.
*******************************************************************************/
Expand All @@ -12,12 +12,16 @@

import org.eclipse.jface.dialogs.TitleAreaDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.events.ControlAdapter;
import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.TabItem;
import org.faktorips.devtools.core.ui.IDataChangeableReadWriteAccess;
import org.faktorips.devtools.core.ui.UIToolkit;
import org.faktorips.runtime.Message;
Expand Down Expand Up @@ -64,7 +68,7 @@ public void setDataChangeable(boolean changeable) {
/**
* Template method that may be extended by sub classes. The default implementation sets the UI
* toolkit's changeable state.
*
*
* @param changeable Flag indicating the changeable state.
*/
protected void setDataChangeableThis(boolean changeable) {
Expand Down Expand Up @@ -114,7 +118,7 @@ protected final Control createDialogArea(Composite parent) {
/**
* This method must create and return the UI composite containing the actual contents of the
* dialog.
*
*
* @param parent The parent UI composite.
*/
protected abstract Composite createWorkArea(Composite parent);
Expand All @@ -136,6 +140,38 @@ protected final Composite createTabItemComposite(TabFolder folder, int numOfColu
return c;
}

protected final Composite createScrollableTabItemComposite(TabFolder folder,
TabItem tab,
int numOfColumns,
boolean equalSize) {

ScrolledComposite scroller = new ScrolledComposite(folder, SWT.V_SCROLL);
scroller.setLayout(new GridLayout());

Composite c = toolkit.createGridComposite(scroller, numOfColumns, equalSize, true);
((GridLayout)c.getLayout()).marginHeight = 12;

scroller.setContent(c);
scroller.setExpandVertical(true);
scroller.setExpandHorizontal(true);

scroller.addControlListener(new ControlAdapter() {
@Override
public void controlResized(ControlEvent e) {
scroller.setMinHeight(folder.computeSize(SWT.DEFAULT, SWT.DEFAULT).y - heightOfTabs(folder, scroller));
scroller.requestLayout();
}

private int heightOfTabs(TabFolder folder, ScrolledComposite scroller) {
return folder.getSize().y - scroller.getClientArea().height;
}
});

tab.setControl(scroller);

return c;
}

protected void showValidationResult(MessageList result) {
Message msg = result.getFirstMessage(Message.ERROR);
if (msg == null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*******************************************************************************
* Copyright (c) Faktor Zehn GmbH - faktorzehn.org
*
*
* This source code is available under the terms of the AGPL Affero General Public License version
* 3.
*
*
* Please see LICENSE.txt for full license terms, including the additional permissions and
* restrictions as well as the possibility of alternative license terms.
*******************************************************************************/
Expand Down Expand Up @@ -98,7 +98,7 @@

/**
* Dialog to edit an attribute.
*
*
* @author Jan Ortmann
*/
public class AttributeEditDialog extends IpsPartEditDialog2 {
Expand Down Expand Up @@ -210,7 +210,7 @@ protected Composite createWorkAreaThis(Composite parent) {

final TabItem validationRulePage = new TabItem(tabFolder, SWT.NONE);
validationRulePage.setText(Messages.AttributeEditDialog_validationRuleTitle);
validationRulePage.setControl(createValidationRulePage(tabFolder));
createValidationRulePage(tabFolder, validationRulePage);
if (startWithRulePage) {
tabFolder.setSelection(2);
ruleDefinitionUI.setFocusToNameField();
Expand Down Expand Up @@ -733,7 +733,7 @@ private void updateAllowedValueSetTypes() {
.setAllowedValueSetTypes(attribute.getAllowedValueSetTypes(attribute.getIpsProject()));
} catch (IpsException e) {
IpsPlugin.log(e);
valueSetSpecificationControl.setAllowedValueSetTypes(new ArrayList<ValueSetType>());
valueSetSpecificationControl.setAllowedValueSetTypes(new ArrayList<>());
}
if (currentValueSetType != null) {
// if the previous selection was a valid selection use this one as new selection in drop
Expand All @@ -742,8 +742,8 @@ private void updateAllowedValueSetTypes() {
}
}

private Control createValidationRulePage(TabFolder folder) {
Composite workArea = createTabItemComposite(folder, 1, false);
private Control createValidationRulePage(TabFolder folder, TabItem tab) {
Composite workArea = createScrollableTabItemComposite(folder, tab, 1, false);

validationRuleAdded = getToolkit().createCheckbox(workArea,
Messages.AttributeEditDialog_labelActivateValidationRule);
Expand Down Expand Up @@ -786,7 +786,7 @@ private Control createValidationRulePage(TabFolder folder) {
* By activating/deactivating a validation rule for an attribute, not only can the rule be
* <code>null</code>, but also new new rule instances can be created repeatedly. To keep all UI
* elements bound to the correct rule instance, it has to be re-bound in that case.
*
*
* SW 10.12.2014: Note that this is a workaround. A cleaner solution would be to introduce a
* rule-PMO that is bound to the UI and hides the fact that the rule may be replaced or deleted.
* See private/sw/3572_2 for a work-in-progress of this idea.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*******************************************************************************
* Copyright (c) Faktor Zehn GmbH - faktorzehn.org
*
*
* This source code is available under the terms of the AGPL Affero General Public License version
* 3.
*
*
* Please see LICENSE.txt for full license terms, including the additional permissions and
* restrictions as well as the possibility of alternative license terms.
*******************************************************************************/
Expand Down Expand Up @@ -59,10 +59,10 @@
* <p>
* To be used wherever a validation rule (definition) is created via GUI. A {@link BindingContext}
* is used to link model and UI.
*
*
* @see RuleEditDialog
* @see AttributeEditDialog
*
*
*/
public class ValidationRuleEditingUI {

Expand Down Expand Up @@ -95,7 +95,7 @@ public ValidationRuleEditingUI(UIToolkit uiToolkit) {
* <p>
* Call {@link #bindFields(IValidationRule, BindingContext)} to connect/bind the controls to a
* specific {@link IValidationRule}.
*
*
* @param workArea composite to create the controls in
*/
public void initUI(Composite workArea) {
Expand Down Expand Up @@ -124,7 +124,7 @@ public void initUI(Composite workArea) {

Text msgText = uiToolkit.createMultilineText(textGroup);
GridData msgTextLayoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
msgTextLayoutData.heightHint = 50;
msgTextLayoutData.heightHint = 100;
msgTextLayoutData.widthHint = UIToolkit.DEFAULT_WIDTH;
msgText.setLayoutData(msgTextLayoutData);
msgText.addModifyListener($ -> updateCharCount());
Expand Down Expand Up @@ -220,7 +220,7 @@ private void updateCharCount() {
/**
* Binds all of this UI's controls to the given {@link IValidationRule} and
* {@link BindingContext}.
*
*
* @param rule the {@link IValidationRule} to connect/bind the UI to. The bound rule can then be
* edited by the controls created by this class.
* @param bindingContext the {@link BindingContext} to remove bindings from
Expand Down Expand Up @@ -282,7 +282,7 @@ public void setFocusToNameField() {
* <p>
* If this method returns <code>true</code> all fields and controls available through getters
* have been initialized.
*
*
* @return <code>true</code> if the ui for a validation rule has been initialized,
* <code>false</code> otherwise.
*/
Expand All @@ -292,7 +292,7 @@ public boolean isUiInitialized() {

/**
* Removes all bindings for this UI's controls from the given context.
*
*
* @param bindingContext the {@link BindingContext} to remove bindings from
*/
public void removeBindingsFromContext(BindingContext bindingContext) {
Expand Down

0 comments on commit c8d2d4f

Please sign in to comment.