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:org.bundlemaker.core.ui.view.transformationhistory.view.HistoryView.java

License:Open Source License

private void resetHistory() {
    IStructuredSelection selection = (IStructuredSelection) _viewer.getSelection();

    if (selection.isEmpty()) {
        return;/*from   ww  w.j a  v  a 2 s .co m*/
    }

    Object firstElement = selection.getFirstElement();

    // If no transformation is selected undo complete history
    final ITransformation transformation = (firstElement instanceof ITransformation)
            ? (ITransformation) firstElement
            : null;

    final IModularizedSystem modularizedSystem = (firstElement instanceof IRootArtifact)
            ? ((IRootArtifact) firstElement).getModularizedSystem()
            : getModularizedSystem(transformation);

    ProgressMonitorDialog dialog = new ProgressMonitorDialog(getViewSite().getShell());
    try {
        dialog.run(true, true, new IRunnableWithProgress() {

            @Override
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                modularizedSystem.undoUntilTransformation(monitor, transformation);

            }
        });

        CommonNavigatorUtils.refresh(CommonNavigatorUtils.PROJECT_EXPLORER_VIEW_ID);

    } catch (InvocationTargetException e) {
        // TODO
        e.printStackTrace();
    } catch (InterruptedException e) {
        // doesn't matter
    }

    refreshEnablement();

}

From source file:org.caesarj.ui.wizard.NewCaesarProjectWizard.java

License:Open Source License

/**
* Builds and adds the necessary properties to the new project and updates the workspace view
*///from w  w w .j  av  a2 s  .co  m
private boolean finalizeNewProject(IJavaProject javaProject, boolean alreadyExists) {
    IProject project = javaProject.getProject();
    final IProject thisProject = project;
    ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell());
    try {

        // The nature to add is the PluginID+NatureID - it is not the
        // name of the class implementing IProjectNature !!
        // When the nature is attached, the project will be driven through
        // INatureProject.configure() which will replace the normal javabuilder
        // with the caesarj builder.
        if (!alreadyExists) {
            CaesarJProjectTools.addCaesarJNature(javaProject, true);
        }

        else {
            dialog.run(true, true, new IRunnableWithProgress() {
                public void run(IProgressMonitor monitor) throws InvocationTargetException {
                    monitor.beginTask("", 2); //$NON-NLS-1$
                    try {
                        monitor.setTaskName("Building project...");
                        thisProject.build(IncrementalProjectBuilder.FULL_BUILD,
                                new SubProgressMonitor(monitor, 2));
                    } catch (CoreException e) {
                    } finally {
                        monitor.done();
                    }
                }
            });
        }
    } catch (InterruptedException e) {
        // build cancelled by user
        return false;
    } catch (InvocationTargetException e) {
        String title = "Error";
        String message = "An error occured while trying to create the project";
        ExceptionHandler.handle(e, getShell(), title, message);
    } catch (CoreException e) {
    }

    project = thisProject;
    //AspectJPlugin.getDefault().setCurrentProject( project );
    selectAndReveal(project);
    return true;
}

From source file:org.caleydo.core.io.gui.dataimport.FilePreviewParser.java

License:Open Source License

public void parseWithProgress(Shell shell, final String fileName, final String delimiter,
        final boolean parseAllRows, final int maxRowsToParse) {
    ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);

    try {/*from   w  w w  . jav a  2  s .  c o  m*/
        dialog.run(true, false, new IRunnableWithProgress() {

            @Override
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                parse(fileName, delimiter, parseAllRows, maxRowsToParse, monitor);
            }
        });
    } catch (Exception e) {
        Logger.log(new Status(IStatus.ERROR, this.toString(), "Dataset loading failed: " + e.getMessage()));
    }
}

From source file:org.caleydo.core.io.gui.dataimport.wizard.DataImportWizard.java

License:Open Source License

