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:com.testify.ecfeed.ui.modelif.StaticTestExecutionSupport.java

License:Open Source License

public void proceed() {
    PrintStream currentOut = System.out;
    ConsoleManager.displayConsole();//from   w  w w .  j av  a2 s . c  o m
    ConsoleManager.redirectSystemOutputToStream(ConsoleManager.getOutputStream());
    try {
        fFailedTests.clear();
        ProgressMonitorDialog dialog = new ProgressMonitorDialog(Display.getCurrent().getActiveShell());
        dialog.open();
        dialog.run(true, true, new ExecuteRunnable());
    } catch (InvocationTargetException e) {
        MessageDialog.openError(Display.getCurrent().getActiveShell(),
                Messages.DIALOG_TEST_EXECUTION_PROBLEM_TITLE, e.getTargetException().getMessage());
    } catch (InterruptedException e) {
        MessageDialog.openError(Display.getCurrent().getActiveShell(),
                Messages.DIALOG_TEST_EXECUTION_PROBLEM_TITLE, e.getMessage());
    }
    if (fFailedTests.size() > 0) {
        String message = "Following tests were not successfull\n\n";
        for (TestCaseNode testCase : fFailedTests) {
            message += testCase.toString() + "\n";
        }
        MessageDialog.openError(Display.getCurrent().getActiveShell(),
                Messages.DIALOG_TEST_EXECUTION_REPORT_TITLE, message);
    }
    displayTestStatusDialog(fTestCases.size());

    System.setOut(currentOut);
}

From source file:com.toubassi.filebunker.ui.backup.BackupController.java

License:Open Source License

private void performBackup() {
    Shell shell = getShell();/*  www  .j av a2  s  .c o  m*/

    if (!vault.isConfigured()) {

        String[] buttons = new String[] { "Configure", "Cancel" };

        MessageDialog dialog = new MessageDialog(shell, "Backup", null,
                "You cannot perform a backup until FileBunker has been "
                        + "configured.  You can select the Configure button "
                        + "below or select Configuration from the File menu " + "at any time.",
                MessageDialog.INFORMATION, buttons, 0);
        int selectedButton = dialog.open();

        if (selectedButton == 0) {
            configurationAction.run();
        }
        return;
    }

    BackupResult result = new BackupResult();
    PerformBackup performBackup = new PerformBackup(vault, backupSpec, result, false);

    try {
        new ProgressMonitorDialog(shell).run(true, true, performBackup);

        String message;
        if (result.numberOfFiles() == 0) {
            message = "No files are in need of backup.";
        } else {
            message = formatBackupResultMessage(result, performBackup.estimate(), false);
        }
        MessageDialog.openInformation(shell, "Backup Complete", message);

    } catch (InvocationTargetException e) {
        handleBackupException(e, result, performBackup.estimate());
    } catch (InterruptedException e) {
        handleBackupException(e, result, performBackup.estimate());
    }
}

From source file:com.toubassi.filebunker.ui.backup.BackupController.java

License:Open Source License

private void performPreview() {
    boolean backupNow = false;
    Shell shell = getShell();//w  w w  .  ja  v a  2  s  . com

    PerformBackup performBackup = new PerformBackup(vault, backupSpec, null, true);

    try {
        new ProgressMonitorDialog(shell).run(true, true, performBackup);

        BackupEstimate estimate = performBackup.estimate();
        if (estimate.numberOfDirtyFiles() == 0) {
            MessageDialog.openInformation(shell, "Backup Preview", "No files are in need of backup.");
        } else {
            backupNow = (new PreviewDialog(shell, performBackup.estimate())).run();
        }
    } catch (InvocationTargetException e) {
        handlePreviewException(e);
    } catch (InterruptedException e) {
        handlePreviewException(e);
    }

    if (backupNow) {
        performBackup();
    }
}

From source file:com.toubassi.filebunker.ui.restore.RestoreController.java

License:Open Source License

