Filters dialog adjustments for Boot Dash

This commit is contained in:
BoykoAlex
2021-05-21 11:52:55 -04:00
parent 6945fe18fc
commit 9cc82fd598
10 changed files with 345 additions and 40 deletions

View File

@@ -1,12 +1,12 @@
/*******************************************************************************
* Copyright (c) 2016 Pivotal, Inc.
* Copyright (c) 2016, 2021 VMware, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Pivotal, Inc. - initial API and implementation
* VMware, Inc. - initial API and implementation
*******************************************************************************/
package org.springsource.ide.eclipse.commons.livexp.ui;
@@ -16,6 +16,7 @@ import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.springsource.ide.eclipse.commons.livexp.Activator;
@@ -84,7 +85,9 @@ public class ButtonSection extends WizardPageSection {
* method to change the layout.
*/
protected void applyLayoutData(Button button) {
GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(button);
if (button.getParent().getLayout() instanceof GridLayout) {
GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(button);
}
}
public ButtonSection setEnabler(LiveExpression<Boolean> enabler) {

View File

@@ -128,17 +128,19 @@ public class ChooseMultipleSection<T extends Ilabelable> extends WizardPageSecti
});
}
if (DEBUG) {
chosen.addListener(new ValueListener<Set<T>>() {
public void gotValue(LiveExpression<Set<T>> exp, Set<T> value) {
chosen.addListener(new ValueListener<Set<T>>() {
public void gotValue(LiveExpression<Set<T>> exp, Set<T> value) {
Set<T> values = exp.getValue();
tv.setCheckedElements(values.toArray());
if (DEBUG) {
System.out.println(">>>> starters");
for (T e : value) {
System.out.println(e.getLabel());
}
System.out.println("<<<< starters");
}
});
}
}
});
}

View File

@@ -0,0 +1,61 @@
/*******************************************************************************
* Copyright (c) 2021 VMware, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* VMware, Inc. - initial API and implementation
*******************************************************************************/
package org.springsource.ide.eclipse.commons.livexp.ui;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Composite;
import org.springsource.ide.eclipse.commons.livexp.core.CompositeValidator;
import org.springsource.ide.eclipse.commons.livexp.core.LiveExpression;
import org.springsource.ide.eclipse.commons.livexp.core.ValidationResult;
public class RowSection extends WizardPageSection {
private IPageSection[] sections;
private CompositeValidator validator;
public RowSection(IPageWithSections owner, IPageSection... sections) {
super(owner);
this.sections = sections;
}
@Override
public void createContents(Composite page) {
Composite c = new Composite(page, SWT.NONE);
GridDataFactory.fillDefaults().grab(false, false).applyTo(c);
RowLayout layout = new RowLayout(SWT.HORIZONTAL);
layout.pack = false;
c.setLayout(layout);
validator = new CompositeValidator();
for (IPageSection s : sections) {
s.createContents(c);
validator.addChild(s.getValidator());
}
}
@Override
public void dispose() {
for (IPageSection s : sections) {
if (s instanceof Disposable) {
((Disposable) s).dispose();
}
}
super.dispose();
}
@Override
public LiveExpression<ValidationResult> getValidator() {
return validator;
}
}

View File

