Example usage for org.eclipse.jface.dialogs ProgressMonitorDialog run

List of usage examples for org.eclipse.jface.dialogs ProgressMonitorDialog run

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs ProgressMonitorDialog run.

Prototype

@Override
public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable)
        throws InvocationTargetException, InterruptedException 

Source Link

Document

This implementation of IRunnableContext#run(boolean, boolean, IRunnableWithProgress) runs the given IRunnableWithProgress using the progress monitor for this progress dialog and blocks until the runnable has been run, regardless of the value of fork.

Usage

From source file:gov.redhawk.ide.sdr.ui.internal.handlers.LaunchDomainManagerWithOptions.java

License:Open Source License

@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
    final ISelection selection = HandlerUtil.getActiveMenuSelection(event);
    displayContext = HandlerUtil.getActiveShell(event);
    dmReg = ScaPlugin.getDefault().getDomainManagerRegistry(displayContext);
    final Shell shell = HandlerUtil.getActiveShell(event);
    if (selection instanceof IStructuredSelection) {
        final IStructuredSelection ss = (IStructuredSelection) selection;
        for (final Object obj : ss.toArray()) {
            if (obj instanceof SdrRoot) {
                final SdrRoot sdrRoot = (SdrRoot) obj;
                Assert.isNotNull(sdrRoot);
                if (sdrRoot.getLoadStatus() == null) {
                    ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
                    try {
                        dialog.run(true, true, new IRunnableWithProgress() {

                            @Override
                            public void run(final IProgressMonitor monitor)
                                    throws InvocationTargetException, InterruptedException {
                                monitor.beginTask("Loading Target SDR..", IProgressMonitor.UNKNOWN);
                                try {
                                    CorbaUtils.invoke(new Callable<Object>() {

                                        @Override
                                        public Object call() throws Exception {
                                            sdrRoot.load(monitor);
                                            return null;
                                        }

                                    }, monitor);
                                } catch (CoreException e) {
                                    throw new InvocationTargetException(e);
                                }/*ww  w .  ja  v  a  2s.co  m*/

                            }
                        });
                    } catch (InvocationTargetException e) {
                        StatusManager.getManager().handle(new Status(IStatus.ERROR, SdrUiPlugin.PLUGIN_ID,
                                "Failed to load SDR.", e.getCause()), StatusManager.SHOW | StatusManager.LOG);
                    } catch (InterruptedException e) {
                        return null;
                    }
                }

                final DomainManagerConfiguration domain = sdrRoot.getDomainConfiguration();
                if (domain == null) {
                    StatusManager.getManager().handle(new Status(IStatus.ERROR, SdrUiPlugin.PLUGIN_ID,
                            "No Domain Configuration available."), StatusManager.SHOW);
                    continue;
                }
                model.setDomainName(domain.getName());

                final LaunchDomainManagerWithOptionsDialog dialog = new LaunchDomainManagerWithOptionsDialog(
                        shell, model, sdrRoot);
                if (dialog.open() == IStatus.OK) {
                    deviceManagers = dialog.getDeviceManagerLaunchConfigurations();
                    prepareDomainManager(domain, event);
                }
            }
        }
    }

    return null;
}

From source file:gov.redhawk.sca.dcd.diagram.adapters.DcdComponentInstantiationEditPartAdapterFactory.java

License:Open Source License

