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:es.bsc.servicess.ide.editors.deployers.GridDeployer.java

License:Apache License

@Override
public void deploy() {
    final Element master = resGRFile.getMasterResource();
    if (master != null) {
        final Element[] workers = resGRFile.getWorkerResources();
        if (workers != null && workers.length > 0) {
            ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell());
            try {
                dialog.run(false, false, new IRunnableWithProgress() {

                    @Override//from   w w w . ja  v a  2  s .  c o  m
                    public void run(final IProgressMonitor monitor)
                            throws InvocationTargetException, InterruptedException {
                        try {
                            executeDeployment(master, workers, monitor);
                        } catch (Exception e) {
                            throw (new InvocationTargetException(e));
                        }
                    }
                });
            } catch (InterruptedException e) {
                String message = e.getMessage();
                System.err.println("Error message: " + message);
                ErrorDialog.openError(super.getShell(), "Error", "Deploying the service",
                        new StatusInfo(IStatus.ERROR, message));
                e.printStackTrace();
            } catch (InvocationTargetException e) {
                String message = e.getMessage();
                System.err.println("Error message: " + message);
                ErrorDialog.openError(super.getShell(), "Error", "Deploying the service",
                        new StatusInfo(IStatus.ERROR, message));
                e.printStackTrace();
            }
        } else {
            ErrorDialog.openError(super.getShell(), "Error", "Deploying the service",
                    new StatusInfo(IStatus.ERROR, "Worker resources not defined"));
        }
    } else {
        ErrorDialog.openError(super.getShell(), "Error", "Deploying the service",
                new StatusInfo(IStatus.ERROR, "Master resource not defined"));
    }
}

From source file:es.bsc.servicess.ide.editors.deployers.LocalhostDeployer.java

License:Apache License

@Override
public void deploy() {
    ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell());
    try {//w ww .j a  v a  2  s . c o  m
        dialog.run(false, false, new IRunnableWithProgress() {

            @Override
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                try {
                    executeDeployment(monitor);
                } catch (Exception e) {
                    throw (new InvocationTargetException(e));
                }
            }
        });
    } catch (InterruptedException e) {
        ErrorDialog.openError(super.getShell(), "Error", "Deploying the service",
                new StatusInfo(IStatus.ERROR, e.getMessage()));
        e.printStackTrace();
    } catch (InvocationTargetException e) {
        ErrorDialog.openError(super.getShell(), "Error", "Deploying the service",
                new StatusInfo(IStatus.ERROR, e.getMessage()));
        e.printStackTrace();
    }
}

From source file:es.bsc.servicess.ide.editors.deployers.LicenseTokensTableComposite.java

License:Apache License

/**
 * Invoke the runnable to generate the license token
 * @param selectionIndex Index of selected license in the license token table
 *///from  ww  w .java 2  s  . c  om
protected void generateToken(final int selectionIndex) {
    ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
    try {
        dialog.run(false, false, new IRunnableWithProgress() {

            @Override
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                try {
                    String token = deployer.executeTokenGeneration(kvTable.getItem(selectionIndex).getText(0),
                            monitor);
                    if (token != null && token.length() > 0) {
                        String name = LicenseTokenUtils.getName(token);
                        if (name.equalsIgnoreCase(kvTable.getItem(selectionIndex).getText(0).trim())) {
                            kvTable.getItem(selectionIndex).setText(1, token);
                        } else {
                            throw (new Exception("Token license identifier " + name
                                    + " is not the specified in the constraints ("
                                    + kvTable.getItem(selectionIndex).getText(0).trim() + ")"));
                        }
                    } else {
                        log.debug("Generated token is invalid");
                        throw (new Exception("Generated token is invalid"));
                    }
                } catch (Exception e) {
                    log.debug("Exception:" + e.getMessage());
                    throw (new InvocationTargetException(e));

                }
            }
        });
    } catch (InterruptedException e) {
        log.error("Exception generating licenses", e);
        ErrorDialog.openError(shell, "Exception Generating license token ", e.getMessage(),
                new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getLocalizedMessage(), e));
    } catch (InvocationTargetException e) {
        log.error("Exception generating licenses", e);
        ErrorDialog.openError(shell, "Exception Generating license token ", e.getMessage(),
                new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getLocalizedMessage(), e));
    }
}

