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

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

Introduction

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

Prototype

public ProgressMonitorDialog(Shell parent) 

Source Link

Document

Creates a progress monitor dialog under the given shell.

Usage

From source file:ch.elexis.extdoc.dialogs.MoveIntoSubDirsDialog.java

License:Open Source License

public void run() {
    if (logger == null)
        logger = LoggerFactory.getLogger(this.getClass());
    logger.info("MoveIntoSubDirsDialog started"); //$NON-NLS-1$

    ProgressMonitorDialog dialog = new ProgressMonitorDialog(null);
    try {//from   w  ww  . j a  v a  2s. c o  m
        dialog.run(true, true, new IRunnableWithProgress() {
            public void run(IProgressMonitor monitor) {
                int nrTreated = 0;
                java.util.List<File> oldFiles = MatchPatientToPath.getAllOldConventionFiles();
                int nrFiles = oldFiles.size();
                String dialogTitle = String.format("Alle (%1d) Dateien in Unterverzeichnisse auslagern ...", //$NON-NLS-1$
                        nrFiles);
                logger.info(dialogTitle);
                if (oldFiles == null) {
                    SWTHelper.showInfo(dialogTitle, Messages.MoveIntoSubDirsDialog_no_old_Files_found);
                    return;
                }
                monitor.beginTask(dialogTitle, oldFiles.size());
                Iterator<File> iterator = oldFiles.iterator();
                while (iterator.hasNext()) {
                    if (monitor.isCanceled())
                        break;
                    File f = iterator.next();
                    logger.info("Moving " + f.getAbsolutePath()); //$NON-NLS-1$
                    MatchPatientToPath.MoveIntoSubDir(f.getAbsolutePath());
                    ++nrTreated;
                    if (nrTreated % 10 == 1) {
                        monitor.subTask(String.format(Messages.MoveIntoSubDirsDialog_sub_task, f.getName()));
                        monitor.worked(10);
                    }
                }
                monitor.done();
                logger.info("MoveIntoSubDirsDialog done"); //$NON-NLS-1$
                SWTHelper.showInfo(dialogTitle, Messages.MoveIntoSubDirsDialog_finished);
            }
        });
    } catch (InvocationTargetException e) {
        e.printStackTrace();
        SWTHelper.showInfo("Fehler beim Auslagern!!",
                Messages.MoveIntoSubDirsDialog_finished + "\n" + e.getMessage());
        logger.info("Fehler beim Auslagern!!" + e.getLocalizedMessage()); //$NON-NLS-1$
    } catch (InterruptedException e) {
        e.printStackTrace();
        SWTHelper.showInfo("Fehler beim Auslagern!",
                Messages.MoveIntoSubDirsDialog_finished + "\n" + e.getMessage());
        logger.info("Fehler beim Auslagern!!" + e.getLocalizedMessage()); //$NON-NLS-1$
    }
    return;
}

From source file:ch.elexis.icpc.fire.handlers.ExportFireHandler.java

License:Open Source License

/**
 * the command has been executed, so extract extract the needed information from the application
 * context.// w w w.j av  a  2s  . c o m
 */
public Object execute(ExecutionEvent event) throws ExecutionException {
    String lastupdate = CoreHub.globalCfg.get(CFGPARAM, null);
    if (lastupdate == null) {
        lastupdate = "20090101";
    }
    Query<Konsultation> qbe = new Query<Konsultation>(Konsultation.class);
    TimeTool ttFrom = new TimeTool(lastupdate);
    ttFrom.addHours(Report.EXPORT_DELAY * -1);
    qbe.add(Konsultation.DATE, Query.GREATER, ttFrom.toString(TimeTool.DATE_COMPACT));
    TimeTool ttTo = new TimeTool();
    ttTo.addHours(Report.EXPORT_DELAY * -1);
    qbe.add(Konsultation.DATE, Query.LESS_OR_EQUAL, ttTo.toString(TimeTool.DATE_COMPACT));
    List<Konsultation> konsen = qbe.execute();
    if (konsen.size() > 0) {
        FileDialog fd = new FileDialog(Hub.getActiveShell(), SWT.SAVE);
        fd.setFileName("elexis-fire" + new TimeTool().toString(TimeTool.DATE_COMPACT) + ".xml");
        fd.setFilterExtensions(new String[] { "xml" });
        fd.setFilterNames(new String[] { "XML-Dateien" });
        String expath = fd.open();
        if (expath != null) {
            ProgressMonitorDialog progress = new ProgressMonitorDialog(HandlerUtil.getActiveShell(event));
            try {
                progress.run(true, true, new ReportExportRunnable(konsen, expath));
            } catch (InvocationTargetException | InterruptedException e) {
                logger.warn("Exception during FIRE export", e);
            }
        }
    }
    return null;
}

