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