public void restore(RestoreSpecification restoreSpec) {
    Shell shell = getShell();/*from   w w  w  . j a v  a  2 s  .  co m*/

    if (!vault.isConfigured()) {

        String[] buttons = new String[] { "Configure", "Cancel" };

        MessageDialog dialog = new MessageDialog(shell, "Backup", null,
                "You cannot restore files until FileBunker has been "
                        + "configured.  You can select the Configure button "
                        + "below or select Configuration from the File menu " + "at any time.",
                MessageDialog.INFORMATION, buttons, 0);
        int selectedButton = dialog.open();

        if (selectedButton == 0) {
            configurationAction.run();
        }
        return;
    }

    String restorePath;
    ArrayList revisions = restoreSpec.revisions();
    boolean singleFileSelected = revisions.size() == 1 && !((Revision) revisions.get(0)).isDirectory();

    if (singleFileSelected) {
        FileRevision revision = (FileRevision) revisions.get(0);
        File proposedFile = proposedFileRestoreLocation(revision.node().file());

        FileDialog dialog = new FileDialog(getShell(), SWT.SAVE);
        dialog.setFilterPath(proposedFile.getParent());
        dialog.setFileName(proposedFile.getName());

        restorePath = dialog.open();
    } else {

        DirectoryDialog dialog = new DirectoryDialog(getShell());

        if (revisions.size() == 1) {
            dialog.setMessage("Choose the name that the selected folder "
                    + "will be restored as.  For files that already exist "
                    + "on disk, unique names will be used so that no " + "files are overwritten.");
        } else {
            dialog.setMessage("Choose the folder into which the selected files "
                    + "will be restored.  For files that already exist "
                    + "on disk, unique names will be used so that no " + "files are overwritten.");
        }
        dialog.setFilterPath(spec.commonPath());

        restorePath = dialog.open();
    }

    if (restorePath == null) {
        return;
    }

    File restoreRoot = new File(restorePath);

    if (singleFileSelected && restoreRoot.exists()) {
        MessageBox dialog = new MessageBox(getShell(), SWT.ICON_WARNING | SWT.YES | SWT.NO);

        dialog.setMessage(restoreRoot.getName() + " already exists.  Do you want to replace it?");

        if (dialog.open() != SWT.YES) {
            return;
        }
    }

    RestoreResult result = new RestoreResult();
    PerformRestore performRestore = new PerformRestore(vault, restoreSpec, restoreRoot, result);

    try {
        new ProgressMonitorDialog(shell).run(true, true, performRestore);

        String message;
        if (result.numberOfFiles() == 0) {
            message = "No files were restored.";
        } else {
            message = formatRestoreResultMessage(result, performRestore.estimate(), false);
        }
        MessageDialog.openInformation(shell, "Restore Complete", message);
    } catch (InvocationTargetException e) {
        handleException(e, restoreSpec, result, performRestore.estimate());
    } catch (InterruptedException e) {
        handleException(e, restoreSpec, result, performRestore.estimate());
    }
}

From source file:com.versant.core.jdo.tools.plugins.eclipse.editor.DDLEditor.java

License:Open Source License

public DDLEditor() {
    super();//from w w  w.  ja  v  a  2 s. c o  m
    //      setSourceViewerConfiguration(new TextSourceViewerConfiguration());
    setDocumentProvider(new AbstractDocumentProvider() {
        protected IAnnotationModel createAnnotationModel(Object element) throws CoreException {
            return null;
        }

        protected IDocument createDocument(Object element) throws CoreException {
            return new Document(s);
        }

        protected void doSaveDocument(IProgressMonitor monitor, Object element, IDocument document,
                boolean overwrite) throws CoreException {
        }

        protected IRunnableContext getOperationRunner(IProgressMonitor monitor) {
            return new ProgressMonitorDialog(getSite().getShell());
        }
    });
}

From source file:com.verticon.treatment.poi.handlers.EventImportHandler.java

License:Open Source License

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    ex = null;/*w  w  w  .  j  av a 2s  .  c  o m*/
    message = new StringBuffer("Imported: ");
    IEditorPart editorPart = HandlerUtil.getActiveEditorChecked(event);

    EditingDomain editingDomain = ((IEditingDomainProvider) editorPart.getAdapter(IEditingDomainProvider.class))
            .getEditingDomain();

    Resource r = editingDomain.getResourceSet().getResources().get(0);
    EObject o = r.getContents().get(0);
    if (!(o instanceof Program)) {
        MessageDialog.openError(HandlerUtil.getActiveShell(event), "Event Import Failed",
                "Treatment Document must contain a Program Element");
        return false;
    }

    Program program = (Program) o;

    IRunnableWithProgress op = new WorkspaceModifyDelegatingOperation(getRunnable(program,
            (IStructuredSelection) HandlerUtil.getActiveMenuSelectionChecked(event), editingDomain));

    ProgressMonitorDialog dialog = new ProgressMonitorDialog(HandlerUtil.getActiveShell(event));
    try {
        dialog.run(false, true, op);

        if (ex == null) {
            MessageDialog.openInformation(HandlerUtil.getActiveShell(event), "Event Data Import",
                    message.toString());
        } else {
            MessageDialog.openError(HandlerUtil.getActiveShell(event), "Event Data Import Failed",
                    ex.getMessage());
        }

    } catch (InvocationTargetException e) {
        MessageDialog.openError(HandlerUtil.getActiveShell(event), "Event Data Import Failed", e.getMessage());
    } catch (InterruptedException e) {
        // Restore the interrupted status
        Thread.currentThread().interrupt();
    }
    return null;
}

