]> gerrit.simantics Code Review - simantics/district.git/blob
cdb502c3c5a870ddc887f240a8c6c185173d055d
[simantics/district.git] /
1 package org.simantics.district.network.ui.techtype.table;
2
3
4 import javax.annotation.PostConstruct;
5 import javax.annotation.PreDestroy;
6 import javax.inject.Inject;
7
8 import org.eclipse.e4.ui.model.application.MApplication;
9 import org.eclipse.e4.ui.model.application.commands.MCommand;
10 import org.eclipse.e4.ui.model.application.ui.basic.MPart;
11 import org.eclipse.e4.ui.model.application.ui.menu.MHandledToolItem;
12 import org.eclipse.e4.ui.model.application.ui.menu.MMenuFactory;
13 import org.eclipse.e4.ui.model.application.ui.menu.MToolBar;
14 import org.eclipse.e4.ui.workbench.modeling.ESelectionService;
15 import org.eclipse.swt.widgets.Composite;
16
17 public class TechTypeTableView {
18
19         @Inject ESelectionService selectionService;
20
21         public static TechTypeTable table;
22
23         @Inject
24         public void init(MPart part, MApplication app) {
25                 MToolBar toolBar = MMenuFactory.INSTANCE.createToolBar();
26                 toolBar.setToBeRendered(true);
27                 toolBar.getChildren().add(createImportCSVDataToolItem(app));
28                 part.setToolbar(toolBar);
29         }
30
31         private MHandledToolItem createImportCSVDataToolItem(MApplication app) {
32                 MHandledToolItem createHandledToolItem = MMenuFactory.INSTANCE.createHandledToolItem();
33                 // Command is contributed via fragment
34                 MCommand command = app.getCommand("org.simantics.district.network.ui.command.importtechtypecsv");
35                 createHandledToolItem.setCommand(command); //$NON-NLS-1$
36                 createHandledToolItem.setLabel("Import Tech Type");
37                 createHandledToolItem.setIconURI("platform:/plugin/com.famfamfam.silk/icons/table_edit.png"); //$NON-NLS-1$
38                 return createHandledToolItem;
39         }
40
41         @PostConstruct
42         public void postConstruct(Composite parent) {
43                 table = new TechTypeTable(parent, 0);
44                 
45         }
46         
47         @PreDestroy
48         public void dispose() {
49                 table.dispose();
50                 table = null;
51         }
52
53 }