<elements xsi:type="commands:Command" xmi:id="_QcEKQIAGEemKlokjSaREFQ" elementId="org.simantics.district.network.ui.command.importcsv" commandName="Import CSV"/>
<elements xsi:type="commands:Command" xmi:id="_VWtY8LqWEemcscVaZzEyWw" elementId="org.simantics.district.network.ui.command.importtechtypecsv" commandName="Import Tech Type CSV"/>
<elements xsi:type="commands:Command" xmi:id="_dN5OYPaJEeqB1-l6EhcCjg" elementId="org.simantics.district.network.ui.command.validatetechtypetable" commandName="Validate Tech Type Table"/>
+ <elements xsi:type="commands:Command" xmi:id="_fzvVQP2aEeqB1-l6EhcCjg" elementId="org.simantics.district.network.ui.command.resetcomponentproperties" commandName="Reset Component Properties"/>
</fragments>
<fragments xsi:type="fragment:StringModelFragment" xmi:id="_Js7rUMMAEea1mdgpHNVHMA" featurename="menuContributions" parentElementId="xpath:/">
<elements xsi:type="menu:MenuContribution" xmi:id="_T-jiEN8NEeaigNyzMJBOrg" elementId="org.simantics.district.network.ui.menucontribution.districtDiagramPopup" parentId="#DistrictDiagramPopup">
<elements xsi:type="commands:Handler" xmi:id="_akE8EIAGEemKlokjSaREFQ" elementId="org.simantics.district.network.ui.handler.9" contributionURI="bundleclass://org.simantics.district.network.ui/org.simantics.district.network.ui.table.ImportCSVHandler" command="_QcEKQIAGEemKlokjSaREFQ"/>
<elements xsi:type="commands:Handler" xmi:id="_XjbIILqWEemcscVaZzEyWw" elementId="org.simantics.district.network.ui.handler.10" contributionURI="bundleclass://org.simantics.district.network.ui/org.simantics.district.network.ui.table.ImportTechTypeCSVHandler" command="_VWtY8LqWEemcscVaZzEyWw"/>
<elements xsi:type="commands:Handler" xmi:id="_luZP0PaJEeqB1-l6EhcCjg" elementId="org.simantics.district.network.ui.handler.11" contributionURI="bundleclass://org.simantics.district.network.ui/org.simantics.district.network.ui.techtype.table.ValidateTechTypeTableHandler" command="_dN5OYPaJEeqB1-l6EhcCjg"/>
+ <elements xsi:type="commands:Handler" xmi:id="_nFUFcP2aEeqB1-l6EhcCjg" elementId="org.simantics.district.network.ui.handler.12" contributionURI="bundleclass://org.simantics.district.network.ui/org.simantics.district.network.ui.techtype.table.ResetComponentsHandler" command="_fzvVQP2aEeqB1-l6EhcCjg"/>
</fragments>
</fragment:ModelFragments>
--- /dev/null
+package org.simantics.district.network.ui.techtype.table;
+
+import javax.inject.Named;
+
+import org.eclipse.e4.core.di.annotations.CanExecute;
+import org.eclipse.e4.core.di.annotations.Execute;
+import org.eclipse.e4.ui.services.IServiceConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.swt.widgets.Shell;
+import org.simantics.db.Resource;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.district.network.techtype.TechTypeUtils;
+import org.simantics.utils.ui.ExceptionUtils;
+
+public class ResetComponentsHandler {
+
+ @CanExecute
+ public boolean canExecute() {
+ return TechTypeTableView.table.getCurrentTable() != null;
+ }
+
+ @Execute
+ public void execute(@Named(IServiceConstants.ACTIVE_SHELL) Shell s) {
+ Resource table = TechTypeTableView.table.getCurrentTable();
+ if (table == null)
+ return;
+
+ boolean result = MessageDialog.openConfirm(null, "Confirmation", "Do you really want to reset all component properties to values in this table?");
+ if (result == false)
+ return;
+
+ try {
+ TechTypeUtils.resetComponents(table);
+ } catch (DatabaseException e) {
+ ExceptionUtils.logAndShowError("Error resetting components.", e);
+ }
+ }
+
+}
import org.eclipse.e4.ui.model.application.ui.menu.MHandledToolItem;
import org.eclipse.e4.ui.model.application.ui.menu.MMenuFactory;
import org.eclipse.e4.ui.model.application.ui.menu.MToolBar;
+import org.eclipse.e4.ui.model.application.ui.menu.MToolBarElement;
import org.eclipse.e4.ui.workbench.modeling.ESelectionService;
import org.eclipse.swt.widgets.Composite;
import org.simantics.Simantics;
toolBar.setToBeRendered(true);
toolBar.getChildren().add(createImportCSVDataToolItem(app));
toolBar.getChildren().add(createValidateTableToolItem(app));
+ toolBar.getChildren().add(createResetComponentsItem(app));
part.setToolbar(toolBar);
}
return createHandledToolItem;
}
+ private MToolBarElement createResetComponentsItem(MApplication app) {
+ MHandledToolItem createHandledToolItem = MMenuFactory.INSTANCE.createHandledToolItem();
+ // Command is contributed via fragment
+ MCommand command = app.getCommand("org.simantics.district.network.ui.command.resetcomponentproperties");
+ createHandledToolItem.setCommand(command); //$NON-NLS-1$
+ createHandledToolItem.setLabel("Reset Component Properties");
+ createHandledToolItem.setIconURI("platform:/plugin/com.famfamfam.silk/icons/database_go.png"); //$NON-NLS-1$
+ return createHandledToolItem;
+ }
+
@PostConstruct
public void postConstruct(Composite parent) {
Resource pipe = null;