From source file:ch.elexis.TarmedRechnung.XMLExporter.java

License:Open Source License

/**
 * Output a Collection of bills. This essentially lets the user modify the output settings (if
 * any) and then calls doExport() fr each bill in rnn
 * /*from   w w  w.  ja  v a  2 s  . c  om*/
 * @param type
 *            desired mode (original, copy, storno)
 * @param rnn
 *            a Collection of Rechnung - Objects to output
 */
@Override
public Result<Rechnung> doOutput(final IRnOutputter.TYPE type, final Collection<Rechnung> rnn,
        Properties props) {
    Result<Rechnung> ret = new Result<Rechnung>();
    if (outputDir == null) {
        SWTHelper.SimpleDialog dlg = new SWTHelper.SimpleDialog(new SWTHelper.IControlProvider() {
            @Override
            public Control getControl(Composite parent) {
                return createSettingsControl(parent);
            }

            @Override
            public void beforeClosing() {
                // Nothing
            }
        });
        if (dlg.open() != Dialog.OK) {
            return ret;
        }
    }
    ProgressMonitorDialog progress = new ProgressMonitorDialog(Display.getDefault().getActiveShell());
    try {
        progress.run(true, true, new IRunnableWithProgress() {

            @Override
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                monitor.beginTask(Messages.RechnungsDrucker_PrintingBills, rnn.size());
                for (Rechnung rn : rnn) {
                    if (doExport(rn, outputDir + File.separator + rn.getNr() + ".xml", type, //$NON-NLS-1$
                            false) == null) {
                        ret.add(Result.SEVERITY.ERROR, 1, Messages.XMLExporter_ErrorInBill + rn.getNr(), rn,
                                true);
                    }
                    monitor.worked(1);
                    if (monitor.isCanceled()) {
                        break;
                    }
                }
                monitor.done();
            }
        });

    } catch (InvocationTargetException | InterruptedException e) {
        LoggerFactory.getLogger(XMLExporter.class).error("Error outputting bills", e);
        MessageDialog.openError(Display.getDefault().getActiveShell(),
                Messages.RechnungsDrucker_MessageErrorWhilePrinting,
                Messages.RechnungsDrucker_MessageErrorWhilePrinting + "[" + e.getMessage() + "]");
    }
    return ret;
}

From source file:ch.hsr.ifs.cdt.metriculator.tagcloud.views.TagCloudViewPart.java

License:Open Source License

