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
Expand Up @@ -74,6 +74,7 @@ Import-Package: jakarta.annotation,
org.eclipse.set.utils.widgets,
org.eclipse.swt,
org.eclipse.swt.events,
org.eclipse.swt.layout,
org.eclipse.swt.widgets,
org.locationtech.jts.geom;version="1.19.0",
org.osgi.service.component.annotations,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ PlazModellPart_ExportTitleMsg=Export als CSV
PlazModellPart_ExportCsvFileName=PlaZ-Modell
PlazModellPart_ExpandAllGroup= Alle ausklappen
PlazModellPart_CollapseAllGroup= Alle einklappen

PlazModellPart_ActiveDefaultFilterCheckbox=Ausblenden technische Meldungen
PlazReportColumns_Severity = Schweregrad
PlazReportColumns_ProblemType = Problemart
PlazReportColumns_LineNumber = Zeilennummer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,9 @@ public class Messages {
*/
public String PlazExport_ExportProcess_ErrorDialog_Message;

/**
* Ausblenden technische Meldungen
*/
public String PlazModellPart_ActiveDefaultFilterCheckbox;

}
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ public String getText() {
}
});

tableView.createActiveDefaultFilterCheckBox(
(Composite) getBanderole().getControl());
tableView.createExpandCollapseAllButton(
(Composite) getBanderole().getControl(),
messages.PlazModellPart_ExpandAllGroup,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
package org.eclipse.set.feature.plazmodel.table;

import java.nio.file.Path;
import java.util.Map;

import org.eclipse.nebula.widgets.nattable.NatTable;
import org.eclipse.set.basis.ToolboxPaths.ExportPathExtension;
Expand All @@ -22,8 +23,14 @@
import org.eclipse.set.utils.table.menu.TableMenuService;
import org.eclipse.set.utils.table.tree.AbstractTreeLayerTable;
import org.eclipse.set.utils.xml.XMLNodeFinder;
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.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;

/**
* View for the validation table
Expand Down Expand Up @@ -142,4 +149,42 @@ public void exportCsv() {
exportCsv(part.getToolboxShell(), part.getDialogService(),
messages.PlazModellPart_ExportTitleMsg, exportFileName);
}

@Override
protected Map<Integer, Object> getDefaultFilterValue() {
return Map.of(Integer.valueOf(2), "-GUID-Sortierung"); //$NON-NLS-1$
}

/**
* IMPROVE: when reimplementation the filter to like excel then the check
* box here can be removed
*
* @param parent
* the parent composite
*/
public void createActiveDefaultFilterCheckBox(final Composite parent) {
final Composite composite = new Composite(parent, SWT.NONE);
// Empty
final Composite space = new Composite(parent, SWT.NONE);
space.setLayout(new GridLayout());
composite.setLayout(new GridLayout(2, false));
final Button checkDefaultFilterButton = new Button(composite,
SWT.CHECK);
checkDefaultFilterButton.setSelection(true);
final Label checkDefaultFilterLabel = new Label(composite, SWT.NONE);
checkDefaultFilterLabel
.setText(messages.PlazModellPart_ActiveDefaultFilterCheckbox);
checkDefaultFilterButton.addSelectionListener(new SelectionListener() {

@Override
public void widgetSelected(final SelectionEvent e) {
widgetDefaultSelected(e);
}

@Override
public void widgetDefaultSelected(final SelectionEvent e) {
setDefaultFilterState(checkDefaultFilterButton.getSelection());
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
package org.eclipse.set.feature.validation.table;

import java.nio.file.Path;
import java.util.Collections;
import java.util.Map;

import org.eclipse.nebula.widgets.nattable.NatTable;
import org.eclipse.set.basis.ToolboxPaths.ExportPathExtension;
Expand Down Expand Up @@ -136,4 +138,9 @@ public void exportCsv() {
exportCsv(shell, part.getDialogService(),
messages.ExportValidationTitleMsg, exportFileName);
}

@Override
protected Map<Integer, Object> getDefaultFilterValue() {
return Collections.emptyMap();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ class TableDataProvider implements IDataProvider {
].filter[filterMatch].toList
}

def Map<Integer, Object> getCurrentFilters() {
return filters
}

/**
* Checks whether a row fulfils the applied filters
*
Expand All @@ -75,15 +79,19 @@ class TableDataProvider implements IDataProvider {
for (var i = 0; i < columnCount; i++) {
if (filters.containsKey(i)) {
val content = row.contents.get(i).plainStringValue.toLowerCase
var filterValue = filters.get(i).toString.toLowerCase
val isExcludeFilter = filterValue.substring(0, 1).equals(
EXCULDE_FILTER_SIGN)
filterValue = isExcludeFilter ? filterValue.
substring(1) : filterValue

// Equivalence logic
if (isExcludeFilter === content.contains(filterValue)) {
return false
var filterValues = filters.get(i).toString.split(",")
for (v : filterValues) {
if (!v.nullOrEmpty) {
val isExcludeFilter = v.substring(0, 1).equals(
EXCULDE_FILTER_SIGN)
var value = isExcludeFilter ? v.substring(1) : v

// Equivalence logic
if (isExcludeFilter ===
content.contains(value.toLowerCase)) {
return false
}
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

package org.eclipse.set.utils.table.tree;

import java.util.HashMap;
import java.util.Map;
import java.util.function.UnaryOperator;

Expand Down Expand Up @@ -50,6 +51,9 @@ public abstract class AbstractTreeLayerTable
*/
protected TreeLayer treeLayer;

private boolean activeDefaultFilter = true;
protected IFilterStrategy<Object> treeFilterStrategy;

@Override
protected void createTableBodyData(final Table table,
final UnaryOperator<Integer> getSourceLine) {
Expand Down Expand Up @@ -84,6 +88,7 @@ public boolean doCommand(final ILayerCommand command) {
}
};
// Collapse all group by default
bodyDataProvider.applyFilter(getDefaultFilterValue());
treeLayer.doCommand(new TreeCollapseAllCommand());
}

Expand Down Expand Up @@ -117,10 +122,36 @@ public void applyFilter(
// The hidden rows list in {@link TreeDataProvider} will not be
// change by direct call expland-collapse function
layer.expandAll();
treeDataProvider.applyFilter(filterIndexToObjectMap);

treeDataProvider
.applyFilter(getFilterObjectMap(filterIndexToObjectMap));
treeLayer.doCommand(new TreeCollapseAllCommand());
}

private Map<Integer, Object> getFilterObjectMap(
final Map<Integer, Object> filterIndexToObjectMap) {
final HashMap<Integer, Object> result = new HashMap<>(
filterIndexToObjectMap);
if (activeDefaultFilter) {
getDefaultFilterValue()
.forEach((key, value) -> result.compute(key, (k, v) -> {
if (v == null) {
return value;
}
return v.toString() + "," + value.toString(); //$NON-NLS-1$
}));
} else {
getDefaultFilterValue().forEach((key, value) -> {
final Object restFilter = result.computeIfPresent(key, (k,
v) -> v.toString().replace(value.toString(), "")); //$NON-NLS-1$
if (restFilter.toString().isEmpty()) {
result.remove(key);
}
});
}
return result;
}

}

@Override
Expand All @@ -129,8 +160,9 @@ protected FilterRowHeaderComposite<Object> createFilterRowHeader(
final DataLayer columnHeaderDataLayer,
final ConfigRegistry configRegistry) {
if (bodyDataProvider instanceof final TreeDataProvider treeDataProvider) {
return new FilterRowHeaderComposite<>(
new TreeFilterStrategy<>(treeLayer, treeDataProvider),
treeFilterStrategy = new TreeFilterStrategy<>(treeLayer,
treeDataProvider);
return new FilterRowHeaderComposite<>(treeFilterStrategy,
sortHeaderLayer, columnHeaderDataLayer.getDataProvider(),
configRegistry);
}
Expand All @@ -140,7 +172,7 @@ protected FilterRowHeaderComposite<Object> createFilterRowHeader(
}

/**
* Creat button to toogle expand and collapse all group
* Create button to toggle expand and collapse all group
*
* @param parent
* the parent
Expand Down Expand Up @@ -197,4 +229,19 @@ private void toggleExpandCollapseAll(final Button button,
button.setText(expandAllLabel);
}
}

protected abstract Map<Integer, Object> getDefaultFilterValue();

/**
* @param state
* should active filter for default value
*/
public void setDefaultFilterState(final boolean state) {
activeDefaultFilter = state;
if (treeFilterStrategy != null) {
treeFilterStrategy
.applyFilter(bodyDataProvider.getCurrentFilters());
}
}

}
Loading