From source file:com.verticon.treatment.poi.handlers.NamingImportHandler.java

License:Open Source License

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

    IEditorPart editorPart = HandlerUtil.getActiveEditorChecked(event);

    IRunnableWithProgress op = new WorkspaceModifyDelegatingOperation(
            getRunnable((IStructuredSelection) HandlerUtil.getActiveMenuSelectionChecked(event),
                    Activator.getDefault(), editorPart));

    ProgressMonitorDialog dialog = new ProgressMonitorDialog(HandlerUtil.getActiveShell(event));
    try {// w  ww . j  ava 2 s  . c  o m
        dialog.run(false, true, op);

        if (ex == null) {
            MessageDialog.openInformation(HandlerUtil.getActiveShell(event), "Name Data Import",
                    message.toString());
        } else {
            MessageDialog.openError(HandlerUtil.getActiveShell(event), "Name Data Import Failed",
                    ex.getMessage());
        }

    } catch (InvocationTargetException e) {
        MessageDialog.openError(HandlerUtil.getActiveShell(event), "Name Data Import Failed", e.getMessage());
    } catch (InterruptedException e) {
        // Restore the interrupted status
        Thread.currentThread().interrupt();
    }
    return null;
}

From source file:com.wincom.actor.editor.flow.ui.FlowEditor.java

License:Open Source License

/**
 * @see org.eclipse.ui.ISaveablePart#doSaveAs()
 *//*from ww  w.j  a va  2s  .  c om*/
public void doSaveAs() {
    log.info("check");
    SaveAsDialog dialog = new SaveAsDialog(getSite().getWorkbenchWindow().getShell());
    dialog.setOriginalFile(((IFileEditorInput) getEditorInput()).getFile());
    dialog.open();
    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 {
            log.info("check");
            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:com.windowtester.eclipse.ui.convert.ui.WTAPIUsageAction.java

License:Open Source License

/**
 * Called to perform the conversion./*from w ww  . j  av a 2 s  .c o m*/
 */
public void run(IAction action) {
    if (selected == null || selected.size() == 0)
        return;
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    Shell shell = window.getShell();
    try {
        final WTAPIUsage usage = new WTAPIUsage();
        new ProgressMonitorDialog(shell).run(true, true, new IRunnableWithProgress() {
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                try {
                    usage.scan(selected, monitor);
                } catch (Exception e) {
                    throw new InvocationTargetException(e);
                }
            }
        });
        window.getActivePage().openEditor(new WTAPIUsageEditorInput(usage), "org.eclipse.ui.DefaultTextEditor");
    } catch (OperationCanceledException e) {
        // Ignored... Operation canceled by user
    } catch (Exception e) {
        // TODO integrate the Bug Submission form
        if (e instanceof InvocationTargetException)
            e = (Exception) ((InvocationTargetException) e).getCause();
        String errMsg = "WindowTester API scanning exception: " + e;
        Logger.log(errMsg, e);
        new ExceptionDetailsDialog(shell, "Code Conversion Exception", errMsg, e).open();
    }
}

From source file:com.windowtester.eclipse.ui_tool.WTConvertAPIContextBuilderTool.java

License:Open Source License

/**
 * Scan the workspace and create the files.
 *//*from   w  w  w.  java 2  s.c o  m*/
public Object execute(ExecutionEvent event) throws ExecutionException {
    wbShell = HandlerUtil.getActiveWorkbenchWindow(event).getShell();

    // Instantiate the files to be written

    String ymdhms = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
    IFile wtTypesFile = getFile("wt-types", ymdhms);
    if (wtTypesFile == null)
        return null;
    IFile wtStaticMembersFile = getFile("wt-static-members", ymdhms);
    if (wtStaticMembersFile == null)
        return null;

    // Scan the workspace for WindowTester types and members

    try {
        new ProgressMonitorDialog(wbShell).run(true, true, new IRunnableWithProgress() {
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                try {
                    scanWorkspace(monitor);
                } catch (Exception e) {
                    throw new InvocationTargetException(e);
                }
            }
        });
    } catch (Exception e) {
        if (e instanceof InvocationTargetException)
            e = (InvocationTargetException) e;
        new ExceptionDetailsDialog(wbShell, "Exception",
                "Failed to generate content for " + wtTypesFile.getFullPath(), e).open();
        return null;
    }

    // Write the results to the files

    writeFile(wtTypesFile, wtTypes);
    writeFile(wtStaticMembersFile, wtStaticMembers);

    // Open the files in an editor

    try {
        IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
        IDE.openEditor(activePage, wtTypesFile);
        IDE.openEditor(activePage, wtStaticMembersFile);
    } catch (PartInitException e) {
        new ExceptionDetailsDialog(wbShell, "Exception", "Failed to open editors for generated files.", e);
    }

    return null;
}