Search in sources :

Example 16 with RepositoryWorkUnit

use of org.talend.repository.RepositoryWorkUnit 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 17 with RepositoryWorkUnit

use of org.talend.repository.RepositoryWorkUnit 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 18 with RepositoryWorkUnit

use of org.talend.repository.RepositoryWorkUnit in project tdi-studio-se by Talend.

the class DefaultRunProcessService method storeProjectPreferences.

@Override
public void storeProjectPreferences(IPreferenceStore preferenceStore) {
    RepositoryWorkUnit workUnit = new //$NON-NLS-1$
    RepositoryWorkUnit(//$NON-NLS-1$
    "Store project preferences") {

        @Override
        protected void run() {
            try {
                if (preferenceStore instanceof IPersistentPreferenceStore) {
                    ((IPersistentPreferenceStore) preferenceStore).save();
                }
            } catch (IOException e) {
                ExceptionHandler.process(e);
            }
        }
    };
    workUnit.setAvoidUnloadResources(true);
    ProxyRepositoryFactory.getInstance().executeRepositoryWorkUnit(workUnit);
}
Also used : RepositoryWorkUnit(org.talend.repository.RepositoryWorkUnit) IOException(java.io.IOException) IPersistentPreferenceStore(org.eclipse.jface.preference.IPersistentPreferenceStore)

Aggregations

RepositoryWorkUnit (org.talend.repository.RepositoryWorkUnit)18 PersistenceException (org.talend.commons.exception.PersistenceException)14 CoreException (org.eclipse.core.runtime.CoreException)12 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)9 IWorkspace (org.eclipse.core.resources.IWorkspace)8 IWorkspaceRunnable (org.eclipse.core.resources.IWorkspaceRunnable)8 ISchedulingRule (org.eclipse.core.runtime.jobs.ISchedulingRule)7 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)7 InvocationTargetException (java.lang.reflect.InvocationTargetException)6 ArrayList (java.util.ArrayList)6 LoginException (org.talend.commons.exception.LoginException)6 Item (org.talend.core.model.properties.Item)5 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)5 ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)4 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)4 Property (org.talend.core.model.properties.Property)4 HashMap (java.util.HashMap)3 List (java.util.List)3 Path (org.eclipse.core.runtime.Path)3 PartInitException (org.eclipse.ui.PartInitException)3