@Override
public boolean performFinish() {

    // if (!visitedPages.contains(loadDataSetPage))
    // return false;

    if (visitedPages.contains(loadDataSetPage) || getContainer().getCurrentPage().equals(loadDataSetPage))
        loadDataSetPage.fillDataSetDescription();
    if (visitedPages.contains(dataSetTypePage) || getContainer().getCurrentPage().equals(dataSetTypePage))
        dataSetTypePage.fillDataSetDescription();
    if (visitedPages.contains(chosenDataTypePage) || getContainer().getCurrentPage().equals(chosenDataTypePage))
        chosenDataTypePage.fillDataSetDescription();
    if (visitedPages.contains(addGroupingsPage) || getContainer().getCurrentPage().equals(addGroupingsPage))
        addGroupingsPage.fillDataSetDescription();

    ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell());

    try {//from  w ww  .  j a  va  2s.  c  o  m

        dialog.run(true, false, new IRunnableWithProgress() {

            @Override
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                try {
                    dataDomain = DataLoader.loadData(dataSetDescription, monitor);
                } catch (Exception e) {
                    error = e.getMessage();
                }
            }
        });
    } catch (Exception e) {
        Logger.log(new Status(IStatus.ERROR, this.toString(), "Dataset loading failed: " + e.getMessage()));
    }
    if (dataDomain == null) {
        MessageDialog.openError(getShell(), "Dataset Loading Failed",
                "An error has occurred during loading file " + dataSetDescription.getDataSourcePath() + ". "
                        + (error != null ? error : ""));
    } else {
        DataImportStatusDialog d = DataImportStatusDialogs.createDatasetImportStatusDialog(getShell(),
                dataDomain);
        d.open();
    }

    // DataLoader.loadData(dataSetDescription, null);

    // try {
    // new ProgressMonitorDialog(shell).run(true, true,
    // new LongRunningOperation(indeterminate.getSelection()));
    // } catch (InvocationTargetException e) {
    // MessageDialog.openError(shell, "Error", e.getMessage());
    // } catch (InterruptedException e) {
    // MessageDialog.openInformation(shell, "Cancelled", e.getMessage());
    // }

    // ATableBasedDataDomain dataDomain;
    // Job job = new Job("First Job") {
    // @Override
    // protected IStatus run(IProgressMonitor monitor) {
    //
    //
    // // Use this to open a Shell in the UI thread
    // return Status.OK_STATUS;
    // }
    //
    // };
    // job.setUser(true);
    // job.schedule();

    // todo handle failure

    // try {
    //
    // String secondaryID = UUID.randomUUID().toString();
    // RCPViewInitializationData rcpViewInitData = new
    // RCPViewInitializationData();
    // rcpViewInitData.setDataDomainID(dataDomain.getDataDomainID());
    // RCPViewManager.get().addRCPView(secondaryID, rcpViewInitData);
    //
    // if (PlatformUI.getWorkbench().getActiveWorkbenchWindow() != null) {
    // PlatformUI
    // .getWorkbench()
    // .getActiveWorkbenchWindow()
    // .getActivePage()
    // .showView(dataDomain.getDefaultStartViewType(), secondaryID,
    // IWorkbenchPage.VIEW_ACTIVATE);
    //
    // }
    // } catch (PartInitException e) {
    // // TODO Auto-generated catch block
    // e.printStackTrace();
    // }

    return true;
}

From source file:org.caleydo.view.relationshipexplorer.ui.dialog.ImportIDMappingDialog.java

License:Open Source License

@Override
protected void okPressed() {

    if (isDataValid()) {

        final IDMappingDescription desc = new IDMappingDescription();
        desc.setParsingStartLine(numHeaderRowsSpinner.getSelection());
        desc.setParsingStopLine(-1);/*from   www  .  ja  v a  2 s.  c o  m*/
        desc.setFileName(loadFile.getFileName());
        desc.setDelimiter(delimiters.getDelimeter());
        desc.setMultiMapping(true);
        desc.setCreateReverseMapping(true);
        desc.setResolveCodeMappingUsingCodeToId_LUT(false);

        desc.setIdCategory(idCategoryCombo.getText());

        IDType fromIDType = IDType.getIDType(identifierCombos[0].getText());
        desc.setFromIDType(fromIDType.getTypeName());
        desc.setFromDataType(fromIDType.getDataType());

        IDType toIDType = IDType.getIDType(identifierCombos[1].getText());
        desc.setToIDType(toIDType.getTypeName());
        desc.setToDataType(toIDType.getDataType());

        ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell());

        try {

            dialog.run(true, false, new IRunnableWithProgress() {

                @Override
                public void run(IProgressMonitor monitor)
                        throws InvocationTargetException, InterruptedException {
                    desc.addMapping();
                    IDMappingManager.addIDMappingDescription(desc);
                }
            });
        } catch (Exception e) {
            Logger.log(new Status(IStatus.ERROR, this.toString(), "Dataset loading failed: " + e.getMessage()));
        }

        super.okPressed();
    }
}

