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:com.genuitec.eclipse.gerrit.tools.internal.changes.commands.NewChangeBranchCommand.java

License:Open Source License

@Override
protected Object internalExecute(ExecutionEvent event) throws Exception {
    Shell shell = HandlerUtil.getActiveShell(event);

    Repository repository = RepositoryUtils.getRepository(HandlerUtil.getCurrentSelection(event));
    if (repository == null) {
        return null;
    }//  w w  w.  j  a  v a  2s .  co m

    //fetch remote branches
    RepositoryUtils.fetchOrigin(shell, repository);

    //configure branch creation
    CreateChangeBranchDialog createChangeBranchDialog = new CreateChangeBranchDialog(shell, repository);
    if (createChangeBranchDialog.open() != IDialogConstants.OK_ID) {
        return null;
    }
    //perform branch operation
    try {
        ProgressMonitorDialog progressDialog = new ProgressMonitorDialog(shell);
        final CreateChangeBranchOperation op = new CreateChangeBranchOperation(progressDialog.getShell(), event,
                repository, createChangeBranchDialog.getSettings());
        progressDialog.run(true, true, op);
    } catch (InterruptedException e) {
        //ignore
    }

    return null;
}

From source file:com.genuitec.eclipse.gerrit.tools.internal.fbranches.commands.CreateFeatureBranchCommand.java

License:Open Source License

@Override
protected void execute(ExecutionEvent event, List<Repository> repositories, String branchRef)
        throws ExecutionException {
    Shell shell = HandlerUtil.getActiveShell(event);

    //fetch remote branches
    for (Repository repository : repositories) {
        RepositoryUtils.fetchOrigin(shell, repository);
    }//  ww  w  . j  a v  a  2  s.  c om

    //configure branch creation
    CreateFeatureBranchDialog createFeatureBranchDialog = new CreateFeatureBranchDialog(shell, repositories);
    if (createFeatureBranchDialog.open() != IDialogConstants.OK_ID) {
        return;
    }

    String userId = RepositoryUtils.getUserId(repositories);

    //perform branch operation
    for (Repository repository : repositories) {
        try {
            ProgressMonitorDialog progressDialog = new ProgressMonitorDialog(shell);
            final CreateBranchOperation op = new CreateBranchOperation(progressDialog.getShell(), event,
                    repository, userId, createFeatureBranchDialog.getSettings());
            progressDialog.run(true, true, op);
        } catch (InterruptedException e) {
            //ignore
        } catch (Exception e) {
            RepositoryUtils.handleException(e);
        }
    }

    return;
}

From source file:com.genuitec.eclipse.gerrit.tools.internal.fbranches.commands.MergeStableIntoCurrentBranchCommand.java

License:Open Source License

@Override
protected void execute(ExecutionEvent event, List<Repository> repositories, String branchRef)
        throws ExecutionException {

    //perform branch operation
    Shell shell = HandlerUtil.getActiveShell(event);
    for (Repository repository : repositories) {
        try {//w  ww .j a  v a  2s.co  m
            if (!canMerge(repository)) {
                continue;
            }
            ProgressMonitorDialog progressDialog = new ProgressMonitorDialog(shell);
            final MergeStableIntoCurrentBranchOperation op = new MergeStableIntoCurrentBranchOperation(event,
                    branchRef, repository);
            progressDialog.run(true, true, op);
        } catch (InterruptedException e) {
            //ignore
        } catch (Exception e) {
            RepositoryUtils.handleException(e);
        }
    }

}

From source file:com.genuitec.eclipse.gerrit.tools.internal.gps.commands.ExportProjectsHandler.java

License:Open Source License