@Override
public Object getAdapter(final Object adaptableObject, final Class adapterType) {
    if (adaptableObject instanceof GraphicalEditPart) {
        final GraphicalEditPart editPart = (GraphicalEditPart) adaptableObject;
        final DcdComponentInstantiation ci = (DcdComponentInstantiation) editPart
                .getAdapter(ComponentInstantiation.class);

        if (ci != null && ci.eResource() != null) {
            if (adapterType == ScaDevice.class || adapterType == ScaAbstractComponent.class
                    || adapterType == ScaPropertyContainer.class) {
                final URI uri = ci.eResource().getURI();
                final Map<String, String> query = QueryParser.parseQuery(uri.query());
                final String ior = query.get(ScaFileSystemConstants.QUERY_PARAM_WF);
                final ScaDeviceManager manager = ScaModelPlugin.getDefault().findEObject(ScaDeviceManager.class,
                        ior);/*  ww w  .j  a v a2  s. c  o m*/
                final String deviceId = ci.getId();
                if (manager != null) {
                    List<ScaDevice<?>> devices = Collections.emptyList();
                    if (manager.isSetDevices()) {
                        devices = manager.getAllDevices();
                    } else {
                        if (Display.getCurrent() != null) {
                            ProgressMonitorDialog dialog = new ProgressMonitorDialog(
                                    Display.getCurrent().getActiveShell());
                            try {
                                dialog.run(true, true, new IRunnableWithProgress() {

                                    @Override
                                    public void run(final IProgressMonitor monitor)
                                            throws InvocationTargetException, InterruptedException {
                                        monitor.beginTask("Fetching devices for " + manager.getLabel(),
                                                IProgressMonitor.UNKNOWN);
                                        try {
                                            CorbaUtils.invoke(new Callable<List<ScaDevice<?>>>() {

                                                public List<ScaDevice<?>> call() throws Exception {
                                                    manager.fetchDevices(monitor);
                                                    return manager.getAllDevices();
                                                }
                                            }, monitor);
                                        } catch (CoreException e) {
                                            throw new InvocationTargetException(e);
                                        }
                                    }
                                });
                            } catch (InvocationTargetException e) {
                                StatusManager.getManager()
                                        .handle(new Status(Status.ERROR, DcdDiagramPluginActivator.PLUGIN_ID,
                                                "Failed to fetch devices for " + manager.getLabel(), e),
                                                StatusManager.SHOW | StatusManager.LOG);
                            } catch (InterruptedException e) {
                                // PASS
                            }

                        } else {
                            try {
                                ProtectedThreadExecutor.submit(new Callable<List<ScaDevice<?>>>() {

                                    public List<ScaDevice<?>> call() throws Exception {
                                        manager.fetchDevices(null);
                                        return manager.getAllDevices();
                                    }
                                });
                            } catch (final InterruptedException e) {
                                // PASS
                            } catch (final ExecutionException e) {
                                StatusManager.getManager()
                                        .handle(new Status(Status.ERROR, DcdDiagramPluginActivator.PLUGIN_ID,
                                                "Failed to fetch devices for " + manager.getLabel(), e),
                                                StatusManager.SHOW | StatusManager.LOG);
                            } catch (final TimeoutException e) {
                                StatusManager
                                        .getManager().handle(
                                                new Status(Status.WARNING, DcdDiagramPluginActivator.PLUGIN_ID,
                                                        "Timed out trying to fetch devices for "
                                                                + manager.getLabel(),
                                                        e),
                                                StatusManager.SHOW | StatusManager.LOG);
                            }
                        }

                        // Ensure the manager devices are "set" to avoid future zombie threads
                        if (!manager.isSetAllDevices()) {
                            ScaModelCommand.execute(manager, new ScaModelCommand() {

                                @Override
                                public void execute() {
                                    if (!manager.isSetAllDevices()) {
                                        manager.getDevices().clear();
                                    }
                                }
                            });
                        }

                        devices = manager.getAllDevices();
                    }

                    for (final ScaDevice<?> device : devices) {
                        if (deviceId.equals(device.getIdentifier())) {
                            return device;
                        }
                    }
                }
            }
        }
    }

    return null;
}

From source file:gov.redhawk.sca.internal.ui.SadComponentInstantiationAdapterFactory.java

License:Open Source License

/**
 * {@inheritDoc}/*from w w  w .  j a v  a 2 s.c  om*/
 */