private void createSideTab(SashForm form) {
    Composite parent = new Composite(form, SWT.NONE);
    parent.setLayout(new GridLayout());
    parent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    options = new CloudOptionsComposite(parent, SWT.NONE, viewer) {

        protected Group addLayoutButtons(Composite parent) {
            Group buttons = super.addLayoutButtons(parent);

            Label l = new Label(buttons, SWT.NONE);
            l.setText("Scale");
            final Combo scale = new Combo(buttons, SWT.DROP_DOWN | SWT.READ_ONLY);
            scale.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
            scale.setItems(new String[] { "linear", "logarithmic" });
            scale.select(1);// w  w  w  .  j  a v a2 s . c om
            scale.addSelectionListener(new SelectionListener() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    switch (scale.getSelectionIndex()) {
                    case 0:
                        labelProvider.setScale(TypeLabelProvider.Scaling.LINEAR);
                        break;
                    case 1:
                        labelProvider.setScale(TypeLabelProvider.Scaling.LOGARITHMIC);
                        break;
                    default:
                        break;
                    }
                }

                @Override
                public void widgetDefaultSelected(SelectionEvent e) {
                }
            });
            l = new Label(buttons, SWT.NONE);
            l.setText("X Axis Variation");
            final Combo xAxis = new Combo(buttons, SWT.DROP_DOWN | SWT.READ_ONLY);
            xAxis.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
            xAxis.setItems(new String[] { "0", "10", "20", "30", "40", "50", "60", "70", "80", "90", "100" });
            xAxis.select(2);
            xAxis.addSelectionListener(new SelectionListener() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    String item = xAxis.getItem(xAxis.getSelectionIndex());
                    layouter.setOption(DefaultLayouter.X_AXIS_VARIATION, Integer.parseInt(item));

                }

                @Override
                public void widgetDefaultSelected(SelectionEvent e) {
                }
            });

            l = new Label(buttons, SWT.NONE);
            l.setText("Y Axis Variation");
            final Combo yAxis = new Combo(buttons, SWT.DROP_DOWN | SWT.READ_ONLY);
            yAxis.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
            yAxis.setItems(new String[] { "0", "10", "20", "30", "40", "50", "60", "70", "80", "90", "100" });
            yAxis.select(1);
            yAxis.addSelectionListener(new SelectionListener() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    String item = yAxis.getItem(yAxis.getSelectionIndex());
                    layouter.setOption(DefaultLayouter.Y_AXIS_VARIATION, Integer.parseInt(item));
                }

                @Override
                public void widgetDefaultSelected(SelectionEvent e) {
                }
            });

            Button run = new Button(buttons, SWT.NONE);
            run.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
            run.setText("Re-Position");
            run.addSelectionListener(new SelectionListener() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    final ProgressMonitorDialog dialog = new ProgressMonitorDialog(
                            viewer.getControl().getShell());
                    dialog.setBlockOnOpen(false);
                    dialog.open();
                    dialog.getProgressMonitor().beginTask("Layouting tag cloud...", 100);
                    viewer.reset(dialog.getProgressMonitor(), false);
                    dialog.close();
                }

                @Override
                public void widgetDefaultSelected(SelectionEvent e) {
                }
            });
            Button layout = new Button(buttons, SWT.NONE);
            layout.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
            layout.setText("Re-Layout");
            layout.addSelectionListener(new SelectionListener() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    ProgressMonitorDialog dialog = new ProgressMonitorDialog(viewer.getControl().getShell());
                    dialog.setBlockOnOpen(false);
                    dialog.open();
                    dialog.getProgressMonitor().beginTask("Layouting tag cloud...", 200);
                    viewer.setInput(viewer.getInput(), dialog.getProgressMonitor());
                    viewer.reset(dialog.getProgressMonitor(), false);
                    dialog.close();
                }

                @Override
                public void widgetDefaultSelected(SelectionEvent e) {
                }
            });
            return buttons;
        };

    };
    GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
    options.setLayoutData(gd);
}

From source file:ch.hsr.ifs.cutelauncher.CuteLaunchShortcut.java

License:Open Source License

/**
 * Method searchAndLaunch./*from   w  w w  .  j a  va2s.  c  o m*/
 * @param objects
 * @param mode
 */
