]> gerrit.simantics Code Review - simantics/district.git/blobdiff - org.simantics.district.network.ui/src/org/simantics/district/network/ui/techtype/table/TechTypeTableView.java
First testing version of TechTypeTable
[simantics/district.git] / org.simantics.district.network.ui / src / org / simantics / district / network / ui / techtype / table / TechTypeTableView.java
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
new file mode 100644 (file)
index 0000000..cdb502c
--- /dev/null
@@ -0,0 +1,53 @@
+package org.simantics.district.network.ui.techtype.table;
+
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.inject.Inject;
+
+import org.eclipse.e4.ui.model.application.MApplication;
+import org.eclipse.e4.ui.model.application.commands.MCommand;
+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.workbench.modeling.ESelectionService;
+import org.eclipse.swt.widgets.Composite;
+
+public class TechTypeTableView {
+
+       @Inject ESelectionService selectionService;
+
+       public static TechTypeTable table;
+
+       @Inject
+       public void init(MPart part, MApplication app) {
+               MToolBar toolBar = MMenuFactory.INSTANCE.createToolBar();
+               toolBar.setToBeRendered(true);
+               toolBar.getChildren().add(createImportCSVDataToolItem(app));
+               part.setToolbar(toolBar);
+       }
+
+       private MHandledToolItem createImportCSVDataToolItem(MApplication app) {
+               MHandledToolItem createHandledToolItem = MMenuFactory.INSTANCE.createHandledToolItem();
+               // Command is contributed via fragment
+               MCommand command = app.getCommand("org.simantics.district.network.ui.command.importtechtypecsv");
+               createHandledToolItem.setCommand(command); //$NON-NLS-1$
+               createHandledToolItem.setLabel("Import Tech Type");
+               createHandledToolItem.setIconURI("platform:/plugin/com.famfamfam.silk/icons/table_edit.png"); //$NON-NLS-1$
+               return createHandledToolItem;
+       }
+
+       @PostConstruct
+       public void postConstruct(Composite parent) {
+               table = new TechTypeTable(parent, 0);
+               
+       }
+       
+       @PreDestroy
+       public void dispose() {
+               table.dispose();
+               table = null;
+       }
+
+}