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 @@ -2,6 +2,8 @@ Abstracttableview_transformation_progress=Tabelle wird erzeugt

ToolboxTableView_Export=Exportieren
ToolboxTableView_ExportTable=Export der Einzeltabelle
ToolboxTableView_TableIncompleteHint=Diese Tabelle ist unvollständig, da noch nicht alle anderen Tabellen generiert wurden.
ToolboxTableView_CalculateTables=Tabellen berechnen

ESTW_TableOverviewDescriptionService_ViewName=ESTW – Tabellenübersicht
ETCS_TableOverviewDescriptionService_ViewName=ETCS – Tabellenübersicht
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.eclipse.emf.common.command.CommandStackListener;
import org.eclipse.emf.common.util.ECollections;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.GridLayoutFactory;
import org.eclipse.nebula.widgets.nattable.NatTable;
import org.eclipse.nebula.widgets.nattable.config.ConfigRegistry;
import org.eclipse.nebula.widgets.nattable.data.IDataProvider;
Expand Down Expand Up @@ -75,6 +76,7 @@
import org.eclipse.set.feature.table.abstracttableview.ColumnGroupGroupGroupHeaderLayer;
import org.eclipse.set.feature.table.abstracttableview.NatTableColumnGroupHelper;
import org.eclipse.set.feature.table.abstracttableview.ToolboxTableModelThemeConfiguration;
import org.eclipse.set.feature.table.internal.TableServiceUtils;
import org.eclipse.set.feature.table.messages.Messages;
import org.eclipse.set.feature.table.messages.MessagesWrapper;
import org.eclipse.set.model.planpro.Basisobjekte.Ur_Objekt;
Expand Down Expand Up @@ -124,9 +126,12 @@
import org.eclipse.swt.custom.StyleRange;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.osgi.service.event.EventHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -153,6 +158,8 @@ public final class ToolboxTableView extends BasePart {
static final Logger logger = LoggerFactory
.getLogger(ToolboxTableView.class);

private Composite calculateMissingTablesPanel;

private BodyLayerStack bodyLayerStack;

@Inject
Expand Down Expand Up @@ -333,6 +340,7 @@ public void accept(final SelectedControlAreaChangedEvent t) {
return;
}
updateModel(getToolboxPart());
updateCalculateMissingTablesPanel();
natTable.refresh();
};
getBroker().subscribe(Events.RELOAD_WORKNOTES_TABLE,
Expand Down Expand Up @@ -444,6 +452,11 @@ protected void createView(final Composite parent) {
return;
}

if (tableInfo.shortcut()
.equalsIgnoreCase(ToolboxConstants.WORKNOTES_TABLE_SHORTCUT)) {
this.addCalculateMissingTablesPanel(parent);
}

final ColumnDescriptor rootColumnDescriptor = table
.getColumndescriptors()
.get(0);
Expand Down Expand Up @@ -780,6 +793,77 @@ protected ColumnGroup4HeaderLayer createGroupHeaderLayer(
return columnGroup4HeaderLayer;
}

private Collection<TableInfo> getMissingTables() {
return TableServiceUtils.getMissingTables(tableService,
getModelSession(), controlAreaIds);
}

private void calculateAllMissingTables(final IProgressMonitor monitor) {
TableServiceUtils.calculateAllMissingTables(tableService,
getModelSession(), controlAreaIds, monitor, messages);
}

private void calculateAllMissingTablesEvent() {
try {
getDialogService().showProgress(getToolboxShell(),
this::calculateAllMissingTables);
} catch (InvocationTargetException | InterruptedException e) {
getDialogService().error(getToolboxShell(), e);
}
updateCalculateMissingTablesPanel();
}

private void addCalculateMissingTablesPanel(final Composite parent) {
if (getMissingTables().size() == 0) {
return;
}
// custom panel
final Composite panel = new Composite(parent, SWT.CENTER);
GridLayoutFactory.fillDefaults().numColumns(2).applyTo(panel);
final Label label = new Label(panel, SWT.LEFT);
GridDataFactory.fillDefaults()
.align(SWT.BEGINNING, SWT.CENTER)
.grab(true, false)
.applyTo(label);
label.setText(messages.ToolboxTableView_TableIncompleteHint);
final Button button = new Button(panel, SWT.None);
GridDataFactory.swtDefaults()
.align(SWT.END, SWT.FILL)
.grab(true, false)
.applyTo(button);
button.setText(messages.ToolboxTableView_CalculateTables);
button.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(final SelectionEvent e) {
calculateAllMissingTablesEvent();
}

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

panel.setBackground(
Display.getCurrent().getSystemColor(SWT.COLOR_YELLOW));

calculateMissingTablesPanel = panel;
updateCalculateMissingTablesPanel();
}

private void updateCalculateMissingTablesPanel() {
if (calculateMissingTablesPanel == null) {
return;
}
if (getMissingTables().size() == 0) {
final Composite parent = calculateMissingTablesPanel.getParent();
calculateMissingTablesPanel.dispose();
parent.layout(true, true);
parent.update();
calculateMissingTablesPanel = null;
}
}

@Override
protected SelectableAction getOutdatedAction() {
return new RefreshAction(this, e -> outdatedUpdate());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,8 @@ public Map<TableInfo, Collection<TableError>> getTableErrors(
final Pt1TableCategory tableCategory) {
final HashMap<TableInfo, Collection<TableError>> result = new HashMap<>();
getAvailableTables().forEach(tableInfo -> {
if (tableInfo.category().equals(tableCategory)) {
if (tableCategory == null
|| tableInfo.category().equals(tableCategory)) {
final List<TableError> tableErrors = TableServiceUtils
.getCachedTableError(getCacheService(), tableInfo,
modelSession, controlAreaIds);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,26 @@
import static org.eclipse.set.ppmodel.extensions.StellBereichExtensions.getStellBereich;
import static org.eclipse.set.ppmodel.extensions.StellBereichExtensions.isInControlArea;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.function.BiConsumer;
import java.util.function.Function;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.set.basis.IModelSession;
import org.eclipse.set.basis.cache.Cache;
import org.eclipse.set.basis.constants.ContainerType;
import org.eclipse.set.basis.constants.TableType;
import org.eclipse.set.basis.constants.ToolboxConstants;
import org.eclipse.set.core.services.cache.CacheService;
import org.eclipse.set.feature.table.messages.Messages;
import org.eclipse.set.model.planpro.Ansteuerung_Element.Stell_Bereich;
import org.eclipse.set.model.planpro.Basisobjekte.Ur_Objekt;
import org.eclipse.set.model.planpro.Block.Block_Anlage;
Expand All @@ -48,6 +54,8 @@
import org.eclipse.set.ppmodel.extensions.StellBereichExtensions;
import org.eclipse.set.ppmodel.extensions.UrObjectExtensions;
import org.eclipse.set.ppmodel.extensions.container.MultiContainer_AttributeGroup;
import org.eclipse.set.services.table.TableService;
import org.eclipse.set.utils.ToolboxConfiguration;
import org.eclipse.set.utils.table.TableError;
import org.eclipse.set.utils.table.TableInfo;
import org.eclipse.set.utils.table.TableInfo.Pt1TableCategory;
Expand Down Expand Up @@ -128,6 +136,119 @@ protected static List<TableError> getCachedTableError(
getObj, controlAreaIds, modelSession, null);
}

/**
* Provides a list of all not yet generated tables.
*
* @param tableService
* the table service to fetch available tables
* @param modelSession
* the current model session
* @param controlAreaIds
* the set of control area id's
* @return list of tables that are not yet generated
*/
public static Collection<TableInfo> getMissingTables(
final TableService tableService, final IModelSession modelSession,
final Set<String> controlAreaIds) {
return getMissingTables(tableService, modelSession, controlAreaIds,
null);
}

/**
* Provides a list of all not yet generated tables.
*
* @param tableService
* the table service to fetch available tables
* @param modelSession
* the current model session
* @param controlAreaIds
* the set of control area id's
* @param tableCategory
* an optional table category to only calculate tables of this
* category. Provide null if this filter shall not be applied
* @return list of tables that are not yet generated
*/
public static Collection<TableInfo> getMissingTables(
final TableService tableService, final IModelSession modelSession,
final Set<String> controlAreaIds,
final Pt1TableCategory tableCategory) {
final Map<TableInfo, Collection<TableError>> computedErrors = tableService
.getTableErrors(modelSession, controlAreaIds, tableCategory);
final Collection<TableInfo> allTableInfos = tableService
.getAvailableTables()
.stream()
.filter(table -> tableCategory == null
|| table.category().equals(tableCategory))
.toList();

final ArrayList<TableInfo> missingTables = new ArrayList<>();
missingTables.addAll(allTableInfos);
if (!ToolboxConfiguration.isDebugMode()) {
// in debug mode we want to be able to recompute the errors
// that's why we mark all as missing
missingTables
.removeIf(info -> computedErrors.keySet().contains(info));
}
return missingTables;
}

/**
* Generates all not yet generated tables.
*
* @param tableService
* the table service to fetch not yet generated tables tables
* @param modelSession
* the current model session
* @param controlAreaIds
* the set of control area id's
* @param monitor
* the monitor to display progress
* @param messages
* the translated messages for displaying in the progress monitor
*/
public static void calculateAllMissingTables(
final TableService tableService, final IModelSession modelSession,
final Set<String> controlAreaIds, final IProgressMonitor monitor,
final Messages messages) {
calculateAllMissingTables(tableService, modelSession, controlAreaIds,
null, monitor, messages);
}

/**
* Generates all not yet generated tables.
*
* @param tableService
* the table service to fetch not yet generated tables tables
* @param modelSession
* the current model session
* @param controlAreaIds
* the set of control area id's
* @param tableCategory
* an optional table category to only calculate tables of this
* category. Provide null if this filter shall not be applied
* @param monitor
* the monitor to display progress
* @param messages
* the translated messages for displaying in the progress monitor
*/
public static void calculateAllMissingTables(
final TableService tableService, final IModelSession modelSession,
final Set<String> controlAreaIds,
final Pt1TableCategory tableCategory,
final IProgressMonitor monitor, final Messages messages) {
final Collection<TableInfo> missingTables = getMissingTables(
tableService, modelSession, controlAreaIds, tableCategory);
monitor.beginTask(messages.TableOverviewPart_CalculateMissingTask,
missingTables.size());
if (!modelSession.isSingleState()) {
tableService.transformTables(monitor, new HashSet<>(missingTables),
TableType.DIFF, controlAreaIds);
} else {
tableService.transformTables(monitor, new HashSet<>(missingTables),
TableType.SINGLE, controlAreaIds);
}
}

protected static Table filterRequestValue(final Table table,
final TableInfo tableInfo, final TableType tableType,
final IModelSession modelsession,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,17 @@ public class Messages {
*/
public String ToolboxTableView_ExportTable;

/**
* Diese Tabelle ist unvollständig, da noch nicht alle anderen Tabellen
* generiert wurden.
*/
public String ToolboxTableView_TableIncompleteHint;

/**
* Tabellen berechnen
*/
public String ToolboxTableView_CalculateTables;

/**
* Tabellenexport
*/
Expand Down
Loading
Loading