private void searchAndLaunch(final Object[] elements, String mode) {
    if (elements != null && elements.length > 0) {
        IBinary bin = null;
        if (elements.length == 1 && elements[0] instanceof IBinary) {
            bin = (IBinary) elements[0];
        } else {
            final List<IBinary> results = new ArrayList<IBinary>();
            ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell());
            IRunnableWithProgress runnable = new RunnableWithProgressToScanForExecutableImpl(elements, results);

            try {
                dialog.run(true, true, runnable);
            } catch (InterruptedException e) {
                return;
            } catch (InvocationTargetException e) {
                MessageDialog.openError(getShell(),
                        LaunchMessages.getString("CApplicationLaunchShortcut.Application_Launcher"), //$NON-NLS-1$
                        e.getMessage());
                return;
            }

            int count = results.size();
            if (count == 0) {
                MessageDialog.openError(getShell(),
                        LaunchMessages.getString("CApplicationLaunchShortcut.Application_Launcher"), //$NON-NLS-1$
                        LaunchMessages.getString("CApplicationLaunchShortcut.Launch_failed_no_binaries")); //$NON-NLS-1$
            } else if (count > 1) {
                bin = chooseBinary(results, mode);
            } else {
                bin = results.get(0);
            }
        }

        if (bin != null) {
            launch(bin, mode);
        }
    } else {
        MessageDialog.openError(getShell(),
                LaunchMessages.getString("CApplicationLaunchShortcut.Application_Launcher"), //$NON-NLS-1$
                LaunchMessages.getString("CApplicationLaunchShortcut.Launch_failed_no_project_selected")); //$NON-NLS-1$
    }
}

From source file:ch.novcom.elexis.mednet.plugin.ui.commands.GetResult.java

License:Open Source License

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {

    ProgressMonitorDialog progress = new ProgressMonitorDialog(HandlerUtil.getActiveShell(event));

    try {//from  w  ww .j  a v  a2  s.c om
        progress.run(true, false, new IRunnableWithProgress() {

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

                DocumentImporterPage dip = new DocumentImporterPage();
                try {
                    dip.doImport(monitor);
                } catch (Exception e) {
                    LOGGER.error("execute() - " + "Exception calling doImport", e);//$NON-NLS-1$
                }

            }
        });

    } catch (InvocationTargetException | InterruptedException e) {
        MessageDialog.openError(HandlerUtil.getActiveShell(event), "Fehler",
                "Fehler beim PDF erzeugen.\n" + e.getMessage());
    }

    return null;
}

From source file:cn.cstv.wspscm.editor.PSCMonitorDiagramEditor.java

License:Open Source License