@Override
public Object getAdapter(final Object adaptableObject, @SuppressWarnings("rawtypes") final Class adapterType) {
    if (adapterType == ScaComponent.class && adaptableObject instanceof SadComponentInstantiation) {
        final SadComponentInstantiation compInst = (SadComponentInstantiation) adaptableObject;
        if (compInst.eResource() == null) {
            return null;
        }

        final URI uri = compInst.eResource().getURI();
        final Map<String, String> query = QueryParser.parseQuery(uri.query());
        final String wfRef = query.get(ScaFileSystemConstants.QUERY_PARAM_WF);
        final ScaWaveform waveform = ScaModelPlugin.getDefault().findEObject(ScaWaveform.class, wfRef);
        final String myId = compInst.getId();
        if (waveform != null) {
            List<ScaComponent> components = Collections.emptyList();
            if (waveform.isSetComponents()) {
                components = waveform.getComponents();
            } else {
                if (Display.getCurrent() != null) {
                    ProgressMonitorDialog dialog = new ProgressMonitorDialog(
                            Display.getCurrent().getActiveShell());
                    try {
                        dialog.run(true, true, new IRunnableWithProgress() {

                            @Override
                            public void run(final IProgressMonitor monitor)
                                    throws InvocationTargetException, InterruptedException {
                                monitor.beginTask("Fetching components...", IProgressMonitor.UNKNOWN);
                                try {
                                    CorbaUtils.invoke(new Callable<Object>() {

                                        @Override
                                        public Object call() throws Exception {
                                            waveform.fetchComponents(monitor);
                                            return null;
                                        }

                                    }, monitor);
                                } catch (CoreException e) {
                                    throw new InvocationTargetException(e);
                                } catch (InterruptedException e) {
                                    // PASS
                                }
                            }
                        });
                    } catch (InvocationTargetException e) {
                        StatusManager.getManager()
                                .handle(new Status(Status.ERROR, ScaUiPlugin.PLUGIN_ID,
                                        "Failed to fetch components.", e),
                                        StatusManager.LOG | StatusManager.SHOW);
                    } catch (InterruptedException e) {
                        // PASS
                    }
                } else {
                    try {
                        ProtectedThreadExecutor.submit(new Callable<Object>() {

                            @Override
                            public Object call() throws Exception {
                                waveform.fetchComponents(null);
                                return null;
                            }

                        });
                    } catch (InterruptedException e) {
                        // PASS
                    } catch (ExecutionException e) {
                        StatusManager.getManager()
                                .handle(new Status(Status.ERROR, ScaUiPlugin.PLUGIN_ID,
                                        "Failed to fetch components.", e),
                                        StatusManager.LOG | StatusManager.SHOW);
                    } catch (TimeoutException e) {
                        StatusManager.getManager()
                                .handle(new Status(Status.WARNING, ScaUiPlugin.PLUGIN_ID,
                                        "Timed out while trying to fetch components.", e),
                                        StatusManager.LOG | StatusManager.SHOW);
                    }
                }
            }
            for (final ScaComponent component : components) {
                final String scaComponentId = component.identifier();
                if (scaComponentId.startsWith(myId)) {
                    return component;
                }
            }

        }
    }

    return null;
}

From source file:gov.redhawk.sca.sad.diagram.adapters.AdapterUtil.java

License:Open Source License

public static List<ScaComponent> safeFetchComponents(final ScaWaveform waveform) {
    List<ScaComponent> retVal = Collections.emptyList();
    if (waveform == null) {
        return Collections.emptyList();
    } else if (waveform.isSetComponents()) {
        retVal = waveform.getComponents();
    } else {//from  ww  w . j  av  a 2s.c  o m

        if (Display.getCurrent() != null) {
            ProgressMonitorDialog dialog = new ProgressMonitorDialog(Display.getCurrent().getActiveShell());
            try {
                dialog.run(true, true, new IRunnableWithProgress() {
                    @Override
                    public void run(final IProgressMonitor monitor)
                            throws InvocationTargetException, InterruptedException {
                        monitor.beginTask("Fetching components for " + waveform.getName(),
                                IProgressMonitor.UNKNOWN);
                        try {
                            CorbaUtils.invoke(new Callable<List<ScaComponent>>() {

                                @Override
                                public List<ScaComponent> call() throws Exception {
                                    return waveform.fetchComponents(monitor);
                                }

                            }, monitor);
                        } catch (CoreException e) {
                            throw new InvocationTargetException(e);
                        }
                    }
                });
            } catch (InvocationTargetException e) {
                StatusManager.getManager()
                        .handle(new Status(Status.ERROR, RedhawkSadDiagramPlugin.PLUGIN_ID,
                                "Failed to fetch components for " + waveform.getName(), e),
                                StatusManager.SHOW | StatusManager.LOG);
            } catch (InterruptedException e) {
                // PASS
            }
            retVal = waveform.getComponents();
        } else {
            try {
                retVal = ProtectedThreadExecutor.submit(new Callable<List<ScaComponent>>() {

                    public List<ScaComponent> call() throws Exception {
                        return waveform.fetchComponents(null);
                    }

                });
            } catch (final InterruptedException e) {
                // PASS
            } catch (final ExecutionException e) {
                StatusManager.getManager()
                        .handle(new Status(Status.ERROR, RedhawkSadDiagramPlugin.PLUGIN_ID,
                                "Failed to fetch components for " + waveform.getName(), e),
                                StatusManager.SHOW | StatusManager.LOG);
            } catch (final TimeoutException e) {
                StatusManager.getManager()
                        .handle(new Status(Status.WARNING, RedhawkSadDiagramPlugin.PLUGIN_ID,
                                "Timed out trying to fetch components for " + waveform.getName(), e),
                                StatusManager.SHOW | StatusManager.LOG);
            }
        }

        // Ensure the waveform components are "set" to avoid future zombie threads
        if (!waveform.isSetComponents()) {
            ScaModelCommand.execute(waveform, new ScaModelCommand() {

                @Override
                public void execute() {
                    if (!waveform.isSetComponents()) {
                        waveform.getComponents().clear();
                    }
                }
            });
        }
    }
    return retVal;
}

