|
1 /** |
|
2 * Copyright (c) 2010 Symbian Foundation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Symbian Foundation - initial contribution. |
|
11 * Contributors: |
|
12 * Description: |
|
13 * Overview: |
|
14 * Details: |
|
15 * Platforms/Drives/Compatibility: |
|
16 * Assumptions/Requirement/Pre-requisites: |
|
17 * Failures and causes: |
|
18 */ |
|
19 package org.symbian.tools.tmw.internal.util; |
|
20 |
|
21 import java.lang.reflect.InvocationTargetException; |
|
22 import java.util.Set; |
|
23 |
|
24 import org.eclipse.core.resources.IFile; |
|
25 import org.eclipse.core.runtime.IProgressMonitor; |
|
26 import org.eclipse.jface.operation.IRunnableWithProgress; |
|
27 import org.eclipse.ui.IWorkbenchPage; |
|
28 import org.eclipse.ui.PartInitException; |
|
29 import org.eclipse.ui.PlatformUI; |
|
30 import org.eclipse.ui.ide.IDE; |
|
31 import org.symbian.tools.tmw.ui.TMWCoreUI; |
|
32 |
|
33 public class OpenFilesRunnable implements IRunnableWithProgress { |
|
34 private final IFile[] openFiles; |
|
35 |
|
36 public OpenFilesRunnable(Set<IFile> openFiles) { |
|
37 this.openFiles = openFiles.toArray(new IFile[openFiles.size()]); |
|
38 } |
|
39 |
|
40 public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { |
|
41 monitor.beginTask("Opening files in editors", openFiles.length); |
|
42 for (IFile file : openFiles) { |
|
43 IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); |
|
44 try { |
|
45 IDE.openEditor(page, file); |
|
46 } catch (PartInitException e) { |
|
47 TMWCoreUI.log(e); |
|
48 } |
|
49 monitor.worked(1); |
|
50 } |
|
51 monitor.done(); |
|
52 } |
|
53 } |