@@ -1,12 +1,12 @@
/*******************************************************************************
* Copyright (c) 2013 Pivotal Software, Inc.
* Copyright (c) 2013, 2021 VMware Software, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Pivotal Software, Inc. - initial API and implementation
* Pivotal VMware, Inc. - initial API and implementation
*******************************************************************************/
package org.springsource.ide.eclipse.commons.livexp.ui;
@@ -43,6 +43,8 @@ public class StringFieldSection extends WizardPageSection {
private boolean password = false;
private boolean vertical = false;
private boolean labelUnder = false;
//////////////////////////////
@@ -64,6 +66,15 @@ public class StringFieldSection extends WizardPageSection {
return this;
}
/**
* Should be called before createContents(...) is called, i.e. before SWT controls are created.
*/
public StringFieldSection labelUnder(boolean under) {
this.labelUnder = under;
this.vertical = under || this.vertical;
return this;
}
public StringFieldSection(IPageWithSections owner, FieldModel<String> f) {
this(owner, f.getLabel(), f.getVariable(), f.getValidator());
}
@@ -85,6 +96,20 @@ public class StringFieldSection extends WizardPageSection {
return this;
}
private Label createLabel(Composite projectGroup) {
Label label = new Label(projectGroup, SWT.NONE);
label.setText(labelText);
GridDataFactory.fillDefaults()
.hint(vertical ? SWT.DEFAULT : UIConstants.fieldLabelWidthHint(label), SWT.DEFAULT)
.align(SWT.BEGINNING, SWT.CENTER)
.applyTo(label);
if (tooltip!=null) {
label.setToolTipText(tooltip);
text.setToolTipText(tooltip);
}
return label;
}
@Override
public void createContents(Composite page) {
// project specification group
@@ -95,17 +120,19 @@ public class StringFieldSection extends WizardPageSection {
projectGroup.setLayout(layout);
projectGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
Label label = new Label(projectGroup, SWT.NONE);
label.setText(labelText);
GridDataFactory.fillDefaults()
.hint(vertical ? SWT.DEFAULT : UIConstants.fieldLabelWidthHint(label), SWT.DEFAULT)
.align(SWT.BEGINNING, SWT.CENTER)
.applyTo(label);
if (!labelUnder) {
createLabel(projectGroup);
}
text = new Text(projectGroup, SWT.BORDER | (password ? SWT.PASSWORD : 0));
GridData data = new GridData(GridData.FILL_HORIZONTAL);
data.widthHint = UIConstants.FIELD_TEXT_AREA_WIDTH;
text.setLayoutData(data);
if (labelUnder) {
createLabel(projectGroup);
}
text.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
variable.setValue(text.getText());
@@ -125,10 +152,6 @@ public class StringFieldSection extends WizardPageSection {
enabler.addListener(UIValueListener.from((exp, enable) -> {
text.setEnabled(enable);
}));
if (tooltip!=null) {
label.setToolTipText(tooltip);
text.setToolTipText(tooltip);
}
}
public StringFieldSection tooltip(String string) {

View File

@@ -0,0 +1,162 @@
/*******************************************************************************
* Copyright (c) 2021 VMware, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* VMware, Inc. - initial API and implementation
*******************************************************************************/
package org.springsource.ide.eclipse.commons.livexp.ui;
import java.util.Arrays;
import java.util.List;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.dialogs.TrayDialog;
import org.eclipse.jface.operation.IRunnableContext;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.forms.widgets.SharedScrolledComposite;
import org.eclipse.ui.progress.UIJob;
import org.springsource.ide.eclipse.commons.livexp.Activator;
import org.springsource.ide.eclipse.commons.livexp.core.Validator;
import org.springsource.ide.eclipse.commons.livexp.util.ExceptionUtil;
public class TrayDialogWithSections extends TrayDialog implements IPageWithSections, Reflowable {
private OkButtonHandler model;
private SharedScrolledComposite scroller;
private List<WizardPageSection> sections = null;
protected TrayDialogWithSections(Shell shell, OkButtonHandler model) {
super(shell);
this.model = model;
}
protected Control createDialogArea(Composite parent) {
scroller = new SharedScrolledComposite(parent, SWT.V_SCROLL | SWT.H_SCROLL) {};
scroller.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
scroller.setExpandHorizontal(true);
scroller.setExpandVertical(true);
Composite page = new Composite(scroller, SWT.NONE);
applyDialogFont(page);
GridLayout layout = new GridLayout(1, false);
layout.marginHeight = 12;
layout.marginWidth = 12;
page.setLayout(layout);
for (PageSection section : getSections()) {
section.createContents(page);
}
page.pack(true);
scroller.setContent(page);
return parent;
}
private UIJob reflowJob;
@Override
public boolean reflow() {
if (reflowJob==null) {
reflowJob = new UIJob(Display.getDefault(), "Reflow Wizard Contents") {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
if (scroller!=null && !scroller.isDisposed()) {
scroller.reflow(true);
}
return Status.OK_STATUS;
}
};
reflowJob.setSystem(true);
}
reflowJob.schedule();
return true;
}
protected synchronized List<WizardPageSection> getSections() {
if (sections==null) {
sections = safeCreateSections();
}
return sections;
}
private List<WizardPageSection> safeCreateSections() {
try {
return createSections();
} catch (CoreException e) {
Activator.log(e);
return Arrays.asList(
new CommentSection(this, "Dialog couldn't be created because of an unexpected error:+\n"+ExceptionUtil.getMessage(e)+"\n\n"
+ "Check the error log for details"),
new ValidatorSection(Validator.alwaysError(ExceptionUtil.getMessage(e)), this)
);
}
}
/**
* This method should be implemented to generate the contents of the page.
*/
protected List<WizardPageSection> createSections() throws CoreException {
//This default implementation is meant to be overridden
return Arrays.asList(
new CommentSection(this, "Override DialogWithSections.createSections() to provide real content."),
new ValidatorSection(Validator.alwaysError("Subclass must implement validation logic"), this)
);
}
public void dispose() {
for (WizardPageSection s : sections) {
s.dispose();
}
}
@Override
protected void cancelPressed() {
super.cancelPressed();
}
@Override
protected final void okPressed() {
super.okPressed();
try {
model.performOk();
} catch (Exception e) {
Activator.log(e);
MessageDialog.openError(getShell(), "Error", ExceptionUtil.getMessage(e));
}
}
/**
* Simulate clicking the ok button. Does nothing if ok button is not found or disabled.
*/
public boolean clickOk() {
Button button = getButton(OK);
if (button!=null && button.isEnabled()) {
okPressed();
return true;
}
return false;
}
@Override
public IRunnableContext getRunnableContext() {
return PlatformUI.getWorkbench().getProgressService();
}
}

View File

@@ -1,12 +1,12 @@
/*******************************************************************************
* Copyright (c) 2017, 2019 Pivotal, Inc.
* Copyright (c) 2017, 2021 VMware, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Pivotal, Inc. - initial API and implementation
* VMware, Inc. - initial API and implementation
*******************************************************************************/
package org.springsource.ide.eclipse.commons.livexp.ui.util;
@@ -87,7 +87,6 @@ public class SwtConnect {
control.addDisposeListener(de -> enabler.dispose());
Disposable disconnect = enabler.onChange(UIValueListener.from((e,v) -> {
control.setEnabled(e.getValue());
System.out.println("Apply enablement changed: " + e.getValue());
}));
control.addDisposeListener(de -> disconnect.dispose());
}