From source file:gov.redhawk.sca.sad.diagram.adapters.AdapterUtil.java

License:Open Source License

public static List<ScaPort<?, ?>> safeFetchPorts(final ScaComponent component) {
    List<ScaPort<?, ?>> retVal = Collections.emptyList();
    if (component.isSetPorts()) {
        retVal = component.getPorts();/*  w  w w  .  j  a  v  a  2s .  c o m*/
    } else {
        if (Display.getCurrent() != null) {
            ProgressMonitorDialog dialog = new ProgressMonitorDialog(Display.getCurrent().getActiveShell());
            try {
                dialog.run(true, true, new IRunnableWithProgress() {

                    @Override
                    public void run(final IProgressMonitor monitor)
                            throws InvocationTargetException, InterruptedException {
                        monitor.beginTask("Fetching ports for " + component.getName(),
                                IProgressMonitor.UNKNOWN);
                        try {
                            CorbaUtils.invoke(new Callable<List<ScaPort<?, ?>>>() {

                                public List<ScaPort<?, ?>> call() throws Exception {
                                    return component.fetchPorts(monitor);
                                }

                            }, monitor);
                        } catch (CoreException e) {
                            throw new InvocationTargetException(e);
                        }
                    }
                });
            } catch (InvocationTargetException e) {
                StatusManager.getManager()
                        .handle(new Status(Status.ERROR, RedhawkSadDiagramPlugin.PLUGIN_ID,
                                "Failed to fetch ports for " + component.getName(), e),
                                StatusManager.SHOW | StatusManager.LOG);
            } catch (InterruptedException e) {
                // PASS
            }
            retVal = component.getPorts();
        } else {
            try {
                retVal = ProtectedThreadExecutor.submit(new Callable<List<ScaPort<?, ?>>>() {

                    public List<ScaPort<?, ?>> call() throws Exception {
                        return component.fetchPorts(null);
                    }

                });
            } catch (final InterruptedException e) {
                // PASS
            } catch (final ExecutionException e) {
                StatusManager.getManager()
                        .handle(new Status(Status.ERROR, RedhawkSadDiagramPlugin.PLUGIN_ID,
                                "Failed to fetch ports for " + component.getName(), e),
                                StatusManager.SHOW | StatusManager.LOG);
            } catch (final TimeoutException e) {
                StatusManager.getManager()
                        .handle(new Status(Status.WARNING, RedhawkSadDiagramPlugin.PLUGIN_ID,
                                "Timed out trying to fetch ports for " + component.getName(), e),
                                StatusManager.SHOW | StatusManager.LOG);
            }
        }

        // Ensure the component's port are "set" to avoid future zombie threads
        if (!component.isSetPorts()) {
            ScaModelCommand.execute(component, new ScaModelCommand() {

                @Override
                public void execute() {
                    if (!component.isSetPorts()) {
                        component.getPorts().clear();
                    }
                }
            });
        }
    }

    return retVal;
}

From source file:gov.redhawk.ui.editor.SCAFormEditor.java

License:Open Source License

/**
 * This is the method called to load a resource into the editing domain's resource set based on the editor's input.
 *//*from  w  w  w  .  ja v  a 2 s  .c  o m*/
