package org.simantics.district.network.ui.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.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 DistrictCSVTableView { @Inject ESelectionService selectionService; private DistrictCSVTable 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 createHandledToolItem.setCommand(app.getCommand("org.simantics.district.network.ui.command.importcsv")); //$NON-NLS-1$ createHandledToolItem.setLabel("Import CSV"); createHandledToolItem.setIconURI("platform:/plugin/com.famfamfam.silk/icons/table_edit.png"); //$NON-NLS-1$ return createHandledToolItem; } @PostConstruct public void postConstruct(Composite parent) { table = new DistrictCSVTable(parent, 0); } @PreDestroy public void dispose() { table.dispose(); table = null; } public String[][] getCurrentData() { return table.getCurrentData(); } }