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

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

Introduction

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

Prototype

public IProgressMonitor getProgressMonitor() 

Source Link

Document

Returns the progress monitor to use for operations run in this progress dialog.

Usage

From source file:org.pentaho.di.ui.trans.dialog.TransPreviewProgressDialog.java

License:Apache License

/**
 * Opens the progress dialog/*w w  w . ja v  a  2 s .co  m*/
 * @param showErrorDialogs dictates whether error dialogs should be shown when errors occur - can be set to false
 *                         to let the caller control error dialogs instead.
 * @return a {@link TransMeta}
 */
public TransMeta open(final boolean showErrorDialogs) {
    IRunnableWithProgress op = new IRunnableWithProgress() {
        public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
            doPreview(monitor, showErrorDialogs);
        }
    };

    try {
        final ProgressMonitorDialog pmd = new ProgressMonitorDialog(shell);

        // Run something in the background to cancel active database queries, forecably if needed!
        Runnable run = new Runnable() {
            public void run() {
                IProgressMonitor monitor = pmd.getProgressMonitor();
                while (pmd.getShell() == null || (!pmd.getShell().isDisposed() && !monitor.isCanceled())) {
                    try {
                        Thread.sleep(100);
                    } catch (InterruptedException e) {
                        // Ignore
                    }
                }

                if (monitor.isCanceled()) { // Disconnect and see what happens!

                    try {
                        trans.stopAll();
                    } catch (Exception e) { /* Ignore */
                    }
                }
            }
        };

        // Start the cancel tracker in the background!
        new Thread(run).start();

        pmd.run(true, true, op);
    } catch (InvocationTargetException e) {
        if (showErrorDialogs) {
            new ErrorDialog(shell,
                    BaseMessages.getString(PKG,
                            "TransPreviewProgressDialog.ErrorLoadingTransformation.DialogTitle"),
                    BaseMessages.getString(PKG,
                            "TransPreviewProgressDialog.ErrorLoadingTransformation.DialogMessage"),
                    e);
        }
        transMeta = null;
    } catch (InterruptedException e) {
        if (showErrorDialogs) {
            new ErrorDialog(shell,
                    BaseMessages.getString(PKG,
                            "TransPreviewProgressDialog.ErrorLoadingTransformation.DialogTitle"),
                    BaseMessages.getString(PKG,
                            "TransPreviewProgressDialog.ErrorLoadingTransformation.DialogMessage"),
                    e);
        }
        transMeta = null;
    }

    return transMeta;
}

From source file:org.schwiebert.cloudio.application.actions.LoadFileAction.java

License:Open Source License

@Override
public void run(IAction action) {
    FileDialog dialog = new FileDialog(getShell(), SWT.OPEN);

    dialog.setText("Select text file...");
    String sourceFile = dialog.open();
    if (sourceFile == null)
        return;//from   www.  j  a  v  a  2 s.c  o  m
    ProgressMonitorDialog pd = new ProgressMonitorDialog(getShell());
    try {
        List<Type> types = TypeCollector.getData(new File(sourceFile), "UTF-8");
        pd.setBlockOnOpen(false);
        pd.open();
        pd.getProgressMonitor().beginTask("Generating cloud...", 200);
        TagCloudViewer viewer = getViewer();
        viewer.setInput(types, pd.getProgressMonitor());
        long start = System.currentTimeMillis();
        viewer.getCloud().layoutCloud(pd.getProgressMonitor(), false);
        long end = System.currentTimeMillis();
        System.out.println("Layouted: " + (end - start));
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        pd.close();
    }
}

From source file:org.sf.feeling.decompiler.actions.ExportSourceAction.java

License:Open Source License