public Object execute(ExecutionEvent event) throws ExecutionException {
    Shell shell = HandlerUtil.getActiveShell(event);

    //first open the file
    FileDialog fd = new FileDialog(shell, SWT.SAVE);
    fd.setText("Export Gerrit Project Set file");
    fd.setFilterPath(ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString());
    String[] filterExt = { "*.gps" };
    fd.setOverwrite(true);//w  w w.  j  a va  2s .c  o m
    fd.setFilterExtensions(filterExt);
    String selected = fd.open();

    if (selected != null) {
        GpsFile gpsFile = new GpsFile();
        List<IProject> projects = new ExportProjectsDialog(shell).select();
        if (projects == null || projects.isEmpty()) {
            return null;
        }
        try {
            ProgressMonitorDialog progressDialog = new ProgressMonitorDialog(shell);
            progressDialog.run(true, true, new ExportOperation(gpsFile, progressDialog, projects));
            File f = new File(selected);
            if (f.isFile()) {
                f.delete();
            }
            FileOutputStream fos = new FileOutputStream(selected, false);
            try {
                gpsFile.saveToStream(fos);
            } finally {
                fos.close();
            }
        } catch (InterruptedException e) {
            //ignore
        } catch (Exception e) {
            GerritToolsPlugin.getDefault().getLog()
                    .log(new Status(IStatus.ERROR, GerritToolsPlugin.PLUGIN_ID, e.getLocalizedMessage(), e));
            MessageDialog.openError(shell, "Import", e.getLocalizedMessage());
        }
    }
    return null;
}

From source file:com.genuitec.eclipse.gerrit.tools.internal.gps.commands.ImportProjectsHandler.java

License:Open Source License

public Object execute(ExecutionEvent event) throws ExecutionException {
    Shell shell = HandlerUtil.getActiveShell(event);
    if (shell == null) {
        shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
    }/*  w w w  .  j a  v  a  2  s .  co m*/

    String fileName = event.getParameter("file"); //$NON-NLS-1$
    if (fileName == null) {
        //first open the file
        FileDialog fd = new FileDialog(shell, SWT.OPEN);
        fd.setText("Import Gerrit Project Set file");
        fd.setFilterPath(ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString());
        String[] filterExt = { "*.gps" }; //$NON-NLS-1$
        fd.setFilterExtensions(filterExt);
        fileName = fd.open();
    }

    if (fileName != null) {
        GpsFile gpsFile = new GpsFile();
        try {
            FileInputStream fis = new FileInputStream(fileName);
            try {
                gpsFile.loadFromStream(fis);
            } finally {
                fis.close();
            }

            ImportProjectsDialog importDialog = new ImportProjectsDialog(shell, gpsFile);
            if (importDialog.open() != IDialogConstants.OK_ID) {
                return null;
            }

            ProgressMonitorDialog progressDialog = new ProgressMonitorDialog(shell);
            progressDialog.run(true, true,
                    new ImportOperation(gpsFile, importDialog.getSettings(), progressDialog));
        } catch (InterruptedException e) {
            //ignore
        } catch (Exception e) {
            GerritToolsPlugin.getDefault().getLog()
                    .log(new Status(IStatus.ERROR, GerritToolsPlugin.PLUGIN_ID, e.getLocalizedMessage(), e));
            MessageDialog.openError(shell, "Import", e.getLocalizedMessage());
        }
    }
    return null;
}

From source file:com.genuitec.eclipse.gerrit.tools.internal.utils.commands.TagAndPushHandler.java

License:Open Source License

@Override
protected Object internalExecute(ExecutionEvent event) throws Exception {
    IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event);
    final Shell shell = HandlerUtil.getActiveShell(event);

    List<Repository> repositories = new ArrayList<Repository>();

    //acquire the list of repositories
    for (Object o : selection.toArray()) {
        RepositoryNode node = (RepositoryNode) o;
        repositories.add(node.getRepository());
        assert node.getRepository() != null;
    }/* www .  ja  v a  2  s.co  m*/

    //configure tagging operation
    TagAndPushDialog tagAndPushConfigDialog = new TagAndPushDialog(shell, repositories);
    if (tagAndPushConfigDialog.open() != IDialogConstants.OK_ID) {
        return null;
    }
    //perform tagging operation
    try {
        ProgressMonitorDialog progressDialog = new ProgressMonitorDialog(shell);
        final TagAndPushOperation op = new TagAndPushOperation(progressDialog.getShell(), repositories,
                tagAndPushConfigDialog.getSettings());
        progressDialog.run(true, true, op);
        shell.getDisplay().asyncExec(new Runnable() {

            public void run() {
                if (op.getResult().getSeverity() >= IStatus.WARNING) {
                    Policy.getStatusHandler().show(op.getResult(), "Results of the operation");
                } else {
                    MessageDialog.openInformation(shell, "Create and Push Tag",
                            "Repositories has been successfully tagged.");
                }
            }
        });
    } catch (InterruptedException e) {
        //ignore
    } catch (Exception e) {
        GerritToolsPlugin.getDefault().getLog()
                .log(new Status(IStatus.ERROR, GerritToolsPlugin.PLUGIN_ID, e.getLocalizedMessage(), e));
        MessageDialog.openError(shell, "Create and Push Tag", e.getLocalizedMessage());
    }

    return null;
}

