Search in sources :

Example 1 with ExportExternalDialog

use of net.heartsome.cat.ts.ui.docx.dialog.ExportExternalDialog in project translationstudio8 by heartsome.

the class ExportExternalHandler method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    Shell shell = HandlerUtil.getActiveShell(event);
    if (!initExportConfig(event)) {
        return null;
    }
    config.setShell(shell);
    ExportExternalDialog dialog = new ExportExternalDialog(config);
    if (Dialog.OK == dialog.open()) {
        if (config.getExportType() == ExportExternal.EXPORT_HSPROOF) {
            try {
                config.doExport();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        } else {
            ProgressMonitorDialog progressDialog = new ProgressMonitorDialog(shell);
            try {
                progressDialog.run(true, true, new IRunnableWithProgress() {

                    @Override
                    public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                        config.setMonitor(monitor);
                        try {
                            config.doExport();
                        } catch (IOException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }
                    }
                });
            } catch (InvocationTargetException e) {
                e.printStackTrace();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
    return null;
}
Also used : Shell(org.eclipse.swt.widgets.Shell) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ExportExternalDialog(net.heartsome.cat.ts.ui.docx.dialog.ExportExternalDialog) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) IOException(java.io.IOException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Aggregations

IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ExportExternalDialog (net.heartsome.cat.ts.ui.docx.dialog.ExportExternalDialog)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)1 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)1 Shell (org.eclipse.swt.widgets.Shell)1