1 package org.simantics.district.network.ui.techtype.table;
5 import javax.inject.Named;
7 import org.eclipse.e4.core.di.annotations.CanExecute;
8 import org.eclipse.e4.core.di.annotations.Execute;
9 import org.eclipse.e4.ui.services.IServiceConstants;
10 import org.eclipse.jface.dialogs.MessageDialog;
11 import org.eclipse.swt.widgets.Shell;
12 import org.simantics.db.Resource;
13 import org.simantics.db.exception.DatabaseException;
14 import org.simantics.district.network.techtype.TechTypeValidationUtils;
15 import org.simantics.utils.ui.ExceptionUtils;
17 public class ValidateTechTypeTableHandler {
19 public boolean canExecute() {
20 return TechTypeTableView.table.getCurrentTable() != null;
24 public void execute(@Named(IServiceConstants.ACTIVE_SHELL) Shell s) {
25 Resource table = TechTypeTableView.table.getCurrentTable();
31 result = TechTypeValidationUtils.validateTechTypeTable(table);
32 } catch (DatabaseException e) {
33 ExceptionUtils.logAndShowError("Tech type table validation failed", e);
37 TechTypeTableView.table.setValidationResult(result);
39 MessageDialog.openInformation(s, "Validation result", result.isEmpty() ?
40 "No invalid values found" : result.size() + " invalid values found");