1 package org.simantics.district.network.ui.techtype.table;
3 import javax.inject.Named;
5 import org.eclipse.e4.core.di.annotations.CanExecute;
6 import org.eclipse.e4.core.di.annotations.Execute;
7 import org.eclipse.e4.ui.services.IServiceConstants;
8 import org.eclipse.jface.dialogs.MessageDialog;
9 import org.eclipse.swt.widgets.Shell;
10 import org.simantics.db.Resource;
11 import org.simantics.db.exception.DatabaseException;
12 import org.simantics.district.network.techtype.TechTypeUtils;
13 import org.simantics.utils.ui.ExceptionUtils;
15 public class ResetComponentsHandler {
18 public boolean canExecute() {
19 return TechTypeTableView.table.getCurrentTable() != null;
23 public void execute(@Named(IServiceConstants.ACTIVE_SHELL) Shell s) {
24 Resource table = TechTypeTableView.table.getCurrentTable();
28 boolean result = MessageDialog.openConfirm(null, "Confirmation", "Do you really want to reset all component properties to values in this table?");
33 TechTypeUtils.resetComponents(table);
34 } catch (DatabaseException e) {
35 ExceptionUtils.logAndShowError("Error resetting components.", e);