1 package org.simantics.district.selection.ui.handlers;
3 import org.eclipse.e4.core.contexts.IEclipseContext;
4 import org.eclipse.e4.core.di.annotations.CanExecute;
5 import org.eclipse.e4.core.di.annotations.Execute;
6 import org.eclipse.e4.ui.workbench.IWorkbench;
7 import org.eclipse.e4.ui.workbench.modeling.ESelectionService;
8 import org.eclipse.jface.window.Window;
9 import org.eclipse.swt.widgets.Shell;
10 import org.simantics.db.exception.DatabaseException;
11 import org.simantics.district.selection.ui.parts.EditSelectorDialog;
12 import org.slf4j.Logger;
13 import org.slf4j.LoggerFactory;
15 public class CreateNewElementSelector {
17 private static final Logger LOGGER = LoggerFactory.getLogger(CreateNewElementSelector.class);
20 public boolean canExecute(ESelectionService selectionService) {
25 public void createNewElementSelector(IEclipseContext context, IWorkbench workbench) {
26 Shell shell = context.getActive(Shell.class);
27 EditSelectorDialog dialog = new EditSelectorDialog(shell, null);
28 LOGGER.debug("Opening dialog");
29 int result = dialog.open();
30 LOGGER.debug("Dialog closed with result code " + result);
31 if (result == Window.OK) {
33 dialog.writeSelection();
34 } catch (DatabaseException e) {
35 LOGGER.error("Writing new element selection failed", e);