Search in sources :

Example 1 with IImportWriter

use of org.talend.dataprofiler.core.ui.imex.model.IImportWriter in project tdq-studio-se by Talend.

the class ImportWizard method performFinish.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.wizard.Wizard#performFinish()
     */
@Override
public boolean performFinish() {
    // TDQ-10715: only close the DQ editors before import items except the sql editor and text editor.
    // TDQ-13856: when click cancel, do NOT close any editors.
    IWorkbenchPage activePage = CorePlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
    IEditorPart[] editors = activePage.getEditors();
    for (IEditorPart editor : editors) {
        if (editor instanceof CommonFormEditor) {
            boolean isSaved = activePage.closeEditor(editor, true);
            if (!isSaved) {
                // $NON-NLS-1$
                MessageUI.openWarning(DefaultMessagesImpl.getString("ImportItemAction.closeEditors"));
                return true;
            }
        }
    }
    // ADD xqliu TDQ-4284 2011-12-26
    if (ProxyRepositoryFactory.getInstance().isUserReadOnlyOnCurrentProject()) {
        return true;
    }
    // ~ TDQ-4284
    final ItemRecord[] records = importPage.getElements();
    final IImportWriter writer = importPage.getWriter();
    IRunnableWithProgress op = new IRunnableWithProgress() {

        public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
            // $NON-NLS-1$
            monitor.beginTask("Import Item", records.length);
            writer.write(records, monitor);
            monitor.done();
        }
    };
    try {
        ProgressUI.popProgressDialog(op);
    } catch (Exception e) {
        log.error(e, e);
    }
    CorePlugin.getDefault().refreshWorkSpace();
    CorePlugin.getDefault().refreshDQView();
    return true;
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ItemRecord(org.talend.dataprofiler.core.ui.imex.model.ItemRecord) IImportWriter(org.talend.dataprofiler.core.ui.imex.model.IImportWriter) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IEditorPart(org.eclipse.ui.IEditorPart) InvocationTargetException(java.lang.reflect.InvocationTargetException) CommonFormEditor(org.talend.dataprofiler.core.ui.editor.CommonFormEditor) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Example 2 with IImportWriter

use of org.talend.dataprofiler.core.ui.imex.model.IImportWriter in project tdq-studio-se by Talend.

the class ImportWizard method performCancel.

@Override
public boolean performCancel() {
    final ItemRecord[] records = importPage.getElements();
    if (records.length > 0) {
        final IImportWriter writer = importPage.getWriter();
        try {
            writer.finish(records, null);
            writer.postFinish();
        } catch (Exception e) {
            ExceptionHandler.process(e);
        }
    }
    return super.performCancel();
}
Also used : ItemRecord(org.talend.dataprofiler.core.ui.imex.model.ItemRecord) IImportWriter(org.talend.dataprofiler.core.ui.imex.model.IImportWriter) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

InvocationTargetException (java.lang.reflect.InvocationTargetException)2 IImportWriter (org.talend.dataprofiler.core.ui.imex.model.IImportWriter)2 ItemRecord (org.talend.dataprofiler.core.ui.imex.model.ItemRecord)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)1 IEditorPart (org.eclipse.ui.IEditorPart)1 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)1 CommonFormEditor (org.talend.dataprofiler.core.ui.editor.CommonFormEditor)1