private void exportPackagesSource(final String decompilerType, final boolean reuseBuf, final boolean always,
        final String projectFile, final IJavaElement[] children) {
    try {//from   www  .  j  a  v a2 s . c o  m
        final List exceptions = new ArrayList();
        ProgressMonitorDialog dialog = new ProgressMonitorDialog(Display.getDefault().getActiveShell());
        dialog.run(true, true, new IRunnableWithProgress() {

            public void run(final IProgressMonitor monitor)
                    throws InvocationTargetException, InterruptedException {
                exportPackageSources(monitor, decompilerType, reuseBuf, always, projectFile, children,
                        exceptions);

                final File workingDir = new File(JavaDecompilerPlugin.getDefault().getPreferenceStore()
                        .getString(JavaDecompilerPlugin.TEMP_DIR));// $NON-NLS-1$

                if (workingDir != null && workingDir.exists()) {
                    try {
                        FileUtil.deleteDirectory(null, workingDir, 0);
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            }
        });

        if (dialog.getProgressMonitor().isCanceled()) {
            MessageDialog.openInformation(Display.getDefault().getActiveShell(),
                    Messages.getString("ExportSourceAction.InfoDialog.Title"), //$NON-NLS-1$
                    Messages.getString("ExportSourceAction.InfoDialog.Message.Canceled")); //$NON-NLS-1$
        } else if (!exceptions.isEmpty()) {
            final MultiStatus status = new MultiStatus(JavaDecompilerPlugin.PLUGIN_ID, IStatus.WARNING,
                    (exceptions.size() <= 1
                            ? Messages.getFormattedString("ExportSourceAction.WarningDialog.Message.Failed", //$NON-NLS-1$
                                    new String[] { "" + exceptions.size() //$NON-NLS-1$
                                    })
                            : Messages.getFormattedString(
                                    "ExportSourceAction.WarningDialog.Message.Failed.Multi", //$NON-NLS-1$
                                    new String[] { "" + exceptions.size() //$NON-NLS-1$
                                    })), null) {

                public void add(IStatus status) {
                    super.add(status);
                    setSeverity(IStatus.WARNING);
                }
            };
            for (int i = 0; i < exceptions.size(); i++) {
                Status exception = (Status) exceptions.get(i);
                status.add(exception);
            }

            JavaDecompilerPlugin.getDefault().getLog().log(status);
            ErrorDialog.openError(Display.getDefault().getActiveShell(),
                    Messages.getString("ExportSourceAction.WarningDialog.Title"), //$NON-NLS-1$
                    Messages.getString("ExportSourceAction.WarningDialog.Message.Success"), //$NON-NLS-1$
                    status);

        } else {
            MessageDialog.openInformation(Display.getDefault().getActiveShell(),
                    Messages.getString("ExportSourceAction.InfoDialog.Title"), //$NON-NLS-1$
                    Messages.getString("ExportSourceAction.InfoDialog.Message.Success")); //$NON-NLS-1$
        }
    } catch (Exception e) {
        IStatus status = new Status(IStatus.ERROR, JavaDecompilerPlugin.PLUGIN_ID,
                Messages.getString("ExportSourceAction.Status.Error.DecompileAndExport"), //$NON-NLS-1$
                e);
        ExceptionHandler.handle(status, Messages.getString("ExportSourceAction.ErrorDialog.Title"), //$NON-NLS-1$
                status.getMessage());
    }
}

From source file:org.springsource.ide.eclipse.commons.frameworks.ui.internal.tasks.SynchUITask.java

License:Open Source License

public void execute() {
    if (userRunnable == null) {
        return;/*from  ww w  . ja v  a2 s .c  o  m*/
    }
    Shell shell = getShell();
    if (shell != null) {
        ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
        IProgressMonitor monitor = dialog.getProgressMonitor();
        if (monitor != null) {
            monitor.setTaskName(taskName);
        }
        try {
            dialog.run(true, true, new IRunnableWithProgress() {

                public void run(IProgressMonitor monitor)
                        throws InvocationTargetException, InterruptedException {
                    userRunnable.run(monitor);

                }
            });
        } catch (InvocationTargetException e) {
            FrameworkUIActivator
                    .log(new Status(IStatus.ERROR, FrameworkUIActivator.PLUGIN_ID, "Unexpected error", e));
        } catch (InterruptedException e) {
            FrameworkUIActivator
                    .log(new Status(IStatus.ERROR, FrameworkUIActivator.PLUGIN_ID, "Operation cancelled", e));
        }
    }

}

From source file:org.xtuml.bp.integrity.generator.Generator.java

License:Open Source License

private static void checkReferentialIntegrity() {

    IPath path;// w w  w .j a va  2 s  . co m
    destPath = "";
    List<String> modelsDir = new ArrayList<String>();
    final IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
    // Build an array of string paths to model folders.
    for (IProject project : projects) {
        String projPath = project.getLocation().toOSString();
        IPath modelspath = new Path(projPath + File.separator + "models");
        if (modelspath.toFile().exists()) {
            modelsDir.add("-i");
            modelsDir.add(modelspath.toOSString());
            if ("" == destPath) {
                // only set these up on the first project found
                path = new Path(projPath + File.separator + DOC_DIR + File.separator);
                if (!path.toFile().exists()) {
                    path.toFile().mkdirs();
                }
                destPath = path.toOSString();
                firstProject = project;
            }
        }
    }
    if ("" != destPath) {
        ProgressMonitorDialog pmd = new ProgressMonitorDialog(
                PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
        pmd.setCancelable(true);
        pmd.create();
        IProgressMonitor monitor = pmd.getProgressMonitor();

        try {
            // Proceed with actually running integrity on the model
            IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
            String id = IConsoleConstants.ID_CONSOLE_VIEW;
            IConsoleView view = (IConsoleView) page.showView(id);
            view.display(myConsole);

            pmd.run(true, true, new IRunnableWithProgress() {

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

                    int steps = 3;
                    int curStep = 1;

                    monitor.beginTask("Check Referential Integrity", steps);

                    while (curStep <= steps) {
                        if (monitor.isCanceled()) {
                            InterruptedException ie = new InterruptedException("User cancelled the operation");
                            throw ie;
                        }

                        try {
                            switch (curStep) {
                            case 1:
                                monitor.subTask("Accumulating model data for workspace");
                                monitor.worked(1);
                                break;
                            case 2:
                                monitor.subTask("Processing model data for all projects");
                                runIntegrity(firstProject, destPath, modelsDir);
                                monitor.worked(1);
                                break;
                            case 3:
                                monitor.subTask("Refreshing");
                                firstProject.refreshLocal(IResource.DEPTH_INFINITE, null);
                                monitor.worked(1);
                                break;
                            }
                        } catch (Throwable e) {
                            RuntimeException err = new RuntimeException(e.getMessage());
                            throw err;
                        }
                        curStep++;
                    }
                }
            });

            // This opens the text file in an editor.
            openOutput(firstProject);
        } catch (Throwable e) {
            String errMsg = e.getMessage();
            if ((errMsg == null) || errMsg.isEmpty()) {
                Throwable cause = e.getCause();
                if (cause != null) {
                    errMsg = cause.getMessage();
                }
                if ((cause == null) || (errMsg == null)) {
                    errMsg = "";
                }
            }
            logMsg(app + args + "\nError.  Check Referential Integrity failed: " + errMsg);
        } finally {
            logMsg(app + args + "\nCheck Referential Integrity finished successfully.");
            monitor.done();
        }
    }
}

From source file:org.yafra.rcp.commands.ConnectHandler.java

License:Apache License

@SuppressWarnings("static-access")
@Override//w ww  . ja v  a  2  s  .  c o  m
public Object execute(ExecutionEvent event) throws ExecutionException {
    glob = GlobalSettings.getSingletonObject();
    glob.setDebugmessage(" - start command connect and login");
    preferredWindow = HandlerUtil.getActiveWorkbenchWindow(event);
    if (glob.isYafraSessionConnected()) {
        MessageDialog.openInformation(preferredWindow.getShell(), "Info",
                "You are already logged in - logoff first");
        return null;
    }
    login = new LoginDialog(preferredWindow.getShell());
    login.open();
    if (login.getReturnCode() == (int) login.OK) {
        ProgressMonitorDialog progressDialog = new ProgressMonitorDialog(preferredWindow.getShell());
        IRunnableWithProgress runnable = new IRunnableWithProgress() {
            public void run(IProgressMonitor progressMonitor) throws InterruptedException {
                progressMonitor.beginTask(Lloginstartmon, IProgressMonitor.UNKNOWN);
                try {
                    // for the provider URL see as examples http://openejb.apache.org/clients.html
                    // openejb in tomee http://127.0.0.1:8080/tomee/ejb
                    // openejb standalone ejbd ejbd://localhost:4201
                    String ServerURL = new String(String.format("http://%s:8080/tomee/ejb", login.getServer()));
                    Properties prop = new Properties();
                    prop.put(glob.getEjbcontext().INITIAL_CONTEXT_FACTORY,
                            "org.apache.openejb.client.RemoteInitialContextFactory");
                    prop.put("java.naming.provider.url", ServerURL);
                    glob.setEjbcontext(new InitialContext(prop));
                    progressMonitor.worked(1);
                    glob.setDebugmessage(" - got context");
                    glob.setYafrases((YafraSessionRemote) glob.getEjbcontext().lookup("YafraSessionRemote"));
                    glob.setDebugmessage(" - got remote session class");
                    glob.getYafrases().init();
                    progressMonitor.worked(2);
                    glob.setDebugmessage(" - got remote init");
                    if (glob.getYafrases().Login(login.getUserid(), login.getPwd())) {
                        glob.setYafraSessionConnected(true);
                        glob.getStatusline().setMessage(null, "Ready - logged in");
                        glob.setDebugmessage(" - login OK");
                        GlobalSettings glob = GlobalSettings.getSingletonObject();
                        glob.setServer(login.getServer());
                        glob.setUser(login.getUserid());
                        MHIYafraUserRemote mhiuser = (MHIYafraUserRemote) glob.getEjbcontext()
                                .lookup("MHIYafraUserRemote");
                        glob.setUserModel(mhiuser.selectUser(login.getUserid()));
                        glob.setUserRoles(mhiuser.getRoles(login.getUserid()));
                    } else {
                        glob.setDebugmessage(" - login NOT OK - EXIT NOW");
                        glob.getStatusline().setMessage(null,
                                "Ready - not logged in - ERROR with login - try again");
                        glob.setYafraSessionConnected(false);
                        return;
                    }
                    glob.setDebugmessage(" - version got from server: " + glob.getYafrases().getVersion());

                    // TODO check why not returning
                    progressMonitor.done();
                } catch (Exception e) {
                    glob.setYafraSessionConnected(false);
                    progressMonitor.done();
                    Status status = new Status(IStatus.ERROR, "My Plug-in ID", 0, "EJB3 connection error", e);
                    ErrorDialog.openError(Display.getCurrent().getActiveShell(), "EJB3 connection error",
                            e.toString(), status);
                    e.printStackTrace();
                }
            };
        };
        try {
            progressDialog.open();
            runnable.run(progressDialog.getProgressMonitor());
        } catch (InvocationTargetException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        progressDialog.close();
        try {
            IViewReference ref = preferredWindow.getActivePage().findViewReference("org.yafra.rcp.LoginView");
            preferredWindow.getActivePage().hideView(ref);
            preferredWindow.getActivePage().showView("org.yafra.rcp.LoginView");
        } catch (PartInitException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    }

    return null;
}

From source file:tubame.portability.plugin.wizard.JbmConvertWizard.java

License:Apache License

/**
 * {@inheritDoc}/*from  w w w.  j  ava2 s. co m*/
 */
@Override
public boolean performFinish() {
    LOGGER.info(String.format(MessageUtil.LOG_INFO_ACTION_P, ResourceUtil.DIALOG_CONVERT,
            MessageUtil.LOG_INFO_BTN_NAME_FINISH,
            "TargetText=[" + jbmConvertSelectionPage.getTargetText() + "] OutSourceFolderText=["
                    + jbmConvertSelectionPage.getOutSourceFolderText() + "] WebLogicVersionCombo=["
                    + jbmConvertSelectionPage.getWebLogicVersionCombo() + "]"));
    boolean validate = jbmConvertSelectionPage.textValidate();
    // False if you get caught in the validate
    if (!validate) {
        return false;
    }
    boolean searchOk = false;
    ConvertView view = null;
    ConvertWithProgress convertProgress = null;
    String jbmFilePath = null;
    try {
        LOGGER.info(String.format(MessageUtil.LOG_INFO_PROC_START, MessageUtil.LOG_INFO_PROC_NAME_CONVERT));

        // Get the view
        view = PluginUtil.getConvertView();
        jbmFilePath = PluginUtil.getResolvedPluginDir() + ApplicationPropertyUtil.CONVERT_JBM_OUT_FILE_PATH;
        String target = PluginUtil.getFileFullPath(jbmConvertSelectionPage.getTargetText());

        File deleteFile = new File(jbmFilePath);
        if (deleteFile != null && deleteFile.isFile()) {
            if (!deleteFile.delete()) {
                LOGGER.warn(String.format(MessageUtil.LOG_WARN_FILE_DELETE_FAIL, jbmFilePath));
            }
        }

        // Search process
        ConvertSearchToolWithProgress progress = new ConvertSearchToolWithProgress(target,
                this.projectPath + ApplicationPropertyUtil.SEARCH_CONVERT_KEYWORD_FILE, jbmFilePath);
        ProgressMonitorDialog dialog = new ProgressMonitorDialog(PluginUtil.getActiveWorkbenchShell());

        dialog.run(true, true, progress);
        if (!progress.isFileOut()) {
            LOGGER.info(String.format(MessageUtil.LOG_INFO_PROC_END_P, MessageUtil.LOG_INFO_PROC_NAME_CONVERT,
                    MessageUtil.INF_SEARCH_NON));
            PluginUtil.viewInfoDialog(getDialogTitle(), MessageUtil.INF_SEARCH_NON);
            return false;
        }

        // The cancellation or if there is no conversion files, the process
        // is terminated
        if (!isJbmFileNormal(jbmFilePath)) {
            LOGGER.debug(MessageUtil.INF_CANCEL);
            return false;
        }
        searchOk = true;

        // Conversion process
        convertProgress = new ConvertWithProgress(PluginUtil.getPluginDir(), PluginUtil.getWorkspaceRoot(),
                jbmConvertSelectionPage.getOutSourceFolderText(),
                jbmConvertSelectionPage.getWebLogicVersionCombo(), jbmFilePath);
        dialog.run(true, true, convertProgress);
        // Refresh
        PluginUtil.refreshWorkSpace(dialog.getProgressMonitor());

        // Conversion Complete
        LOGGER.info(String.format(MessageUtil.LOG_INFO_PROC_END, MessageUtil.LOG_INFO_PROC_NAME_CONVERT));
        State state = ConvertState.getInstance();
        if (state.isFailed()) {
            PluginUtil.viewErrorDialog(getDialogTitle(), createRunMessage(convertProgress, getErrorRunFalse()),
                    null);
            // View error log view
            PluginUtil.showErrorLogView();
        } else {

            PluginUtil.viewInfoDialog(getDialogTitle(), createRunMessage(convertProgress, getRunComplete()));
        }
        if (convertProgress.getConvertFileScanner().scanFileData()) {
            PluginUtil.viewInfoDialog(getDialogTitle(), MessageUtil.CONVERTEDFILE_HAS_TODO);

        }

    } catch (IOException e) {
        LOGGER.error(
                String.format(MessageUtil.LOG_ERR_PROC_ABNORMAL_END, MessageUtil.LOG_INFO_PROC_NAME_CONVERT),
                e);
        PluginUtil.viewErrorDialog(getDialogTitle(), getErrorRunFalse(), e);
        if (searchOk) {
            PluginUtil.viewErrorDialog(getDialogTitle(), getErrorRunFalse(), e);
        } else {
            PluginUtil.viewErrorDialog(getDialogTitle(),
                    getErrorRunFalse() + StringUtil.LINE_SEPARATOR + e.getMessage(), e);
        }
        return false;
    } catch (InterruptedException e) {
        // Cancellation
        // Refresh
        PluginUtil.refreshWorkSpace(null);
        PluginUtil.viewInfoDialog(getDialogTitle(), getErrorRunCancel());
        LOGGER.info(String.format(MessageUtil.LOG_INFO_PROC_CANCEL, MessageUtil.LOG_INFO_PROC_NAME_CONVERT));
        LOGGER.debug(MessageUtil.INF_CANCEL);
        return false;
    } catch (InvocationTargetException e) {
        // Failure
        LOGGER.error(
                String.format(MessageUtil.LOG_ERR_PROC_ABNORMAL_END, MessageUtil.LOG_INFO_PROC_NAME_CONVERT),
                e);
        if (searchOk) {
            PluginUtil.viewErrorDialog(getDialogTitle(), createRunMessage(convertProgress, getErrorRunFalse()),
                    e);
        } else {
            PluginUtil.viewErrorDialog(getDialogTitle(),
                    getErrorRunFalse() + StringUtil.LINE_SEPARATOR + e.getMessage(), e);
        }
        return false;
    } catch (JbmException e) {
        LOGGER.error(
                String.format(MessageUtil.LOG_ERR_PROC_ABNORMAL_END, MessageUtil.LOG_INFO_PROC_NAME_CONVERT),
                e);
        if (searchOk) {
            PluginUtil.viewErrorDialog(getDialogTitle(), createRunMessage(convertProgress, getErrorRunFalse()),
                    e);
        } else {
            PluginUtil.viewErrorDialog(getDialogTitle(),
                    getErrorRunFalse() + StringUtil.LINE_SEPARATOR + e.getMessage(), e);
        }
        return false;
    } finally {
        if (view != null && convertProgress != null) {
            view.update(convertProgress.getTargetList(), convertProgress.getConvertStatusFilePath());

        }
    }

    return true;
}

From source file:tubame.portability.plugin.wizard.JbmSearchWizard.java

License:Apache License

/**
 * {@inheritDoc}//w ww  .  ja  v  a  2  s  . c o m
 */
@Override
public boolean performFinish() {
    LOGGER.info(String.format(MessageUtil.LOG_INFO_ACTION_P, ResourceUtil.DIALOG_SEARCH,
            MessageUtil.LOG_INFO_BTN_NAME_FINISH,
            "TargetText=[" + jbmSearchSelectionPage.getTargetText() + "] KnowhowXmlFilePath=["
                    + jbmSearchSelectionPage.getKnowhowXmlFilePath() + "] OutJbmFileText=["
                    + jbmSearchSelectionPage.getOutJbmFileText() + "]"));
    boolean validate = jbmSearchSelectionPage.checkFileUpdate();
    // False when it was stuck to validate
    if (!validate) {
        LOGGER.info(String.format(MessageUtil.LOG_INFO_ACTION, jbmSearchSelectionPage.getDialogTitle(),
                MessageUtil.LOG_INFO_BTN_NAME_NO));
        return false;
    }
    try {
        LOGGER.info(String.format(MessageUtil.LOG_INFO_PROC_START, MessageUtil.LOG_INFO_PROC_NAME_SEARCH));

        String outFilePath = PluginUtil.getFileFullPath(jbmSearchSelectionPage.getOutJbmFileText());
        // Close the file with the same name that is already open
        PluginUtil.closeEditor(jbmSearchSelectionPage.getOutJbmFileText());

        // Convert an existing format file knowhowXML
        // knowhow.xml > keywordSearch.csv
        // knowhow.xml > checkListInformation.xml
        KnowhowXmlConvertFactory.getKnowhowXmlConvertFacade().convertSearchFiles(
                PluginUtil.getFileFullPath(jbmSearchSelectionPage.getKnowhowXmlFilePath()), projectPath);

        // Search process
        SearchToolWithProgress progress = new SearchToolWithProgress(
                PluginUtil.getFileFullPath(jbmSearchSelectionPage.getTargetText()),
                this.projectPath + ApplicationPropertyUtil.SEARCH_KEYWORD_FILE, outFilePath, projectPath);
        ProgressMonitorDialog dialog = new ProgressMonitorDialog(PluginUtil.getActiveWorkbenchShell());
        LOGGER.info("Dialog run start.");
        dialog.run(true, true, progress);
        LOGGER.info("Dialog run end.");
        if (progress.isFileOut()) {
            // Refresh
            LOGGER.info("Output File Path: " + outFilePath);
            LOGGER.info("Output File Path: " + jbmSearchSelectionPage.getOutJbmFileText());
            //                getIFile(outFilePath);
            LOGGER.info("Refresh Workspace");
            PluginUtil.refreshWorkSpace(dialog.getProgressMonitor());
            // Open Perspective
            LOGGER.info("Open Search Perspective");
            PluginUtil.openSeachPerspective();
            // Open the editor
            LOGGER.info("Open Editor");
            PluginUtil.openEditor(jbmSearchSelectionPage.getOutJbmFileText(), PluginUtil.getSearchEditorId());
            LOGGER.info(String.format(MessageUtil.LOG_INFO_PROC_END, MessageUtil.LOG_INFO_PROC_NAME_SEARCH));
            PluginUtil.viewInfoDialog(getDialogTitle(), getRunComplete());
        } else {
            LOGGER.info(String.format(MessageUtil.LOG_INFO_PROC_END_P, MessageUtil.LOG_INFO_PROC_NAME_SEARCH,
                    MessageUtil.INF_SEARCH_NON));
            PluginUtil.viewInfoDialog(getDialogTitle(), MessageUtil.INF_SEARCH_NON);
            return false;
        }
        //        } catch (IOException e) {
        //            LOGGER.error(String.format(MessageUtil.LOG_ERR_PROC_ABNORMAL_END,
        //                    MessageUtil.LOG_INFO_PROC_NAME_SEARCH), e);
        //            PluginUtil.viewErrorDialog(getDialogTitle(), getErrorRunFalse(), e);
        //            return false;
    } catch (InterruptedException e) {
        // Cancellation
        LOGGER.debug(MessageUtil.INF_CANCEL);
        LOGGER.info(String.format(MessageUtil.LOG_INFO_PROC_CANCEL, MessageUtil.LOG_INFO_PROC_NAME_SEARCH));
        PluginUtil.viewInfoDialog(getDialogTitle(), getErrorRunCancel());
        return false;
    } catch (InvocationTargetException e) {
        LOGGER.error(
                String.format(MessageUtil.LOG_ERR_PROC_ABNORMAL_END, MessageUtil.LOG_INFO_PROC_NAME_SEARCH), e);
        PluginUtil.viewErrorDialog(getDialogTitle(),
                getErrorRunFalse() + StringUtil.LINE_SEPARATOR + e.getMessage(), e);
        return false;
    } catch (CoreException e) {
        LOGGER.error(String.format(MessageUtil.LOG_ERR_PROC_ABNORMAL_END_P,
                MessageUtil.LOG_INFO_PROC_NAME_SEARCH, MessageUtil.ERR_SEARCH_PERSPECTIVE_OPEN), e);
        // Failure in perspective related
        PluginUtil.viewErrorDialog(getDialogTitle(), MessageUtil.ERR_SEARCH_PERSPECTIVE_OPEN, e);
        return false;
    } catch (JbmException e) {
        LOGGER.error(
                String.format(MessageUtil.LOG_ERR_PROC_ABNORMAL_END, MessageUtil.LOG_INFO_PROC_NAME_SEARCH), e);
        // Conversion failure to existing form of know-how XML file
        PluginUtil.viewErrorDialog(getDialogTitle(),
                getErrorRunFalse() + StringUtil.LINE_SEPARATOR + e.getMessage(), e);
        return false;
    }
    return true;
}

From source file:tubame.portability.plugin.wizard.ReportGenWizard.java

License:Apache License

/**
 * {@inheritDoc}/*from w  ww.  j  a  va 2  s .c om*/
 */
@Override
public boolean performFinish() {
    LOGGER.info(String.format(MessageUtil.LOG_INFO_ACTION_P, ResourceUtil.DIALOG_REPORTGEN,
            MessageUtil.LOG_INFO_BTN_NAME_FINISH, "TargetText=[" + reportGenDirSelectionPage.getTargetText()
                    + "] OutSourceFolderText=[" + reportGenDirSelectionPage.getOutSourceFolderText() + "]"));

    boolean validate = reportGenDirSelectionPage.textValidate();
    // False if you get caught in the validate
    if (!validate) {
        return false;
    }

    String jbmFilePath = null;
    try {
        LOGGER.info(String.format(MessageUtil.LOG_INFO_PROC_START, MessageUtil.LOG_INFO_PROC_NAME_REPORTGEN));

        String target = reportGenDirSelectionPage.getSearchTargetFullPath();

        String reportDir = reportGenDirSelectionPage.getOutputFullPath() + File.separator + "tubame-report";
        if (new File(reportDir).exists()) {
            removeDir(reportDir, true);
        }
        existCheckListInformationForReportGen(target);

        // Search process
        ReportGenSearchToolWithProgress progress = new ReportGenSearchToolWithProgress(target,
                PythonUtil.getSearchKeywordFilePath(ApplicationPropertyUtil.SEARCH_REPORTGEN_KEYWORD_FILE),
                jbmFilePath, reportGenDirSelectionPage.getSelectedProject());
        ProgressMonitorDialog dialog = new ProgressMonitorDialog(PluginUtil.getActiveWorkbenchShell());

        PluginUtil.getPluginDir();
        createReportTemplateTypeFile(this.reportGenDirSelectionPage.getReportTemplateCombo().getText(),
                PythonUtil.getReportTplPath());

        dialog.run(true, true, progress);
        if (progress.isFileOut()) {
            String reportGenerationPath = PythonUtil.getReportGenerationPath();

            // copy reportGenerationPath 
            copyReport(reportGenerationPath,
                    reportGenDirSelectionPage.getOutputFullPath() + File.separator + "tubame-report");

            // // Open Perspective
            // PluginUtil.openSeachPerspective();
            // // Open the editor
            // PluginUtil.openEditor(
            // jbmSearchSelectionPage.getOutJbmFileText(),
            // PluginUtil.getSearchEditorId());

            setShowHtmlURL(reportGenDirSelectionPage.getOutputFullPath());

            LOGGER.info(String.format(MessageUtil.LOG_INFO_PROC_END, MessageUtil.LOG_INFO_PROC_NAME_REPORTGEN));

            copyGuideToReport(reportDir);

            // Refresh
            PluginUtil.refreshWorkSpace(dialog.getProgressMonitor());

            PluginUtil.viewInfoDialog(getDialogTitle(), getRunComplete());

            if (showHtmlUrl != null) {
                String projectOutputPath = this.reportGenDirSelectionPage.getOutSourceFolderText()
                        + File.separator + "tubame-report";

                if (PluginUtil.viewQuestionDialog(getDialogTitle(),
                        projectOutputPath + MessageUtil.CONFIRM_RERPORT_SHOW_BROWSER)) {
                    PlatformUI.getWorkbench().getBrowserSupport().getExternalBrowser()
                            .openURL(showHtmlUrl.toURI().toURL());
                }
            }

        } else {
            LOGGER.info(String.format(MessageUtil.LOG_INFO_PROC_END_P, MessageUtil.LOG_INFO_PROC_NAME_REPORTGEN,
                    MessageUtil.INF_SEARCH_REPORTGEN_NON));
            PluginUtil.viewInfoDialog(getDialogTitle(), MessageUtil.INF_SEARCH_REPORTGEN_NON);
            return false;
        }

    } catch (InterruptedException e) {
        // Cancellation
        LOGGER.debug(MessageUtil.INF_CANCEL);
        LOGGER.info(String.format(MessageUtil.LOG_INFO_PROC_CANCEL, MessageUtil.LOG_INFO_PROC_NAME_REPORTGEN));
        PluginUtil.viewInfoDialog(getDialogTitle(), getErrorRunCancel());
        return false;
    } catch (InvocationTargetException e) {
        LOGGER.error(
                String.format(MessageUtil.LOG_ERR_PROC_ABNORMAL_END, MessageUtil.LOG_INFO_PROC_NAME_REPORTGEN),
                e);
        PluginUtil.viewErrorDialog(getDialogTitle(),
                getErrorRunFalse() + StringUtil.LINE_SEPARATOR + e.getMessage(), e);
        return false;
    } catch (Exception e) {
        LOGGER.error(
                String.format(MessageUtil.LOG_ERR_PROC_ABNORMAL_END, MessageUtil.LOG_INFO_PROC_NAME_REPORTGEN),
                e);
        PluginUtil.viewErrorDialog(getDialogTitle(),
                getErrorRunFalse() + StringUtil.LINE_SEPARATOR + e.getMessage(), e);
        return false;
    } finally {
        try {
            String reportGenerationPath = PythonUtil.getReportGenerationPath();
            if (new File(reportGenerationPath).exists()) {
                removeDir(reportGenerationPath, true);
            }
        } catch (IOException e) {
            ;
        }
    }

    return true;
    // catch (WorkbenchException e) {
    // LOGGER.error(String.format(MessageUtil.LOG_ERR_PROC_ABNORMAL_END_P,
    // MessageUtil.LOG_INFO_PROC_NAME_REPORTGEN,
    // MessageUtil.ERR_SEARCH_PERSPECTIVE_OPEN), e);
    // // Failure in perspective related
    // PluginUtil.viewErrorDialog(getDialogTitle(),
    // MessageUtil.ERR_SEARCH_PERSPECTIVE_OPEN, e);
    // return false;
    // }
    // catch (JbmException e) {
    // LOGGER.error(String.format(MessageUtil.LOG_ERR_PROC_ABNORMAL_END,
    // MessageUtil.LOG_INFO_PROC_NAME_SEARCH), e);
    // // Conversion failure to existing form of know-how XML file
    // PluginUtil.viewErrorDialog(getDialogTitle(), getErrorRunFalse()
    // + StringUtil.LINE_SEPARATOR + e.getMessage(), e);
    // return false;
    // }

}