From source file:es.bsc.servicess.ide.editors.deployers.LicenseTokensTableComposite.java

License:Apache License

/**
 * Execute the runnable to generate all the license tokens
 *//*from   w ww . ja  v  a 2  s  .co  m*/
protected void generateAllTokens() {

    ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
    try {
        dialog.run(false, false, new IRunnableWithProgress() {

            @Override
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                try {
                    if (kvTable.getItemCount() > 0) {
                        for (int index = 0; index < kvTable.getItemCount(); index++) {
                            String token = deployer.executeTokenGeneration(kvTable.getItem(index).getText(0),
                                    monitor);
                            if (token != null && token.length() > 0) {
                                String name = LicenseTokenUtils.getName(token);
                                if (name.equalsIgnoreCase(kvTable.getItem(index).getText(0).trim())) {
                                    kvTable.getItem(index).setText(1, token);
                                } else {
                                    throw (new Exception("Token license identifier " + name
                                            + " is not the specified in the constraints ("
                                            + kvTable.getItem(index).getText(0).trim() + ")"));
                                }

                            } else
                                throw (new Exception("Generated token for " + kvTable.getItem(index).getText(0)
                                        + " is invalid"));
                        }
                    }
                } catch (Exception e) {
                    log.debug("Exception during generation:" + e.getMessage());
                    throw (new InvocationTargetException(e));
                }
            }
        });
    } catch (InterruptedException e) {
        ErrorDialog.openError(shell, "Exception Generating license ", e.getMessage(),
                new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getLocalizedMessage(), e));
        log.error("Exception Generating License tokens", e);
    } catch (InvocationTargetException e) {
        ErrorDialog.openError(shell, "Exception Generating license", e.getMessage(),
                new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getLocalizedMessage(), e));
        log.error("Exception Generating License tokens", e);
    }
}

From source file:es.bsc.servicess.ide.editors.deployers.LicenseTokensTableComposite.java

License:Apache License

/**
 * Invokes the runnable for creating the service images
 *//*from w w  w.jav a  2 s  .c  o  m*/
protected void createServiceImages() {
    ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell());
    try {
        dialog.run(false, false, new IRunnableWithProgress() {

            @Override
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                try {
                    executeImageCreation(monitor);
                } catch (Exception e) {
                    throw (new InvocationTargetException(e));
                }
            }
        });
    } catch (InterruptedException e) {
        log.error("Error creating images", e);
        ErrorDialog.openError(super.getShell(), "Error creating images", e.getMessage(),
                new Status(Status.ERROR, Activator.PLUGIN_ID, "Exception creating Images", e));
    } catch (InvocationTargetException e) {
        log.error("Error creating images", e);
        ErrorDialog.openError(super.getShell(), "Error creating images", e.getMessage(),
                new Status(Status.ERROR, Activator.PLUGIN_ID, "Exception creating Images", e));
    }
}

From source file:es.bsc.servicess.ide.editors.deployers.LicenseTokensTableComposite.java

License:Apache License

@Override
public void deploy() {
    ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell());
    try {/*from www.j  a  va 2  s  .c  om*/
        dialog.run(false, false, new IRunnableWithProgress() {

            @Override
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                try {
                    executeDeployment(monitor);
                } catch (Exception e) {
                    throw (new InvocationTargetException(e));
                }
            }
        });
    } catch (InterruptedException e) {
        String message = e.getMessage();
        log.error("Error message: " + message, e);
        ErrorDialog.openError(super.getShell(), "Error", "Deploying the service: " + message,
                new Status(IStatus.ERROR, Activator.PLUGIN_ID, message, e));
    } catch (InvocationTargetException e) {
        String message = e.getMessage();
        log.error("Error message: " + message, e);
        ErrorDialog.openError(super.getShell(), "Error", "Deploying the service: " + message,
                new Status(IStatus.ERROR, Activator.PLUGIN_ID, message, e));
    }
}

