X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.district.network.ui%2Fsrc%2Forg%2Fsimantics%2Fdistrict%2Fnetwork%2Fui%2Ftechtype%2Ftable%2FTechTypeTableView.java;h=d66c9a8caa05be2a1d4630fedb24d9a68525e1e9;hb=refs%2Fchanges%2F08%2F4608%2F1;hp=6c25251c344da677ea4459de21be02db14533979;hpb=9ddd4d22538aa9c87a4e5f89346d41f7e48c277b;p=simantics%2Fdistrict.git diff --git a/org.simantics.district.network.ui/src/org/simantics/district/network/ui/techtype/table/TechTypeTableView.java b/org.simantics.district.network.ui/src/org/simantics/district/network/ui/techtype/table/TechTypeTableView.java index 6c25251c..d66c9a8c 100644 --- a/org.simantics.district.network.ui/src/org/simantics/district/network/ui/techtype/table/TechTypeTableView.java +++ b/org.simantics.district.network.ui/src/org/simantics/district/network/ui/techtype/table/TechTypeTableView.java @@ -13,17 +13,13 @@ import org.eclipse.e4.ui.model.application.ui.basic.MPart; 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; import org.simantics.db.Resource; import org.simantics.db.common.NamedResource; -import org.simantics.db.common.procedure.adapter.TransientCacheListener; import org.simantics.db.exception.DatabaseException; -import org.simantics.db.layer0.request.PossibleActiveModel; import org.simantics.district.network.DistrictNetworkUtil; -import org.simantics.district.network.techtype.requests.PossibleTechTypeTable; -import org.simantics.district.network.techtype.requests.PossibleTechTypeTableData; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -43,6 +39,7 @@ public class TechTypeTableView { toolBar.setToBeRendered(true); toolBar.getChildren().add(createImportCSVDataToolItem(app)); toolBar.getChildren().add(createValidateTableToolItem(app)); + toolBar.getChildren().add(createResetComponentsItem(app)); part.setToolbar(toolBar); } @@ -66,6 +63,16 @@ public class TechTypeTableView { 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; @@ -82,21 +89,7 @@ public class TechTypeTableView { LOGGER.debug("Pipe component type is {}", pipe); - String data = null; - Resource tableResource = null; - if (pipe != null) { - try { - Resource model = Simantics.getSession().syncRequest(new PossibleActiveModel(Simantics.getProjectResource())); - if (model != null) { - tableResource = Simantics.getSession().syncRequest(new PossibleTechTypeTable(model, pipe), TransientCacheListener.instance()); - data = Simantics.getSession().syncRequest(new PossibleTechTypeTableData(model, pipe), TransientCacheListener.instance()); - } - } catch (DatabaseException e) { - LOGGER.error("Failed to read tech type table data for {}", pipe, e); - } - } - - table = new TechTypeTable(parent, 0, pipe, tableResource, data); + table = new TechTypeTable(parent, 0, pipe); } @PreDestroy