protected void createModel() {
    final URI resourceURI = EditUIUtil.getURI(getEditorInput());
    // For safety we'll decode the URI to make sure escape sequences have been correctly represented
    String decodedURIString = URI.decode(resourceURI.toString());
    final URI decodedURI = URI.createURI(decodedURIString);
    Exception exception = null;
    try {
        // Load the resource through the editing domain.
        //
        if (Display.getCurrent() != null) {
            ProgressMonitorDialog dialog = new ProgressMonitorDialog(Display.getCurrent().getActiveShell());
            dialog.run(true, true, new IRunnableWithProgress() {

                @Override
                public void run(IProgressMonitor monitor)
                        throws InvocationTargetException, InterruptedException {
                    try {
                        monitor.beginTask("Loading XML...", IProgressMonitor.UNKNOWN);
                        mainResource = CorbaUtils.invoke(new Callable<Resource>() {
                            @Override
                            public Resource call() throws Exception {
                                return editingDomain.getResourceSet().getResource(decodedURI, true);
                            }

                        }, monitor);
                    } catch (CoreException e) {
                        throw new InvocationTargetException(e);
                    }

                }
            });
        } else {
            mainResource = editingDomain.getResourceSet().getResource(decodedURI, true);
        }
    } catch (final Exception e) { // SUPPRESS CHECKSTYLE Logged Catch all exception
        exception = e;
        this.mainResource = this.editingDomain.getResourceSet().getResource(decodedURI, false);
    }
    if (exception != null) {
        StatusManager.getManager()
                .handle(new Status(IStatus.ERROR, RedhawkUiActivator.getPluginId(),
                        "Errors occured while loading the main resource of the editor.", exception),
                        StatusManager.SHOW | StatusManager.LOG);
    }
}

From source file:gov.us.fhim.ui.actions.ImportSpreadsheet.java

License:Open Source License

/**
 * @see IActionDelegate#run(IAction)/*from  ww  w.  j  ava2s.c om*/
 */
public void run(IAction action) {

    ProgressMonitorDialog progressDialog = new ProgressMonitorDialog(shell);

    ObjectPluginAction opa = (ObjectPluginAction) action;

    final TreeSelection selection = (TreeSelection) opa.getSelection();

    final String ActionTitle = "Import Terminology";

    final FileDialog fdlg = new FileDialog(shell, SWT.SINGLE);

    fdlg.setText("Select Terminology Source File");

    fdlg.setFilterNames(FILTER_NAMES);
    fdlg.setFilterExtensions(FILTER_EXTS);

    IRunnableWithProgress runnableWithProgress = new IRunnableWithProgress() {

        public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {

            IWorkspaceRoot myWorkspaceRoot = ResourcesPlugin.getWorkspace().getRoot();

            File f = (File) selection.getFirstElement();

            String umlPath = myWorkspaceRoot.getLocation().toOSString() + f.getFullPath().toOSString();

            try {
                importMapping(monitor, umlPath, fdlg);
            } catch (Exception e) {
                e.printStackTrace();
            }

            try {
                myWorkspaceRoot.refreshLocal(IResource.DEPTH_INFINITE, null);
            } catch (CoreException e) {
            }

            if (monitor.isCanceled()) {
                monitor.done();
                return;
            }

            monitor.done();

        }

    };

    try {
        if (fdlg.open() != null) {
            progressDialog.run(false, true, runnableWithProgress);
            MetricsDialog dlg = new MetricsDialog(shell);
            dlg.create();
            dlg.open();
        }

    } catch (InvocationTargetException invocationTargetException) {
        MessageDialog.openError(shell, ActionTitle,
                "Error Processing Export " + invocationTargetException.getMessage());

    } catch (InterruptedException interruptedException) {
        MessageDialog.openError(shell, ActionTitle,
                "Error Processing Export " + interruptedException.getMessage());

    } finally {
        progressDialog.close();

    }
}

From source file:hub.sam.mas.editor.actions.AddMASContextAction.java

License:Open Source License

public void run(IAction action) {
    display = Display.getCurrent();//w  ww .j  a  va 2  s.  c o m
    Shell shell = new Shell(display);

    ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(shell, new WorkbenchLabelProvider(),
            new WorkbenchContentProvider());
    dialog.setTitle("MAS Context File");
    dialog.setMessage("Select a MAS Context File:");
    dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
    dialog.setSorter(new ResourceSorter(ResourceSorter.NAME));
    // TODO filter *.masctx

    if (dialog.open() == IDialogConstants.OK_ID) {
        IResource resource = (IResource) dialog.getFirstResult();

        try {
            contextFile = new MasContextFile(resource);
            ProgressMonitorDialog progressMonitor = new ProgressMonitorDialog(shell);
            progressMonitor.run(true, false, this);
        } catch (Exception e) {
            MessageDialog.openError(shell, "Error", "Failed to create a MAS Context: " + e.getMessage());
            return;
        }

        IStructuredSelection selection = (IStructuredSelection) getModelView().getViewer().getSelection();
        ((RepositoryTreeObject) selection.getFirstElement()).refresh();

        getModelView().getViewer().refresh();
        shell.dispose();
    }
}

From source file:hub.sam.mas.editor.actions.EditBehaviourAction.java

License:Open Source License

