Filters dialog adjustments for Boot Dash
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2015 Pivotal, Inc.
|
||||
* Copyright (c) 2015, 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.springframework.ide.eclipse.boot.dash.dialogs;
|
||||
|
||||
@@ -14,22 +14,32 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.springsource.ide.eclipse.commons.livexp.core.Validator;
|
||||
import org.springsource.ide.eclipse.commons.livexp.ui.ButtonSection;
|
||||
import org.springsource.ide.eclipse.commons.livexp.ui.CheckboxSection;
|
||||
import org.springsource.ide.eclipse.commons.livexp.ui.ChooseMultipleSection;
|
||||
import org.springsource.ide.eclipse.commons.livexp.ui.DescriptionSection;
|
||||
import org.springsource.ide.eclipse.commons.livexp.ui.DialogWithSections;
|
||||
import org.springsource.ide.eclipse.commons.livexp.ui.RowSection;
|
||||
import org.springsource.ide.eclipse.commons.livexp.ui.StringFieldSection;
|
||||
import org.springsource.ide.eclipse.commons.livexp.ui.TrayDialogWithSections;
|
||||
import org.springsource.ide.eclipse.commons.livexp.ui.WizardPageSection;
|
||||
|
||||
public class ToggleFiltersDialog extends DialogWithSections {
|
||||
public class ToggleFiltersDialog extends TrayDialogWithSections {
|
||||
|
||||
private ToggleFiltersDialogModel model;
|
||||
|
||||
public ToggleFiltersDialog(String title, ToggleFiltersDialogModel model, Shell shell) {
|
||||
super(title, model, shell);
|
||||
super(shell, model);
|
||||
this.model = model;
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Control createContents(Composite parent) {
|
||||
getShell().setText("Select Filters");
|
||||
return super.createContents(parent);
|
||||
}
|
||||
|
||||
public static void open(ToggleFiltersDialogModel model, Shell shell) {
|
||||
@@ -40,14 +50,22 @@ public class ToggleFiltersDialog extends DialogWithSections {
|
||||
@Override
|
||||
protected List<WizardPageSection> createSections() throws CoreException {
|
||||
return Arrays.asList(
|
||||
new StringFieldSection(this, "Regex to match names of the elements to be shown", model.getRegExFilterLiveVar(), Validator.OK).vertical(true),
|
||||
new CheckboxSection(this, model.getEnableRegexFilter(), "Name filter patterns (matching names will be hidden):"),
|
||||
new StringFieldSection(this,
|
||||
"Regex pattern to match names of the elements to be hidden",
|
||||
model.getRegExFilterLiveVar(),
|
||||
Validator.OK).labelUnder(true).setEnabler(model.getEnableRegexFilter()),
|
||||
new ChooseMultipleSection<>(this,
|
||||
"Filters",
|
||||
model.getAvailableFilters(),
|
||||
model.getSelectedFilters(),
|
||||
Validator.OK,
|
||||
model.getSelectedLiveVar()).vertical(true),
|
||||
new DescriptionSection(this, model.getToggleFilterDescription())
|
||||
new DescriptionSection(this, model.getToggleFilterDescription()),
|
||||
new RowSection(this,
|
||||
new ButtonSection(this, "Select All", model::selectAll),
|
||||
new ButtonSection(this, "Deselect All", model::deselectAll)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2015 Pivotal, Inc.
|
||||
* Copyright (c) 2015, 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.springframework.ide.eclipse.boot.dash.dialogs;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.springframework.ide.eclipse.boot.dash.model.ToggleFiltersModel;
|
||||
import org.springframework.ide.eclipse.boot.dash.model.ToggleFiltersModel.FilterChoice;
|
||||
import org.springsource.ide.eclipse.commons.livexp.core.LiveExpression;
|
||||
@@ -35,6 +38,8 @@ public class ToggleFiltersDialogModel implements OkButtonHandler {
|
||||
*/
|
||||
private LiveSet<FilterChoice> selectedFilters = new LiveSet<>();
|
||||
|
||||
private LiveVariable<Boolean> enableRegexFilter = new LiveVariable<>();
|
||||
|
||||
private LiveVariable<String> regexFilter = new LiveVariable<>();
|
||||
|
||||
private LiveVariable<FilterChoice> selected = new LiveVariable<>();
|
||||
@@ -51,6 +56,7 @@ public class ToggleFiltersDialogModel implements OkButtonHandler {
|
||||
this.viewModel = viewModel;
|
||||
selectedFilters.replaceAll(viewModel.getSelectedFilters().getValue());
|
||||
regexFilter = new LiveVariable<>(viewModel.getRegexFilter().getValue());
|
||||
enableRegexFilter = new LiveVariable<>(viewModel.getEnableRegexFilter().getValue());
|
||||
}
|
||||
|
||||
public FilterChoice[] getAvailableFilters() {
|
||||
@@ -77,9 +83,22 @@ public class ToggleFiltersDialogModel implements OkButtonHandler {
|
||||
return selected;
|
||||
}
|
||||
|
||||
public LiveVariable<Boolean> getEnableRegexFilter() {
|
||||
return enableRegexFilter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void performOk() throws Exception {
|
||||
viewModel.getSelectedFilters().replaceAll(selectedFilters.getValue());
|
||||
viewModel.getRegexFilter().setValue(getRegexFilter());
|
||||
viewModel.getEnableRegexFilter().setValue(enableRegexFilter.getValue());
|
||||
}
|
||||
|
||||
public void selectAll() {
|
||||
selectedFilters.replaceAll(Arrays.asList(getAvailableFilters()));
|
||||
}
|
||||
|
||||
public void deselectAll() {
|
||||
selectedFilters.replaceAll(Collections.emptyList());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2015, 2017 Pivotal, Inc.
|
||||
* Copyright (c) 2015, 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.springframework.ide.eclipse.boot.dash.model;
|
||||
|
||||
@@ -85,7 +85,7 @@ public class ToggleFiltersModel {
|
||||
public boolean accept(BootDashElement t) {
|
||||
String regex = regexFilter.getValue();
|
||||
if (t.getName() != null && StringUtils.hasText(regex)) {
|
||||
return t.getName().matches(regex);
|
||||
return !t.getName().matches(regex);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -128,6 +128,7 @@ public class ToggleFiltersModel {
|
||||
};
|
||||
|
||||
private static final String REGEX_FILTER_ID = "regexFilter";
|
||||
private static final String ENABLE_REGEX_FILTER = "enableRegexFilter";
|
||||
|
||||
private final PropertyStoreApi persistentProperties;
|
||||
|
||||
@@ -139,14 +140,16 @@ public class ToggleFiltersModel {
|
||||
this.persistentProperties = new PropertyStoreApi(propertyStore);
|
||||
this.selectedFilters = new LiveSetVariable<>(restoreFilters(), AsyncMode.SYNC);
|
||||
this.regexFilter = new LiveVariable<>(persistentProperties.get(REGEX_FILTER_ID));
|
||||
this.enableRegexFilter = new LiveVariable<>(persistentProperties.get(ENABLE_REGEX_FILTER, false));
|
||||
this.compositeFilter = new LiveExpression<Filter<BootDashElement>>() {
|
||||
{
|
||||
dependsOn(selectedFilters);
|
||||
dependsOn(regexFilter);
|
||||
dependsOn(enableRegexFilter);
|
||||
}
|
||||
@Override
|
||||
protected Filter<BootDashElement> compute() {
|
||||
Filter<BootDashElement> composed = REGEX_FILTER;
|
||||
Filter<BootDashElement> composed = enableRegexFilter.getValue().booleanValue() ? REGEX_FILTER : Filters.acceptAll();
|
||||
for (FilterChoice chosen : selectedFilters.getValues()) {
|
||||
composed = Filters.compose(composed, chosen.getFilter());
|
||||
}
|
||||
@@ -154,12 +157,21 @@ public class ToggleFiltersModel {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
selectedFilters.addListener(new ValueListener<ImmutableSet<FilterChoice>>() {
|
||||
public void gotValue(LiveExpression<ImmutableSet<FilterChoice>> exp, ImmutableSet<FilterChoice> value) {
|
||||
saveFilters(value);
|
||||
}
|
||||
});
|
||||
|
||||
enableRegexFilter.addListener((exp, v) -> {
|
||||
try {
|
||||
persistentProperties.put(ENABLE_REGEX_FILTER, exp.getValue().booleanValue());
|
||||
} catch (Exception e) {
|
||||
Log.log(e);
|
||||
}
|
||||
});
|
||||
|
||||
regexFilter.addListener((expr, v) -> {
|
||||
try {
|
||||
String value = expr.getValue();
|
||||
@@ -218,6 +230,7 @@ public class ToggleFiltersModel {
|
||||
|
||||
private final LiveSetVariable<FilterChoice> selectedFilters;
|
||||
private final LiveVariable<String> regexFilter;
|
||||
private final LiveVariable<Boolean> enableRegexFilter;
|
||||
private final LiveExpression<Filter<BootDashElement>> compositeFilter;
|
||||
|
||||
/**
|
||||
@@ -263,4 +276,7 @@ public class ToggleFiltersModel {
|
||||
public LiveVariable<String> getRegexFilter() {
|
||||
return regexFilter;
|
||||
}
|
||||
public LiveVariable<Boolean> getEnableRegexFilter() {
|
||||
return enableRegexFilter;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2015, 2019 Pivotal, Inc.
|
||||
* Copyright (c) 2015, 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.springframework.ide.eclipse.boot.dash.views;
|
||||
|
||||
@@ -188,7 +188,6 @@ public class BootDashTreeView extends ViewPartWithSections implements ITabbedPro
|
||||
manager.add(actions.getOpenInPackageExplorerAction());
|
||||
manager.add(actions.getOpenConfigAction());
|
||||
manager.add(actions.getShowPropertiesViewAction());
|
||||
manager.add(actions.getToggleFiltersDialogAction());
|
||||
|
||||
MenuUtil.addDynamicSubmenu(manager, actions.getLiveDataConnectionManagement());
|
||||
|
||||
@@ -200,6 +199,9 @@ public class BootDashTreeView extends ViewPartWithSections implements ITabbedPro
|
||||
manager.add(new Separator());
|
||||
addAddRunTargetMenuActions(manager);
|
||||
|
||||
manager.add(new Separator());
|
||||
manager.add(actions.getToggleFiltersDialogAction());
|
||||
|
||||
manager.add(new Separator());
|
||||
manager.add(actions.getOpenBootDashPreferencesAction());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user