From source file:com.genuitec.eclipse.gerrit.tools.utils.RepositoryUtils.java

License:Open Source License

public static void fetchOrigin(Shell shell, final Repository repository) {
    //perform branch operation
    try {//from   w ww .  j  av  a 2  s . com
        ProgressMonitorDialog progressDialog = new ProgressMonitorDialog(shell);
        progressDialog.run(true, true, new IRunnableWithProgress() {

            @Override
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                try {
                    monitor.beginTask("Fetching updates from origin", 100);
                    FetchOperationUI fetchOp = new FetchOperationUI(repository,
                            new RemoteConfig(repository.getConfig(), "origin"), 3000, false); //$NON-NLS-1$
                    fetchOp.setCredentialsProvider(new EGitCredentialsProvider());
                    fetchOp.execute(new SubProgressMonitor(monitor, 100));
                } catch (Exception e) {
                    throw new InvocationTargetException(e);
                }
            }
        });
    } catch (InterruptedException e) {
        //ignore
    } catch (Exception e) {
        RepositoryUtils.handleException(e);
    }
}

From source file:com.gigaspaces.azure.runnable.CacheAccountWithProgressWindow.java

License:Open Source License

@Override
public void run() {
    ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
    try {/* w w w . j  a  v a2s  . c  om*/
        dialog.run(true, true, this);
        dialog.close();
        isCompletedSuccesfully = true;
    } catch (InvocationTargetException e) {
        MessageUtil.displayErrorDialog(shell, Messages.loadingCred, message);
        isCompletedSuccesfully = false;
    } catch (InterruptedException e) {

    }
}

From source file:com.gigaspaces.azure.runnable.FetchDeploymentsForHostedServiceWithProgressWindow.java

License:Open Source License

@Override
public void run() {
    ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
    try {//from ww w .  j a va  2 s . co m
        dialog.run(true, true, this);
        dialog.close();
    } catch (InvocationTargetException e) {
        MessageUtil.displayErrorDialog(shell, com.gigaspaces.azure.wizards.Messages.fetchingDeploymentsTitle,
                e.getMessage());
        Activator.getDefault().log(Messages.error, e);
    } catch (InterruptedException e) {
    }
}

From source file:com.gigaspaces.azure.runnable.LoadAccountWithProgressWindow.java

License:Open Source License

@Override
public void run() {
    ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
    try {//from   w  w w.  j a  v  a  2s  .  co  m
        dialog.run(true, true, this);
        dialog.close();
        PreferenceUtil.setLoaded(true);
    } catch (InvocationTargetException e) {
        // special check for Java 1.6 and bouncycastle not in classpath error
        if (Messages.importDlgMsgJavaVersion.equals(e.getMessage())) {
            MessageUtil.displayErrorDialog(shell, Messages.loadingCred, Messages.importDlgMsgJavaVersion);
        } else {
            MessageUtil.displayErrorDialog(shell, Messages.loadingCred, Messages.loadingAccountError);
        }
        Activator.getDefault().log(Messages.error, e);
        PreferenceUtil.setLoaded(false);
    } catch (InterruptedException e) {
        // cancel pressed, so user might not be interested in loading data again
        PreferenceUtil.setLoaded(true);
    }
}