public void run(IAction action) {
    link = getLinkFromSelection();/*w  w w .  j a v a  2 s  .c o  m*/
    if (link == null) {
        MasContext masContext = getMASContextFromSelection();
        MaseCreationFactory maseFactory = new MaseCreationFactory(
                (masFactory) masContext.getMasModel().getFactory(), Activity.class);
        Activity activity = maseFactory.createActivity();
        link = masContext.createLink(getSelectedOperation(), activity);
    }

    display = Display.getCurrent();
    ProgressMonitorDialog progressMonitor = new ProgressMonitorDialog(display.getActiveShell());
    try {
        progressMonitor.run(true, false, this);
    } catch (InvocationTargetException e) {
        MessageDialog.openError(display.getActiveShell(), "Error",
                "Failed to open a MAS Editor: " + e.getMessage());
    } catch (InterruptedException e) {
    }
}

From source file:it.eng.spagobi.meta.editor.business.actions.CreateQueryAction.java

License:Mozilla Public License

/**
 * This executes the command.//ww w. j  a  v  a 2  s  . c o  m
 */
@Override
public void run() {
    try {
        int returnCode = Window.CANCEL;
        BusinessModel businessModel = (BusinessModel) ((BusinessRootItemProvider) owner).getParentObject();

        // First, check if there are any physical model objects marked as deleted
        PhysicalModelInitializer physicalModelInitializer = new PhysicalModelInitializer();
        List<ModelObject> markedElements = physicalModelInitializer
                .getElementsMarkedAsDeleted(businessModel.getPhysicalModel());
        if (!markedElements.isEmpty()) {
            DeleteElementsWarningDialog warningDialog = new DeleteElementsWarningDialog(markedElements);
            warningDialog.create();
            warningDialog.setBlockOnOpen(true);
            returnCode = warningDialog.open();
            if (returnCode == Window.OK) {
                // execute a command for mass delete of elements marked as deleted
                DeletePhysicalModelObjectAction deletePhysicalModelObjectAction = new DeletePhysicalModelObjectAction();
                final Command deleteCommand = deletePhysicalModelObjectAction.createCommand(markedElements);
                // this guard is for extra security, but should not be necessary
                if (editingDomain != null && deleteCommand != null) {
                    // use up the command

                    ProgressMonitorDialog progressDialog = new ProgressMonitorDialog(new Shell());
                    progressDialog.setCancelable(false);
                    try {
                        progressDialog.run(false, false, new IRunnableWithProgress() {
                            @Override
                            public void run(IProgressMonitor monitor) {
                                // Note: this is a non-UI Thread
                                monitor.beginTask("Deleting marked elements, please wait...",
                                        IProgressMonitor.UNKNOWN);
                                // doing task...

                                editingDomain.getCommandStack().execute(deleteCommand);

                                monitor.done();
                            }
                        });
                    } catch (InvocationTargetException e1) {
                        e1.printStackTrace();
                    } catch (InterruptedException e1) {
                        e1.printStackTrace();
                    }
                }

            }
        }

        if (markedElements.isEmpty() || returnCode != Window.CANCEL) {
            // check the constraints for hibernate mappings
            BusinessModelInitializer businessModelInitializer = new BusinessModelInitializer();
            List<Pair<BusinessRelationship, Integer>> incorrectRelationships = businessModelInitializer
                    .checkRelationshipsConstraints(businessModel);
            int relationshipsWarningReturnCode = Window.CANCEL;
            if (!incorrectRelationships.isEmpty()) {
                BusinessModelRelationshipsCheckWarningDialog warningDialog = new BusinessModelRelationshipsCheckWarningDialog(
                        incorrectRelationships);
                warningDialog.create();
                warningDialog.setBlockOnOpen(true);
                relationshipsWarningReturnCode = warningDialog.open();
            }

            if (incorrectRelationships.isEmpty() || relationshipsWarningReturnCode == Window.OK) {
                // CreateQueryWizard wizard = new CreateQueryWizard(businessModel, editingDomain, (AbstractSpagoBIModelCommand)command );
                NewQueryFileWizard wizard = new NewQueryFileWizard(businessModel, editingDomain,
                        (ISpagoBIModelCommand) command, modelFileFullPath);
                wizard.init(PlatformUI.getWorkbench(), new StructuredSelection());
                WizardDialog dialog = new WizardDialog(wizard.getShell(), wizard);
                dialog.create();
                dialog.open();
            }

        }

    } catch (Throwable t) {
        t.printStackTrace();
    }
}