Search in sources :

Example 1 with CreateFileOperation

use of org.eclipse.ui.ide.undo.CreateFileOperation in project tdi-studio-se by Talend.

the class ExportProjectsAsAction method initializeExternalLibraries.

/**
     * DOC bqian Comment method "test".
     */
private void initializeExternalLibraries() {
    initializeLibPath();
    // final InputStream initialContents = null;
    final Map<Project, List<LinkTargetStore>> map = getProjectAndRelatedLinks();
    IRunnableWithProgress op = new IRunnableWithProgress() {

        @Override
        public void run(IProgressMonitor monitor) {
            Set<Project> projects = map.keySet();
            //$NON-NLS-1$
            monitor.beginTask(Messages.getString("ExportProjectsAsAction.createLiberariesLink"), projects.size());
            for (Project project : projects) {
                //$NON-NLS-1$
                monitor.setTaskName(Messages.getString("ExportProjectsAsAction.processProject") + project.getLabel());
                List<LinkTargetStore> links = map.get(project);
                for (LinkTargetStore store : links) {
                    // CreateFileOperation op = new CreateFileOperation(store.file, store.uri, null,
                    // IDEWorkbenchMessages.WizardNewFileCreationPage_title);
                    CreateFileOperation op = new CreateFileOperation(store.file, store.uri, null, //$NON-NLS-1$
                    Messages.getString("IDEWorkbenchMessages.WizardNewFileCreationPage_title"));
                    try {
                        PlatformUI.getWorkbench().getOperationSupport().getOperationHistory().execute(op, monitor, WorkspaceUndoUtil.getUIInfoAdapter(window.getShell()));
                    } catch (final ExecutionException e) {
                        ExceptionHandler.process(e);
                    }
                }
                monitor.worked(1);
            }
            monitor.done();
        }
    };
    try {
        PlatformUI.getWorkbench().getActiveWorkbenchWindow().run(true, true, op);
    } catch (Exception e) {
        // e.printStackTrace();
        ExceptionHandler.process(e);
    }
}
Also used : IProject(org.eclipse.core.resources.IProject) Project(org.talend.core.model.general.Project) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CreateFileOperation(org.eclipse.ui.ide.undo.CreateFileOperation) ArrayList(java.util.ArrayList) List(java.util.List) ExecutionException(org.eclipse.core.commands.ExecutionException) CoreException(org.eclipse.core.runtime.CoreException) ExecutionException(org.eclipse.core.commands.ExecutionException) PersistenceException(org.talend.commons.exception.PersistenceException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Aggregations

ArrayList (java.util.ArrayList)1 List (java.util.List)1 ExecutionException (org.eclipse.core.commands.ExecutionException)1 IProject (org.eclipse.core.resources.IProject)1 CoreException (org.eclipse.core.runtime.CoreException)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)1 CreateFileOperation (org.eclipse.ui.ide.undo.CreateFileOperation)1 PersistenceException (org.talend.commons.exception.PersistenceException)1 Project (org.talend.core.model.general.Project)1