1 package org.simantics.modeling.ui.actions;
3 import org.eclipse.jface.wizard.WizardDialog;
4 import org.eclipse.swt.widgets.Display;
5 import org.eclipse.ui.IWorkbenchWindow;
6 import org.eclipse.ui.PlatformUI;
7 import org.simantics.Simantics;
8 import org.simantics.db.Resource;
9 import org.simantics.db.common.utils.Logger;
10 import org.simantics.db.exception.DatabaseException;
11 import org.simantics.db.layer0.adapter.ActionFactory;
12 import org.simantics.db.layer0.request.PossibleURI;
13 import org.simantics.modeling.ui.wizard.MigrateWizard;
16 * @author Antti Villberg
18 public class MigrateComponentType implements ActionFactory {
21 public Runnable create(Object target) {
23 if (!(target instanceof Resource))
26 final Resource r = (Resource)target;
28 return new Runnable() {
35 final String initial = Simantics.sync(new PossibleURI(r));
37 Display.getDefault().asyncExec(new Runnable() {
42 final int SIZING_WIZARD_WIDTH = 500;
43 final int SIZING_WIZARD_HEIGHT = 600;
44 IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
45 MigrateWizard wizard = new MigrateWizard(initial);
46 WizardDialog dialog = new WizardDialog(window.getShell(), wizard);
48 dialog.getShell().setSize(Math.max(SIZING_WIZARD_WIDTH, dialog.getShell().getSize().x), SIZING_WIZARD_HEIGHT);
55 } catch (DatabaseException e) {
56 Logger.defaultLogError(e);