diff options
3 files changed, 49 insertions, 116 deletions
diff --git a/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/api/widgets/AbstractEEFWidgetLifecycleManager.java b/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/api/widgets/AbstractEEFWidgetLifecycleManager.java index 978299bea..736ca2d6e 100644 --- a/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/api/widgets/AbstractEEFWidgetLifecycleManager.java +++ b/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/api/widgets/AbstractEEFWidgetLifecycleManager.java @@ -15,9 +15,6 @@ import java.util.Collection; import java.util.Optional; import java.util.function.Consumer; -import org.eclipse.eef.EEFDynamicMappingFor; -import org.eclipse.eef.EEFDynamicMappingIf; -import org.eclipse.eef.EEFGroupDescription; import org.eclipse.eef.EEFWidgetDescription; import org.eclipse.eef.EEFWidgetStyle; import org.eclipse.eef.common.api.utils.Util; @@ -51,7 +48,6 @@ import org.eclipse.swt.events.MouseTrackListener; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; @@ -127,7 +123,7 @@ public abstract class AbstractEEFWidgetLifecycleManager extends AbstractEEFLifec * {@inheritDoc} * * @see org.eclipse.eef.ide.ui.api.widgets.AbstractEEFLifecycleManager#createControl(org.eclipse.swt.widgets.Composite, - * org.eclipse.eef.common.ui.api.IEEFFormContainer) + * org.eclipse.eef.common.ui.api.IEEFFormContainer) */ @Override public void createControl(Composite parent, IEEFFormContainer formContainer) { @@ -135,64 +131,26 @@ public abstract class AbstractEEFWidgetLifecycleManager extends AbstractEEFLifec EEFWidgetFactory widgetFactory = formContainer.getWidgetFactory(); - Composite composite = parent; - - // If we are in a group, we will always create a label (empty or not) for the 3 columns layout of the group. - boolean isInGroup = this.isInGroup(); - - // Some widgets (like a checkbox) will not have a separated "label" widget for their label. Those widgets will - // thus never create another widget expect in the group (for the layout). - boolean needsSeparatedLabel = this.needSeparatedLabel(); - - // Finally if the label expression is blank, we will not create a label inside of a group (for the layout). - boolean isBlankLabel = Util.isBlank(this.getWidgetDescription().getLabelExpression()); - - boolean needsLabel = isInGroup || (!isBlankLabel && needsSeparatedLabel); - boolean needsHelp = isInGroup || !Util.isBlank(this.getWidgetDescription().getHelpExpression()); - - // If we are not in a group, we will create a composite to hold all the label and help of the widget if - // necessary - if (!isInGroup && (needsLabel || needsHelp)) { - composite = widgetFactory.createComposite(parent); - - // We will only create the necessary number of columns for this "invisible" composite - int numColumn = 1; - if (needsLabel) { - numColumn = numColumn + 1; - } - if (needsHelp) { - numColumn = numColumn + 1; - } - GridLayout layout = new GridLayout(numColumn, false); - // As this composite is "invisible", it must not add border. - layout.marginHeight = 0; - layout.marginWidth = 0; - composite.setLayout(layout); - - GridData layoutData = new GridData(GridData.FILL_HORIZONTAL); - layoutData.horizontalSpan = 1; - composite.setLayoutData(layoutData); - } - - if (needsLabel) { - this.label = widgetFactory.createStyledText(composite, SWT.READ_ONLY); - this.label.setEditable(false); - this.label.setCaret(null); - this.label.setCursor(Display.getCurrent().getSystemCursor(SWT.CURSOR_ARROW)); - this.label.setDoubleClickEnabled(false); - this.label.setLayoutData(new GridData(this.getLabelVerticalAlignment())); - } - - if (needsHelp) { - this.help = widgetFactory.createCLabel(composite, ""); //$NON-NLS-1$ - if (!Util.isBlank(this.getWidgetDescription().getHelpExpression())) { - this.help.setImage(EEFIdeUiPlugin.getPlugin().getImageRegistry().get(Icons.HELP)); - this.help.setLayoutData(new GridData(this.getLabelVerticalAlignment())); - this.help.setToolTipText(""); //$NON-NLS-1$ - } + // Because the parent layout has 3 columns, always create 3 widgets. + + // The label (even if empty) + this.label = widgetFactory.createStyledText(parent, SWT.READ_ONLY); + this.label.setEditable(false); + this.label.setCaret(null); + this.label.setCursor(Display.getCurrent().getSystemCursor(SWT.CURSOR_ARROW)); + this.label.setDoubleClickEnabled(false); + this.label.setLayoutData(new GridData(this.getLabelVerticalAlignment())); + + // The help bullet (even if no help is available) + this.help = widgetFactory.createCLabel(parent, ""); //$NON-NLS-1$ + if (!Util.isBlank(this.getWidgetDescription().getHelpExpression())) { + this.help.setImage(EEFIdeUiPlugin.getPlugin().getImageRegistry().get(Icons.HELP)); + this.help.setLayoutData(new GridData(this.getLabelVerticalAlignment())); + this.help.setToolTipText(""); //$NON-NLS-1$ } - this.createMainControl(composite, formContainer); + // The main control (delegated to the concrete Lifecycle Manager) + this.createMainControl(parent, formContainer); this.controlDecoration = new ControlDecoration(this.getValidationControl(), SWT.TOP | SWT.LEFT); this.checkLockStatus(); @@ -210,33 +168,6 @@ public abstract class AbstractEEFWidgetLifecycleManager extends AbstractEEFLifec } /** - * Indicates if the widget description is located directly under a group or if it is under a container. - * - * @return <code>true</code> if the widget description is directly under a group, <code>false</code> otherwise - */ - private boolean isInGroup() { - EObject eContainer = this.getWidgetDescription().eContainer(); - - // Test if the widget description is in a dynamic mapping directly under a group - if (eContainer instanceof EEFDynamicMappingIf && eContainer.eContainer() instanceof EEFDynamicMappingFor) { - EEFDynamicMappingFor dynamicMappingFor = (EEFDynamicMappingFor) eContainer.eContainer(); - return dynamicMappingFor.eContainer() instanceof EEFGroupDescription; - } - - // Otherwise, let's test if it is directly under a group - return eContainer instanceof EEFGroupDescription; - } - - /** - * Indicates if the widget should create a label widget for its label. - * - * @return <code>true</code> if a label should be created, <code>false</code> otherwise. - */ - protected boolean needSeparatedLabel() { - return true; - } - - /** * Returns the vertical alignment of the label of the widget. Use one of the following values: * <ul> * <li>GridData.VERTICAL_ALIGN_BEGINNING</li> diff --git a/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFCheckboxLifecycleManager.java b/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFCheckboxLifecycleManager.java index 68a80f00f..1f25b6f87 100644 --- a/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFCheckboxLifecycleManager.java +++ b/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFCheckboxLifecycleManager.java @@ -109,16 +109,6 @@ public class EEFCheckboxLifecycleManager extends AbstractEEFWidgetLifecycleManag /** * {@inheritDoc} * - * @see org.eclipse.eef.ide.ui.api.widgets.AbstractEEFWidgetLifecycleManager#needSeparatedLabel() - */ - @Override - protected boolean needSeparatedLabel() { - return false; - } - - /** - * {@inheritDoc} - * * @see org.eclipse.eef.ide.ui.api.widgets.AbstractEEFWidgetLifecycleManager#getController() */ @Override diff --git a/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFContainerLifecycleManager.java b/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFContainerLifecycleManager.java index 8e77010cd..7966cac02 100644 --- a/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFContainerLifecycleManager.java +++ b/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFContainerLifecycleManager.java @@ -18,7 +18,6 @@ import org.eclipse.eef.EEFContainerDescription; import org.eclipse.eef.EEFControlDescription; import org.eclipse.eef.EEFFillLayoutDescription; import org.eclipse.eef.EEFGridLayoutDescription; -import org.eclipse.eef.EEFGroupDescription; import org.eclipse.eef.EEFLayoutDescription; import org.eclipse.eef.EEF_FILL_LAYOUT_ORIENTATION; import org.eclipse.eef.common.ui.api.EEFWidgetFactory; @@ -97,13 +96,6 @@ public class EEFContainerLifecycleManager implements IEEFLifecycleManager { Composite composite = null; GridData gridData = null; - // If the container is directly under a group, we will create two empty labels for the first two columns of the - // layout (label & help) - if (this.description.eContainer() instanceof EEFGroupDescription) { - widgetFactory.createLabel(parent, ""); //$NON-NLS-1$ - widgetFactory.createLabel(parent, ""); //$NON-NLS-1$ - } - if (isBorderedContainer()) { String borderLabel = getBorderLabel(); composite = widgetFactory.createGroup(parent, borderLabel); @@ -113,30 +105,50 @@ public class EEFContainerLifecycleManager implements IEEFLifecycleManager { gridData = new GridData(GridData.FILL_HORIZONTAL); } + // Because the parent layout has 3 columns, span this composite over 3 columns. + gridData.horizontalSpan = 3; composite.setLayoutData(gridData); - GridLayout compositeLayout = new GridLayout(1, true); - compositeLayout.marginWidth = 1; + + int numColumns = 1; + boolean makeColumnsEqualWidth = true; EEFLayoutDescription layout = this.description.getLayout(); if (layout instanceof EEFFillLayoutDescription) { - // The vertical layout is the default one, we will thus only handle the horizontal one + // The vertical layout is the default one, we thus only handle the horizontal one EEFFillLayoutDescription fillLayoutDescription = (EEFFillLayoutDescription) layout; if (fillLayoutDescription.getOrientation() == EEF_FILL_LAYOUT_ORIENTATION.HORIZONTAL) { - compositeLayout = new GridLayout(this.description.getControls().size(), false); - compositeLayout.marginWidth = 1; + numColumns = this.description.getControls().size(); } } else if (layout instanceof EEFGridLayoutDescription) { EEFGridLayoutDescription gridLayoutDescription = (EEFGridLayoutDescription) layout; - compositeLayout = new GridLayout(gridLayoutDescription.getNumberOfColumns(), gridLayoutDescription.isMakeColumnsWithEqualWidth()); - compositeLayout.marginWidth = 1; + numColumns = gridLayoutDescription.getNumberOfColumns(); + makeColumnsEqualWidth = gridLayoutDescription.isMakeColumnsWithEqualWidth(); } + + GridLayout compositeLayout = new GridLayout(numColumns, makeColumnsEqualWidth); + compositeLayout.marginWidth = 1; + composite.setLayout(compositeLayout); - EEFControlSwitch eefControlSwitch = new EEFControlSwitch(this.interpreter, this.contextAdapter); List<EEFControlDescription> controls = this.description.getControls(); - for (EEFControlDescription eefControlDescription : controls) { - this.lifecycleManagers.addAll(eefControlSwitch.doCreate(composite, formContainer, eefControlDescription, this.variableManager)); + EEFControlSwitch eefControlSwitch = new EEFControlSwitch(this.interpreter, this.contextAdapter); + // Create an invisible composite for each column + for (int columnIndex = 0; columnIndex < numColumns; columnIndex++) { + Composite column = widgetFactory.createComposite(composite); + GridData columnLayoutData = new GridData(SWT.FILL, SWT.BEGINNING, true, false); + column.setLayoutData(columnLayoutData); + + // Three columns: label, help, widget + GridLayout columnLayout = new GridLayout(3, false); + column.setLayout(columnLayout); + + // Pick the right controls for the given column index in the controls flat list + for (int controlIndex = columnIndex; controlIndex < controls.size(); controlIndex += numColumns) { + EEFControlDescription eefControlDescription = controls.get(controlIndex); + this.lifecycleManagers.addAll(eefControlSwitch.doCreate(column, formContainer, eefControlDescription, this.variableManager)); + } } + } /** |