Search in sources :

Example 1 with ArchiveFileExportOperation

use of org.eclipse.ui.internal.wizards.datatransfer.ArchiveFileExportOperation in project tdi-studio-se by Talend.

the class TalendWizardArchiveFileResourceExportPage1 method finish.

@Override
public boolean finish() {
    List resourcesToExport = getWhiteCheckedResources();
    if (!ensureTargetIsValid()) {
        return false;
    }
    // Save dirty editors if possible but do not stop if not all are saved
    saveDirtyEditors();
    // about to invoke the operation so save our state
    saveWidgetValues();
    final List results = new ArrayList(1);
    CoreRuntimePlugin.getInstance().getProxyRepositoryFactory().executeRepositoryWorkUnit(new RepositoryWorkUnit("refresh") {

        @Override
        protected void run() throws LoginException, PersistenceException {
            try {
                ResourcesPlugin.getWorkspace().getRoot().refreshLocal(IResource.DEPTH_INFINITE, null);
            } catch (CoreException e) {
                ExceptionHandler.process(e);
            }
            Display.getCurrent().syncExec(new Runnable() {

                @Override
                public void run() {
                    List resourcesToExport = getWhiteCheckedResources();
                    boolean r = executeExportOperation(new ArchiveFileExportOperation(null, resourcesToExport, getDestinationValue()));
                    results.add(r);
                }
            });
        }
    });
    return results.size() == 1;
}
Also used : ArchiveFileExportOperation(org.eclipse.ui.internal.wizards.datatransfer.ArchiveFileExportOperation) CoreException(org.eclipse.core.runtime.CoreException) ArrayList(java.util.ArrayList) PersistenceException(org.talend.commons.exception.PersistenceException) RepositoryWorkUnit(org.talend.repository.RepositoryWorkUnit) LoginException(org.talend.commons.exception.LoginException) ArrayList(java.util.ArrayList) List(java.util.List)

Example 2 with ArchiveFileExportOperation

use of org.eclipse.ui.internal.wizards.datatransfer.ArchiveFileExportOperation in project tdi-studio-se by Talend.

the class TalendWizardArchiveFileResourceExportPage2 method finish.

@Override
public boolean finish() {
    if (!ensureTargetIsValid()) {
        return false;
    }
    // Save dirty editors if possible but do not stop if not all are saved
    saveDirtyEditors();
    // about to invoke the operation so save our state
    saveWidgetValues();
    final List<Boolean> results = new ArrayList<Boolean>(1);
    CoreRuntimePlugin.getInstance().getProxyRepositoryFactory().executeRepositoryWorkUnit(new RepositoryWorkUnit("refresh") {

        @Override
        protected void run() throws LoginException, PersistenceException {
            try {
                ResourcesPlugin.getWorkspace().getRoot().refreshLocal(IResource.DEPTH_INFINITE, null);
            } catch (CoreException e) {
                ExceptionHandler.process(e);
            }
            Display.getCurrent().syncExec(new Runnable() {

                @Override
                public void run() {
                    List resourcesToExport = getWhiteCheckedResources();
                    boolean r = executeExportOperation(new ArchiveFileExportOperation(null, resourcesToExport, getDestinationValue()));
                    results.add(r);
                }
            });
        }
    });
    return results.size() == 1 && results.get(0) == true;
}
Also used : ArchiveFileExportOperation(org.eclipse.ui.internal.wizards.datatransfer.ArchiveFileExportOperation) CoreException(org.eclipse.core.runtime.CoreException) ArrayList(java.util.ArrayList) PersistenceException(org.talend.commons.exception.PersistenceException) RepositoryWorkUnit(org.talend.repository.RepositoryWorkUnit) LoginException(org.talend.commons.exception.LoginException) ArrayList(java.util.ArrayList) List(java.util.List)

Example 3 with ArchiveFileExportOperation

use of org.eclipse.ui.internal.wizards.datatransfer.ArchiveFileExportOperation in project knime-core by knime.

the class WorkflowExportWizard method doFinish.

/**
 * The worker method. It will find the container, create the export file if
 * missing or just replace its contents.
 */
private void doFinish(final IContainer container, final File fileName, final IProgressMonitor monitor) throws CoreException {
    // start zipping
    monitor.beginTask("Collect resources... ", 3);
    container.refreshLocal(IResource.DEPTH_INFINITE, monitor);
    // if the data should be excluded from the export
    // iterate over the resources and add only the wanted stuff
    // i.e. the "intern" folder and "*.zip" files are excluded
    final List<IResource> resourceList = new ArrayList<IResource>();
    for (IContainer child : m_workflowsToExport) {
        // add all files within the workflow
        addResourcesFor(resourceList, child, m_excludeData);
    }
    monitor.worked(1);
    try {
        ArchiveFileExportOperation exportOperation = null;
        // find lead offset
        final int leadOffset = findLeadOffset();
        if (leadOffset >= 0) {
            // if we have a workflow selected which is inside a workflow
            // group we want to export only the workflow, i.e. strip the
            // preceeding workflow groups from path:
            // this is done with the offset
            exportOperation = new OffsetArchiveFileExportOperation(container, resourceList, fileName.getPath());
            ((OffsetArchiveFileExportOperation) exportOperation).setOffset(leadOffset);
        } else {
            exportOperation = new ArchiveFileExportOperation(container, resourceList, fileName.getPath());
        }
        monitor.beginTask("Write to file... " + fileName, 3);
        exportOperation.run(monitor);
    } catch (Throwable t) {
        final String error = "KNIME project could not be exported." + "\n Reason: " + t.getMessage();
        NodeLogger.getLogger(getClass()).error(error, t);
        Display.getDefault().syncExec(new Runnable() {

            @Override
            public void run() {
                MessageDialog.openError(Display.getDefault().getActiveShell(), "Export could not be completed...", error);
            }
        });
    }
    monitor.worked(1);
}
Also used : ArchiveFileExportOperation(org.eclipse.ui.internal.wizards.datatransfer.ArchiveFileExportOperation) ArrayList(java.util.ArrayList) IContainer(org.eclipse.core.resources.IContainer) IResource(org.eclipse.core.resources.IResource)

Aggregations

ArrayList (java.util.ArrayList)3 ArchiveFileExportOperation (org.eclipse.ui.internal.wizards.datatransfer.ArchiveFileExportOperation)3 List (java.util.List)2 CoreException (org.eclipse.core.runtime.CoreException)2 LoginException (org.talend.commons.exception.LoginException)2 PersistenceException (org.talend.commons.exception.PersistenceException)2 RepositoryWorkUnit (org.talend.repository.RepositoryWorkUnit)2 IContainer (org.eclipse.core.resources.IContainer)1 IResource (org.eclipse.core.resources.IResource)1