From source file:es.bsc.servicess.ide.editors.deployers.LicenseTokensTableComposite.java

License:Apache License

/**
 * Write the service manifest to a file//ww w . ja v  a 2 s .c  o  m
 */
protected void writeManifestToFile() {
    try {
        final ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell());
        final IFile sm = getProject().getProject().getFolder(ProjectMetadata.OUTPUT_FOLDER)
                .getFolder(ProjectMetadata.PACKAGES_FOLDER).getFile(ProjectMetadata.SERVICE_MANIFEST);
        dialog.run(true, true, new IRunnableWithProgress() {
            public void run(IProgressMonitor monitor) throws InvocationTargetException {
                try {
                    if (sm.exists()) {
                        sm.delete(true, monitor);
                    }
                    if (manifest == null) {
                        generateNewManifest();
                    }
                    log.debug("writing the manifest in the file ");
                    sm.create(new ByteArrayInputStream(manifest.toString().getBytes()), true, monitor);
                } catch (Exception e) {
                    log.debug("Exception writing manifest");
                    throw (new InvocationTargetException(e));
                }
            }
        });
    } catch (InvocationTargetException e) {
        log.error("Exception writing manifest", e);
        ErrorDialog.openError(getShell(), "Error writing manifest", e.getMessage(),
                new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Invocation Exception", e));
    } catch (InterruptedException e) {
        log.error("Exception writing manifest", e);
        ErrorDialog.openError(getShell(), "Building interrumped", e.getMessage(),
                new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Interruption Exception", e));
    }
}

From source file:es.bsc.servicess.ide.editors.ImplementationFormPage.java

License:Apache License

/**
 * Update the runtime location modifiying the dependency to the runtime libraries
 *//*from ww w .jav a2 s .co  m*/
protected void updateRuntimeLocation() {
    if (previousRuntimeLocation != null && !previousRuntimeLocation.equals(runtimetext.getText().trim())) {
        IFile f = ((ServiceFormEditor) getEditor()).getMetadataFile();
        try {
            ProjectMetadata pr_meta = new ProjectMetadata(f.getRawLocation().toFile());
            pr_meta.removeDependency(previousRuntimeLocation + ProjectMetadata.ITJAR_EXT);
            pr_meta.setRuntimeLocation(runtimetext.getText().trim());
            pr_meta.addDependency(runtimetext.getText().trim() + ProjectMetadata.ITJAR_EXT,
                    ProjectMetadata.JAR_DEP_TYPE);
            pr_meta.toFile(f.getRawLocation().toFile());
            final IJavaProject project = ((ServiceFormEditor) getEditor()).getProject();

            final ProgressMonitorDialog mon = new ProgressMonitorDialog(getEditor().getSite().getShell());
            mon.run(false, false, new IRunnableWithProgress() {
                public void run(IProgressMonitor monitor) {
                    try {
                        project.getProject().refreshLocal(Resource.DEPTH_INFINITE, monitor);
                    } catch (CoreException e) {
                        ErrorDialog.openError(mon.getShell(), "Error refreshing the classpath", e.getMessage(),
                                e.getStatus());
                        e.printStackTrace();
                    }
                }
            });

        } catch (Exception e) {
            ErrorDialog.openError(this.getEditor().getSite().getShell(),
                    "Error adding runtime to the classpath", e.getMessage(),
                    new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e));
            e.printStackTrace();
        }
    }
    previousRuntimeLocation = runtimetext.getText().trim();
}