public void doSaveAs() {
    SaveAsDialog dialog = new SaveAsDialog(getSite().getWorkbenchWindow().getShell());
    dialog.setOriginalFile(((IFileEditorInput) getEditorInput()).getFile());
    dialog.open();/*from  w  w w . jav  a  2s  .  c om*/
    IPath path = dialog.getResult();

    if (path == null)
        return;

    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    final IFile file = workspace.getRoot().getFile(path);

    WorkspaceModifyOperation op = new WorkspaceModifyOperation() {
        public void execute(final IProgressMonitor monitor) throws CoreException {
            try {
                ByteArrayOutputStream out = new ByteArrayOutputStream();
                createOutputStream(out);
                file.create(new ByteArrayInputStream(out.toByteArray()), true, monitor);
                out.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    };

    try {
        new ProgressMonitorDialog(getSite().getWorkbenchWindow().getShell()).run(false, true, op);
        setInput(new FileEditorInput((IFile) file));
        getCommandStack().markSaveLocation();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:cn.dockerfoundry.ide.eclipse.server.ui.internal.wizards.DockerFoundryServiceWizardPage.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 ww.j  av  a2  s . c om

        final GetServiceOfferingsRunnable runnable = new GetServiceOfferingsRunnable();

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

        // If the user cancelled service acquisition, then just return null.
        if (runnable.isUserCancelled()) {
            return null;
        }

        if (runnable.getServiceOfferingResult() != null) {
            int index = 0;
            for (DockerContainerElement o : runnable.getServiceOfferingResult()) {
                String name = o.getName();
                String image = "Image: " + o.getImage();
                result.add(new AvailableService(name, image, index, o));
                index++;
            }
        }
    } catch (InvocationTargetException e) {
        IStatus status = cloudServer.error(NLS.bind(
                Messages.DockerFoundryServiceWizardPage_ERROR_CONFIG_RETRIVE, e.getCause().getMessage()), 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:cn.edu.pku.ogeditor.ShapesEditor.java

License:Open Source License

/**
 * save the current .ogeditor-file as .owl-file.
 * //from  ww  w .j a v a 2  s  .c  o  m
 * @see org.eclipse.ui.ISaveablePart#doSaveAs()
 */
public void doSaveAs() {
    // Show a SaveAs dialog
    Shell shell = getSite().getWorkbenchWindow().getShell();
    SaveAsDialog dialog = new SaveAsDialog(shell);
    dialog.setOriginalFile(((IFileEditorInput) getEditorInput()).getFile());
    dialog.open();
    IPath path = dialog.getResult();

    if (path != null) {
        System.out.println("dosaveas:path not null");
        // save as owl file
        String fileextension = path.getFileExtension();
        String filepath = Platform.getLocation().toString() + path.toString();

        if (fileextension.equals("owl") || fileextension.equals("rdf") || fileextension.equals("ttl")) {
            System.out.println("dosaveas: is .owl");
            System.out.println("path:" + filepath);
            System.out.println("ws: " + ResourcesPlugin.getWorkspace());

            SaveAsOWL(filepath, fileextension);

        } else {
            System.out.println("dosaveas: not .owl");
            // try to save the editor's contents under a different file name
            final IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
            try {
                new ProgressMonitorDialog(shell).run(false, // don't fork
                        false, // not cancelable
                        new WorkspaceModifyOperation() { // run this
                            // operation
                            public void execute(final IProgressMonitor monitor) {
                                try {
                                    ByteArrayOutputStream out = new ByteArrayOutputStream();
                                    createOutputStream(out);
                                    file.create(new ByteArrayInputStream(out.toByteArray()), // contents
                                            true, // keep saving, even if
                                            // IFile is out of sync
                                            // with the Workspace
                                            monitor); // progress monitor
                                } catch (CoreException ce) {
                                    ce.printStackTrace();
                                } catch (IOException ioe) {
                                    ioe.printStackTrace();
                                }
                            }
                        });
                // set input to the new file
                setInput(new FileEditorInput(file));
                getCommandStack().markSaveLocation();
            } catch (InterruptedException ie) {
                // should not happen, since the monitor dialog is not
                // cancelable
                ie.printStackTrace();
            } catch (InvocationTargetException ite) {
                ite.printStackTrace();
            }
        }
    }
}

From source file:com.aliyun.odps.eclipse.create.wizard.NewDriverWizardPage.java

License:Apache License

private Text createBrowseClassControl(final Composite composite, final String string, String browseButtonLabel,
        final String baseClassName, final String dialogTitle) {
    Label label = new Label(composite, SWT.NONE);
    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    label.setText(string);// www  . j  av  a 2  s .c o  m
    label.setLayoutData(data);

    final Text text = new Text(composite, SWT.SINGLE | SWT.BORDER);
    GridData data2 = new GridData(GridData.FILL_HORIZONTAL);
    data2.horizontalSpan = 2;
    text.setLayoutData(data2);

    Button browse = new Button(composite, SWT.NONE);
    browse.setText(browseButtonLabel);
    GridData data3 = new GridData(GridData.FILL_HORIZONTAL);
    browse.setLayoutData(data3);
    browse.addListener(SWT.Selection, new Listener() {
        public void handleEvent(Event event) {
            IType baseType;
            try {
                baseType = getPackageFragmentRoot().getJavaProject().findType(baseClassName);

                // edit this to limit the scope
                SelectionDialog dialog = JavaUI.createTypeDialog(composite.getShell(),
                        new ProgressMonitorDialog(composite.getShell()),
                        SearchEngine.createHierarchyScope(baseType),
                        IJavaElementSearchConstants.CONSIDER_CLASSES, false);

                dialog.setMessage("&Choose a type:");
                dialog.setBlockOnOpen(true);
                dialog.setTitle(dialogTitle);
                dialog.open();

                if ((dialog.getReturnCode() == Window.OK) && (dialog.getResult().length > 0)) {
                    IType type = (IType) dialog.getResult()[0];
                    text.setText(type.getFullyQualifiedName());
                }
            } catch (JavaModelException e) {
                e.printStackTrace();
            }
        }
    });

    if (!showContainerSelector) {
        label.setEnabled(false);
        text.setEnabled(false);
        browse.setEnabled(false);
    }

    return text;
}