From source file:org.cloudfoundry.ide.eclipse.server.ui.internal.wizards.CloudFoundryServiceWizardPage.java

License:Open Source License

/** Returns the list of available services, or null if the user cancelled the monitor. */
private List<AvailableService> updateConfiguration() {
    final List<AvailableService> result = new ArrayList<AvailableService>();

    try {//from   w w w . j  ava  2 s  . c om

        final GetServiceOfferingsRunnable runnable = new GetServiceOfferingsRunnable();

        // Begin retrieving the service offerings
        ProgressMonitorDialog monitorDlg = new ProgressMonitorDialog(getShell());
        monitorDlg.run(true, true, runnable);

        GetServiceResult getServiceResult = runnable.getGetServiceOperationResult();

        if (getServiceResult == GetServiceResult.SUCCESS) {
            if (runnable.getServiceOfferingResult() != null) {

                if (runnable.getServiceOfferingResult().size() > 0) {

                    int index = 0;
                    for (CloudServiceOffering o : runnable.getServiceOfferingResult()) {

                        result.add(new AvailableService(o.getName(), o.getDescription(), index, o));
                        index++;
                    }
                } else {
                    // Operation succeeded, but no services are available.

                    MessageDialog.openWarning(getShell(),
                            Messages.CloudFoundryServiceWizard_NO_SERVICES_AVAILABLE_TITLE,
                            Messages.CloudFoundryServiceWizard_NO_SERVICES_AVAILABLE_BODY);

                    return null;
                }
            }

        } else if (getServiceResult == GetServiceResult.ERROR) {
            // Error is handled by the exception and by the runnable
            return null;
        } else {
            // If the user cancelled service acquisition, then just return null.
            return null;
        }

    } catch (InvocationTargetException e) {
        Throwable ex = e.getCause() != null ? e.getCause() : e;
        String msg = ex.getMessage();

        // Use a generic message if the exception did not provide one.
        if (msg == null || msg.trim().length() == 0) {
            msg = Messages.CloudFoundryServiceWizardPage_ERROR_CONFIG_RETRIVE_SEE_LOG_FOR_DETAILS;
        }

        IStatus status = cloudServer
                .error(NLS.bind(Messages.CloudFoundryServiceWizardPage_ERROR_CONFIG_RETRIVE, msg), e);
        StatusManager.getManager().handle(status, StatusManager.LOG);
        setMessage(status.getMessage(), IMessageProvider.ERROR);
    } catch (InterruptedException e) {
        if (Logger.WARNING) {
            Logger.println(Logger.WARNING_LEVEL, this, "updateConfiguration", //$NON-NLS-1$
                    "Failed to load the list of available services."); //$NON-NLS-1$
        }
    }

    return result;
}

From source file:org.crosswalk.eclipse.cdt.export.ExportProjectWizard.java

License:Apache License

@Override
public boolean performFinish() {
    ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell());
    IRunnableWithProgress op = new IRunnableWithProgress() {
        @Override/*  w  w w  .j  av a 2s .  c o m*/
        public void run(IProgressMonitor monitor) throws InvocationTargetException {
            try {
                monitor.beginTask("Exporting app to: " + destFile.toString(), 20);
                runResult = ExportHelper.doExport(eProject, targetFormat, destFile, packageParameters, monitor);

            } catch (IOException e) {
                e.printStackTrace();
            } finally {
                monitor.done();
            }
        }
    };
    try {
        dialog.run(false, true, op);
    } catch (Exception e) {
        CdtPluginLog.logError("Failed to export project:" + eProject.getName(), e);
        return false;
    }
    showResultDialog(runResult);
    return true;
}

From source file:org.dafoe.projectmanagement.ProjectManagementWizard.java

License:Open Source License