From source file:es.bsc.servicess.ide.editors.ImplementationFormPage.java

License:Apache License

/**
 * Delete an orchestration class/*  w w w.j av  a2 s  .c o m*/
 * @param index Index of the selected Orchestration class 
 */
protected void deleteServiceClass(int index) {

    if (MessageDialog.openQuestion(this.getEditor().getSite().getShell(), "Service Class Delete",
            " Delete service class " + serviceClassList.getItem(index) + ".\nAre you sure?")) {
        IPackageFragment frag = ((ServiceFormEditor) getEditor()).getMainPackage();
        final ICompilationUnit cu_class = frag
                .getCompilationUnit(Signature.getSimpleName(serviceClassList.getItem(index)) + ".java");
        final ICompilationUnit cu_itf = frag
                .getCompilationUnit(Signature.getSimpleName(serviceClassList.getItem(index)) + "Itf.java");
        final ProgressMonitorDialog mon = new ProgressMonitorDialog(getEditor().getSite().getShell());
        try {
            deleteClassFromMetadataFile(serviceClassList.getItem(index));
            mon.run(false, false, new IRunnableWithProgress() {
                public void run(IProgressMonitor monitor) {
                    try {
                        cu_class.delete(true, monitor);
                        cu_itf.delete(true, monitor);

                    } catch (JavaModelException e) {
                        log.error("Error deleting service class", e);
                        ErrorDialog.openError(mon.getShell(), "Error deleting service class", e.getMessage(),
                                e.getStatus());
                    }
                }
            });
            initData();
        } catch (InvocationTargetException e) {
            log.error("Error deleting service class", e);
            ErrorDialog.openError(mon.getShell(), "Error deleting service class", e.getMessage(),
                    new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e));
        } catch (InterruptedException e) {
            log.error("Error deleting service class", e);
            ErrorDialog.openError(mon.getShell(), "Error deleting service class", e.getMessage(),
                    new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e));
        } catch (ConfigurationException e) {
            log.error("Error deleting service class", e);
            ErrorDialog.openError(mon.getShell(), "Error deleting service class", e.getMessage(),
                    new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e));
        } catch (PartInitException e) {
            log.error("Error deleting service class", e);
            ErrorDialog.openError(mon.getShell(), "Error deleting service class", e.getMessage(),
                    e.getStatus());
        }
    }

}

From source file:es.bsc.servicess.ide.wizards.coretypes.ServiceWarSpecificTreatment.java

License:Apache License

private void loadWarFile(final String selectedDirectory, final IFolder extractFolder) {
    final ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
    try {/*w  ww .  j ava  2 s . co m*/
        log.debug("Selected dir: " + selectedDirectory);
        final File warFile = new File(selectedDirectory);
        if (warFile.exists()) {
            dialog.run(true, true, new IRunnableWithProgress() {
                public void run(IProgressMonitor monitor) throws InvocationTargetException {
                    try {
                        extractWar(warFile, extractFolder, monitor);
                    } catch (Exception e) {
                        throw (new InvocationTargetException(e));
                    }
                }
            });

            resetServiceInfo();
            warLocation.setText(selectedDirectory);
            warPath = selectedDirectory;
            wsdlLocation.setText("");
            urlPattern.setText("");
            wsdl = null;
            serviceURLPath = null;
            wsdlSelectButton.setEnabled(true);
            urlPatternSelectButton.setEnabled(true);
        } else
            throw (new InvocationTargetException(new Exception("The selected file doesn't exists")));
    } catch (InvocationTargetException e) {
        ErrorDialog.openError(dialog.getShell(), "Error loading new war file", "Exception when loading war",
                new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e));
        e.printStackTrace();
    } catch (InterruptedException e) {
        ErrorDialog.openError(dialog.getShell(), "War load interrumped", "Exception when loading war",
                new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e));
        e.printStackTrace();
    }
}