@Override
public boolean performFinish() {
    performState = false;//w ww . j a  v  a2  s .  c  o m
    if (this.refModel.isExists()) {
        ProgressMonitorDialog pd = new ProgressMonitorDialog(Display.getDefault().getActiveShell());
        try {
            pd.run(true, true, new IRunnableWithProgress() {
                public void run(IProgressMonitor monitor)
                        throws InvocationTargetException, InterruptedException {
                    SQLScriptEngine currentSQLScriptEngine = new SQLScriptEngine(refModel);
                    try {
                        currentSQLScriptEngine.openProject(monitor);
                        persistNewDataBase();
                        performState = true;
                    } catch (SQLScriptEngineException e) {
                        e.printStackTrace();
                        performState = false;
                    }
                }
            });
        } catch (Exception e) {
            e.printStackTrace();
        }
    } else {
        ProgressMonitorDialog pd = new ProgressMonitorDialog(Display.getDefault().getActiveShell());
        try {
            pd.run(true, true, new IRunnableWithProgress() {
                public void run(IProgressMonitor monitor)
                        throws InvocationTargetException, InterruptedException {
                    SQLScriptEngine currentSQLScriptEngine = new SQLScriptEngine(refModel);
                    try {
                        currentSQLScriptEngine.newProject(monitor);
                        persistNewDataBase();
                        performState = true;
                    } catch (SQLScriptEngineException e) {
                        e.printStackTrace();
                        performState = false;
                    }
                }
            });
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    return performState;
}

From source file:org.dawb.workbench.ui.diffraction.CalibrantPositioningWidget.java

License:Open Source License

/**
 * Creates a widget group with all the calibrant positioning widgets
 * used in a diffraction calibration view.
 * @param parent//from www.  ja v a 2  s. c  o  m
 *         parent composite of the widget
 * @param model
 *         List of all diffraction data present in the TableViewer (used to update beam centre)
 */
public CalibrantPositioningWidget(Composite parent, final DiffractionDataManager manager) {

    this.manager = manager;
    final Display display = Display.getDefault();

    Composite controllerHolder = new Composite(parent, SWT.FILL);
    controllerHolder.setLayout(new GridLayout(2, false));
    controllerHolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    GridUtils.removeMargins(controllerHolder);

    // Pad composite
    Composite padComp = new Composite(controllerHolder, SWT.NONE);
    padComp.setLayout(new GridLayout(5, false));
    padComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    padComp.setToolTipText("Move calibrant");

    Label l = new Label(padComp, SWT.NONE);
    l = new Label(padComp, SWT.NONE);
    Button upButton = new Button(padComp, SWT.ARROW | SWT.UP);
    upButton.setToolTipText("Move rings up");
    upButton.addMouseListener(new RepeatingMouseAdapter(display, new SlowFastRunnable() {
        @Override
        public void run() {
            DiffractionCalibrationUtils.changeRings(currentData, ManipulateMode.UP, isFast());
        }

        @Override
        public void stop() {
            if (tableViewer != null)
                tableViewer.refresh();
        }
    }));
    upButton.setLayoutData(new GridData(SWT.CENTER, SWT.BOTTOM, false, false));
    l = new Label(padComp, SWT.NONE);
    l = new Label(padComp, SWT.NONE);

    l = new Label(padComp, SWT.NONE);
    Button leftButton = new Button(padComp, SWT.ARROW | SWT.LEFT);
    leftButton.setToolTipText("Shift rings left");
    leftButton.addMouseListener(new RepeatingMouseAdapter(display, new SlowFastRunnable() {
        @Override
        public void run() {
            DiffractionCalibrationUtils.changeRings(currentData, ManipulateMode.LEFT, isFast());
        }

        @Override
        public void stop() {
            if (tableViewer != null)
                tableViewer.refresh();
        }
    }));
    leftButton.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
    l = new Label(padComp, SWT.NONE);
    l.setImage(Activator.getImage("icons/centre.png"));
    l.setToolTipText("Move calibrant");
    l.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, true));
    Button rightButton = new Button(padComp, SWT.ARROW | SWT.RIGHT);
    rightButton.setToolTipText("Shift rings right");
    rightButton.addMouseListener(new RepeatingMouseAdapter(display, new SlowFastRunnable() {
        @Override
        public void run() {
            DiffractionCalibrationUtils.changeRings(currentData, ManipulateMode.RIGHT, isFast());
        }

        @Override
        public void stop() {
            if (tableViewer != null)
                tableViewer.refresh();
        }
    }));
    rightButton.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
    l = new Label(padComp, SWT.NONE);

    l = new Label(padComp, SWT.NONE);
    l = new Label(padComp, SWT.NONE);
    Button downButton = new Button(padComp, SWT.ARROW | SWT.DOWN);
    downButton.setToolTipText("Move rings down");
    downButton.addMouseListener(new RepeatingMouseAdapter(display, new SlowFastRunnable() {
        @Override
        public void run() {
            DiffractionCalibrationUtils.changeRings(currentData, ManipulateMode.DOWN, isFast());
        }

        @Override
        public void stop() {
            if (tableViewer != null)
                tableViewer.refresh();
        }
    }));
    downButton.setLayoutData(new GridData(SWT.CENTER, SWT.TOP, false, false));
    l = new Label(padComp, SWT.NONE);
    l = new Label(padComp, SWT.NONE);

    // Resize group actions
    Composite actionComp = new Composite(controllerHolder, SWT.NONE);
    actionComp.setLayout(new GridLayout(3, false));
    actionComp.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, true));

    Composite sizeComp = new Composite(actionComp, SWT.NONE);
    sizeComp.setLayout(new GridLayout(1, false));
    sizeComp.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, true, true));
    sizeComp.setToolTipText("Change size");
    GridUtils.removeMargins(sizeComp);

    Button plusButton = new Button(sizeComp, SWT.PUSH);
    plusButton.setImage(Activator.getImage("icons/arrow_out.png"));
    plusButton.setToolTipText("Make rings larger");
    plusButton.addMouseListener(new RepeatingMouseAdapter(display, new SlowFastRunnable() {
        @Override
        public void run() {
            DiffractionCalibrationUtils.changeRings(currentData, ManipulateMode.ENLARGE, isFast());
        }

        @Override
        public void stop() {
            if (tableViewer != null)
                tableViewer.refresh();
        }
    }));
    plusButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true));
    Button minusButton = new Button(sizeComp, SWT.PUSH);
    minusButton.setImage(Activator.getImage("icons/arrow_in.png"));
    minusButton.setToolTipText("Make rings smaller");
    minusButton.addMouseListener(new RepeatingMouseAdapter(display, new SlowFastRunnable() {
        @Override
        public void run() {
            DiffractionCalibrationUtils.changeRings(currentData, ManipulateMode.SHRINK, isFast());
        }

        @Override
        public void stop() {
            if (tableViewer != null)
                tableViewer.refresh();
        }
    }));
    minusButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true));

    Composite shapeComp = new Composite(actionComp, SWT.NONE);
    shapeComp.setLayout(new GridLayout(1, false));
    shapeComp.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, true, true));
    shapeComp.setToolTipText("Change shape");
    GridUtils.removeMargins(shapeComp);

    Button elongateButton = new Button(shapeComp, SWT.PUSH);
    elongateButton.setText("Elongate");
    elongateButton.setToolTipText("Make rings more elliptical");
    elongateButton.addMouseListener(new RepeatingMouseAdapter(display, new SlowFastRunnable() {
        @Override
        public void run() {
            DiffractionCalibrationUtils.changeRings(currentData, ManipulateMode.ELONGATE, isFast());
        }

        @Override
        public void stop() {
            if (tableViewer != null)
                tableViewer.refresh();
        }
    }));
    elongateButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true));
    Button squashButton = new Button(shapeComp, SWT.PUSH | SWT.FILL);
    squashButton.setText("Squash");
    squashButton.setToolTipText("Make rings more circular");
    squashButton.addMouseListener(new RepeatingMouseAdapter(display, new SlowFastRunnable() {
        @Override
        public void run() {
            DiffractionCalibrationUtils.changeRings(currentData, ManipulateMode.SQUASH, isFast());
        }

        @Override
        public void stop() {
            if (tableViewer != null)
                tableViewer.refresh();
        }
    }));
    squashButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true));

    Composite rotateComp = new Composite(actionComp, SWT.NONE);
    rotateComp.setLayout(new GridLayout(1, false));
    rotateComp.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, true, true));
    rotateComp.setToolTipText("Change rotation");
    GridUtils.removeMargins(rotateComp);

    Button clockButton = new Button(rotateComp, SWT.PUSH);
    clockButton.setImage(Activator.getImage("icons/arrow_rotate_clockwise.png"));
    clockButton.setToolTipText("Rotate rings clockwise");
    clockButton.addMouseListener(new RepeatingMouseAdapter(display, new SlowFastRunnable() {
        @Override
        public void run() {
            DiffractionCalibrationUtils.changeRings(currentData, ManipulateMode.CLOCKWISE, isFast());
        }

        @Override
        public void stop() {
            if (tableViewer != null)
                tableViewer.refresh();
        }
    }));
    clockButton.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));
    Button antiClockButton = new Button(rotateComp, SWT.PUSH);
    antiClockButton.setImage(Activator.getImage("icons/arrow_rotate_anticlockwise.png"));
    antiClockButton.setToolTipText("Rotate rings anti-clockwise");
    antiClockButton.addMouseListener(new RepeatingMouseAdapter(display, new SlowFastRunnable() {
        @Override
        public void run() {
            DiffractionCalibrationUtils.changeRings(currentData, ManipulateMode.ANTICLOCKWISE, isFast());
        }

        @Override
        public void stop() {
            if (tableViewer != null)
                tableViewer.refresh();
        }
    }));
    antiClockButton.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));

    Button setBeamCentreButton = new Button(controllerHolder, SWT.PUSH);
    setBeamCentreButton.setText("Apply beam centre");
    setBeamCentreButton.setToolTipText("Apply current beam centre to all the images");
    setBeamCentreButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
    setBeamCentreButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            if (currentData == null)
                return;
            DetectorProperties properties = currentData.getMetaData().getDetector2DProperties();
            double[] coords = properties.getBeamCentreCoords();
            if (manager.isValidModel())
                return;
            for (DiffractionTableData dd : manager.iterable()) {
                dd.getMetaData().getDetector2DProperties().setBeamCentreCoords(coords);
            }
        }
    });

    Button findRingButton = new Button(controllerHolder, SWT.PUSH);
    findRingButton.setText("Match rings to image");
    findRingButton.setToolTipText("Use pixel values to find rings in image near calibration rings");
    findRingButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
    findRingButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (CalibrantPositioningWidget.this.ringFinder != null) {

                ProgressMonitorDialog dia = new ProgressMonitorDialog(Display.getCurrent().getActiveShell());
                try {
                    dia.run(true, true, CalibrantPositioningWidget.this.ringFinder);
                } catch (InvocationTargetException e1) {
                    // TODO Auto-generated catch block
                    MessageDialog.openError(Display.getCurrent().getActiveShell(), "Calibration Error",
                            "An error occured during ring finding, please contact your support representative: "
                                    + e1.getTargetException().getLocalizedMessage());
                } catch (InterruptedException e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                }
                updateAfterRingFinding();
            }
        }
    });
}

From source file:org.dawnsci.conversion.ui.pages.AlignImagesConversionPage.java

License:Open Source License

private void align(final RectangularROI roi) {
    if (alignProgressJob == null) {
        alignProgressJob = new AlignProgressJob();
    }//from  w ww.  java2s . co  m
    alignProgressJob.setRectangularROI(roi);
    alignProgressJob.setMode(mode);
    alignProgressJob.setData(data);
    alignProgressJob.setAlignMethod(alignState);
    ProgressMonitorDialog alignProgress = new ProgressMonitorDialog(Display.getCurrent().getActiveShell());
    alignProgress.setCancelable(true);
    try {
        alignProgress.run(true, true, alignProgressJob);
    } catch (InvocationTargetException e1) {
        MessageDialog.openError(Display.getCurrent().getActiveShell(), "Alignment Error",
                "An error occured during alignment: " + e1.getTargetException().getLocalizedMessage());
    } catch (InterruptedException e1) {
        e1.printStackTrace();
    }
    aligned = alignProgressJob.getShiftedImages();
    sliderButtons.get(1).setEnabled(aligned != null);
    sliderButtons.get(0).setSelection(false);
    sliderButtons.get(1).setSelection(true);
    showCorrected = true;
}