plugins/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/util/ProjectUtils.java
author Eugene Ostroukhov <eugeneo@symbian.org>
Tue, 31 Aug 2010 11:58:53 -0700
changeset 479 518afa7c6d2f
parent 470 d4809db37847
child 480 b6d992b9b998
permissions -rw-r--r--
Minor refactoring to make API more clear
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
     1
/**
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
     2
 * Copyright (c) 2009 Symbian Foundation and/or its subsidiary(-ies).
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
     3
 * All rights reserved.
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
     4
 * This component and the accompanying materials are made available
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
     5
 * under the terms of the License "Eclipse Public License v1.0"
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
     6
 * which accompanies this distribution, and is available
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
     7
 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
     8
 *
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
     9
 * Initial Contributors:
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    10
 * Symbian Foundation - initial contribution.
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    11
 * Contributors:
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    12
 * Description:
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    13
 * Overview:
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    14
 * Details:
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    15
 * Platforms/Drives/Compatibility:
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    16
 * Assumptions/Requirement/Pre-requisites:
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    17
 * Failures and causes:
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    18
 */
11
05e53cfc29d8 Import previewer implemented
Eugene Ostroukhov
parents: 3
diff changeset
    19
package org.symbian.tools.wrttools.util;
3
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    20
11
05e53cfc29d8 Import previewer implemented
Eugene Ostroukhov
parents: 3
diff changeset
    21
import java.io.File;
63
558819056485 Importing WGZ is now supported. Several bugfixes in other areas were made
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 54
diff changeset
    22
import java.io.FileInputStream;
11
05e53cfc29d8 Import previewer implemented
Eugene Ostroukhov
parents: 3
diff changeset
    23
import java.io.IOException;
309
c01f5ab28a11 Refactored to add extended support for JS Libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 308
diff changeset
    24
import java.io.InputStream;
3
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    25
import java.net.URI;
63
558819056485 Importing WGZ is now supported. Several bugfixes in other areas were made
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 54
diff changeset
    26
import java.text.MessageFormat;
200
830136ec8316 Wizard can now import projects of any time (i.e. Dreamweaver, WRT IDE) from the filesystem
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 156
diff changeset
    27
import java.util.Arrays;
139
f0a865ead60b Fixed Bug 1869 - Open index file and select it in navigator after the project is created/imported
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 135
diff changeset
    28
import java.util.Collection;
f0a865ead60b Fixed Bug 1869 - Open index file and select it in navigator after the project is created/imported
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 135
diff changeset
    29
import java.util.HashSet;
200
830136ec8316 Wizard can now import projects of any time (i.e. Dreamweaver, WRT IDE) from the filesystem
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 156
diff changeset
    30
import java.util.LinkedList;
830136ec8316 Wizard can now import projects of any time (i.e. Dreamweaver, WRT IDE) from the filesystem
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 156
diff changeset
    31
import java.util.List;
830136ec8316 Wizard can now import projects of any time (i.e. Dreamweaver, WRT IDE) from the filesystem
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 156
diff changeset
    32
import java.util.TreeSet;
63
558819056485 Importing WGZ is now supported. Several bugfixes in other areas were made
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 54
diff changeset
    33
import java.util.zip.ZipEntry;
11
05e53cfc29d8 Import previewer implemented
Eugene Ostroukhov
parents: 3
diff changeset
    34
import java.util.zip.ZipInputStream;
3
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    35
11
05e53cfc29d8 Import previewer implemented
Eugene Ostroukhov
parents: 3
diff changeset
    36
import javax.swing.filechooser.FileSystemView;
05e53cfc29d8 Import previewer implemented
Eugene Ostroukhov
parents: 3
diff changeset
    37
92
e5c37ce1b003 Both WTP and JSDT validation now work
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 82
diff changeset
    38
import org.eclipse.core.resources.ICommand;
63
558819056485 Importing WGZ is now supported. Several bugfixes in other areas were made
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 54
diff changeset
    39
import org.eclipse.core.resources.IContainer;
11
05e53cfc29d8 Import previewer implemented
Eugene Ostroukhov
parents: 3
diff changeset
    40
import org.eclipse.core.resources.IFile;
63
558819056485 Importing WGZ is now supported. Several bugfixes in other areas were made
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 54
diff changeset
    41
import org.eclipse.core.resources.IFolder;
282
39bbb3a15d6f Bug 2341 - Files excluded from widget archive are not clearly marked
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 281
diff changeset
    42
import org.eclipse.core.resources.IMarker;
3
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    43
import org.eclipse.core.resources.IProject;
54
5a2cfa9bc743 Nature is used for UI
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 49
diff changeset
    44
import org.eclipse.core.resources.IProjectDescription;
63
558819056485 Importing WGZ is now supported. Several bugfixes in other areas were made
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 54
diff changeset
    45
import org.eclipse.core.resources.IResource;
156
5d68e30cba9b Fixed Bug 1864 - WRTKit content assist is not always available.
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 139
diff changeset
    46
import org.eclipse.core.resources.IResourceVisitor;
3
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    47
import org.eclipse.core.resources.IWorkspace;
156
5d68e30cba9b Fixed Bug 1864 - WRTKit content assist is not always available.
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 139
diff changeset
    48
import org.eclipse.core.resources.IWorkspaceRunnable;
3
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    49
import org.eclipse.core.resources.ResourcesPlugin;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    50
import org.eclipse.core.runtime.CoreException;
63
558819056485 Importing WGZ is now supported. Several bugfixes in other areas were made
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 54
diff changeset
    51
import org.eclipse.core.runtime.IPath;
3
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    52
import org.eclipse.core.runtime.IProgressMonitor;
156
5d68e30cba9b Fixed Bug 1864 - WRTKit content assist is not always available.
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 139
diff changeset
    53
import org.eclipse.core.runtime.IStatus;
11
05e53cfc29d8 Import previewer implemented
Eugene Ostroukhov
parents: 3
diff changeset
    54
import org.eclipse.core.runtime.NullProgressMonitor;
63
558819056485 Importing WGZ is now supported. Several bugfixes in other areas were made
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 54
diff changeset
    55
import org.eclipse.core.runtime.Path;
156
5d68e30cba9b Fixed Bug 1864 - WRTKit content assist is not always available.
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 139
diff changeset
    56
import org.eclipse.core.runtime.Status;
3
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    57
import org.eclipse.core.runtime.SubProgressMonitor;
156
5d68e30cba9b Fixed Bug 1864 - WRTKit content assist is not always available.
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 139
diff changeset
    58
import org.eclipse.core.runtime.jobs.Job;
139
f0a865ead60b Fixed Bug 1869 - Open index file and select it in navigator after the project is created/imported
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 135
diff changeset
    59
import org.eclipse.jface.viewers.StructuredSelection;
156
5d68e30cba9b Fixed Bug 1864 - WRTKit content assist is not always available.
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 139
diff changeset
    60
import org.eclipse.swt.widgets.Display;
454
38d6944cff88 Bug 3352 - Replace our Navigator View with the JSDT one
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 438
diff changeset
    61
import org.eclipse.ui.IPageLayout;
139
f0a865ead60b Fixed Bug 1869 - Open index file and select it in navigator after the project is created/imported
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 135
diff changeset
    62
import org.eclipse.ui.IViewReference;
f0a865ead60b Fixed Bug 1869 - Open index file and select it in navigator after the project is created/imported
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 135
diff changeset
    63
import org.eclipse.ui.IWorkbenchPage;
f0a865ead60b Fixed Bug 1869 - Open index file and select it in navigator after the project is created/imported
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 135
diff changeset
    64
import org.eclipse.ui.IWorkbenchPart;
f0a865ead60b Fixed Bug 1869 - Open index file and select it in navigator after the project is created/imported
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 135
diff changeset
    65
import org.eclipse.ui.PlatformUI;
f0a865ead60b Fixed Bug 1869 - Open index file and select it in navigator after the project is created/imported
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 135
diff changeset
    66
import org.eclipse.ui.ide.IDE;
200
830136ec8316 Wizard can now import projects of any time (i.e. Dreamweaver, WRT IDE) from the filesystem
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 156
diff changeset
    67
import org.eclipse.ui.internal.wizards.datatransfer.TarEntry;
139
f0a865ead60b Fixed Bug 1869 - Open index file and select it in navigator after the project is created/imported
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 135
diff changeset
    68
import org.eclipse.ui.part.ISetSelectionTarget;
216
914d053d42b1 Bug 2070 - added code completion for browser objects (window, navigator, etc) and core WRT objects (widget, device)
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 203
diff changeset
    69
import org.eclipse.wst.jsdt.core.IIncludePathEntry;
914d053d42b1 Bug 2070 - added code completion for browser objects (window, navigator, etc) and core WRT objects (widget, device)
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 203
diff changeset
    70
import org.eclipse.wst.jsdt.core.IJavaScriptProject;
92
e5c37ce1b003 Both WTP and JSDT validation now work
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 82
diff changeset
    71
import org.eclipse.wst.jsdt.core.JavaScriptCore;
216
914d053d42b1 Bug 2070 - added code completion for browser objects (window, navigator, etc) and core WRT objects (widget, device)
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 203
diff changeset
    72
import org.eclipse.wst.jsdt.core.LibrarySuperType;
914d053d42b1 Bug 2070 - added code completion for browser objects (window, navigator, etc) and core WRT objects (widget, device)
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 203
diff changeset
    73
import org.eclipse.wst.jsdt.internal.core.JavaProject;
3
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    74
import org.eclipse.wst.jsdt.internal.ui.wizards.buildpaths.BuildPathsBlock;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    75
import org.eclipse.wst.validation.ValidationFramework;
11
05e53cfc29d8 Import previewer implemented
Eugene Ostroukhov
parents: 3
diff changeset
    76
import org.symbian.tools.wrttools.Activator;
54
5a2cfa9bc743 Nature is used for UI
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 49
diff changeset
    77
import org.symbian.tools.wrttools.WidgetProjectNature;
282
39bbb3a15d6f Bug 2341 - Files excluded from widget archive are not clearly marked
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 281
diff changeset
    78
import org.symbian.tools.wrttools.core.packager.WRTPackagerConstants;
216
914d053d42b1 Bug 2070 - added code completion for browser objects (window, navigator, etc) and core WRT objects (widget, device)
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 203
diff changeset
    79
import org.symbian.tools.wrttools.wizards.WrtLibraryWizardPage;
3
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    80
119
be293233cdde Some compilation warnings were cleared
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 98
diff changeset
    81
@SuppressWarnings("restriction")
3
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    82
public class ProjectUtils {
300
9505af44d7bf Bug 2480 and bug 2430
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 283
diff changeset
    83
    public static final String EXCLUDE_MARKER_ID = "org.symbian.tools.wrttools.excluded";
282
39bbb3a15d6f Bug 2341 - Files excluded from widget archive are not clearly marked
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 281
diff changeset
    84
236
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
    85
    private static final class FocusOnProjectJob extends Job {
156
5d68e30cba9b Fixed Bug 1864 - WRTKit content assist is not always available.
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 139
diff changeset
    86
236
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
    87
        private final Display display;
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
    88
        private final IProject[] projects;
156
5d68e30cba9b Fixed Bug 1864 - WRTKit content assist is not always available.
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 139
diff changeset
    89
236
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
    90
        public FocusOnProjectJob(IProject[] projects, Display display) {
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
    91
            super("Preparing projects");
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
    92
            this.projects = projects;
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
    93
            this.display = display;
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
    94
            setRule(this.projects.length == 1 ? projects[0] : projects[0].getWorkspace().getRoot());
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
    95
            setUser(false);
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
    96
        }
156
5d68e30cba9b Fixed Bug 1864 - WRTKit content assist is not always available.
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 139
diff changeset
    97
236
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
    98
        @Override
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
    99
        protected IStatus run(IProgressMonitor monitor) {
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   100
            try {
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   101
                final Collection<IFile> files = new HashSet<IFile>(projects.length);
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   102
                for (IProject project : projects) {
479
518afa7c6d2f Minor refactoring to make API more clear
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 470
diff changeset
   103
                    IFile index = CoreUtil.getIndexFile(project);
518afa7c6d2f Minor refactoring to make API more clear
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 470
diff changeset
   104
                    if (index != null && index.isAccessible()) {
518afa7c6d2f Minor refactoring to make API more clear
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 470
diff changeset
   105
                        files.add(index);
236
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   106
                    }
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   107
                }
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   108
                final IFile[] filesArray = files.toArray(new IFile[files.size()]);
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   109
                if (filesArray.length > 0) {
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   110
                    display.asyncExec(new Runnable() {
156
5d68e30cba9b Fixed Bug 1864 - WRTKit content assist is not always available.
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 139
diff changeset
   111
236
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   112
                        public void run() {
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   113
                            IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   114
                                    .getActivePage();
454
38d6944cff88 Bug 3352 - Replace our Navigator View with the JSDT one
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 438
diff changeset
   115
                            IViewReference reference = activePage.findViewReference(IPageLayout.ID_PROJECT_EXPLORER);
236
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   116
                            IWorkbenchPart part = reference.getPart(false);
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   117
                            if (part instanceof ISetSelectionTarget) {
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   118
                                StructuredSelection selection;
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   119
                                if (filesArray.length == 1) {
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   120
                                    selection = new StructuredSelection(filesArray[0]);
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   121
                                } else {
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   122
                                    selection = new StructuredSelection(filesArray);
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   123
                                }
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   124
                                ((ISetSelectionTarget) part).selectReveal(selection);
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   125
                            }
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   126
                            try {
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   127
                                IDE.openEditors(activePage, filesArray);
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   128
                                ResourcesPlugin.getWorkspace().run(new TouchAllResources(projects),
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   129
                                        new NullProgressMonitor());
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   130
                            } catch (CoreException e) {
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   131
                                Activator.log(e);
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   132
                            }
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   133
                        }
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   134
                    });
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   135
                }
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   136
            } catch (CoreException e) {
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   137
                Activator.log(e);
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   138
            }
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   139
            return Status.OK_STATUS;
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   140
        }
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   141
    }
200
830136ec8316 Wizard can now import projects of any time (i.e. Dreamweaver, WRT IDE) from the filesystem
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 156
diff changeset
   142
236
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   143
    private static final class TouchAllResources implements IWorkspaceRunnable {
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   144
        private final IProject[] projects;
200
830136ec8316 Wizard can now import projects of any time (i.e. Dreamweaver, WRT IDE) from the filesystem
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 156
diff changeset
   145
236
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   146
        public TouchAllResources(IProject[] projects) {
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   147
            this.projects = projects;
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   148
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   149
        }
200
830136ec8316 Wizard can now import projects of any time (i.e. Dreamweaver, WRT IDE) from the filesystem
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 156
diff changeset
   150
236
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   151
        public void run(IProgressMonitor monitor) throws CoreException {
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   152
            for (IProject project : projects) {
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   153
                project.accept(new IResourceVisitor() {
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   154
                    public boolean visit(IResource resource) throws CoreException {
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   155
                        if (resource.isAccessible() && resource.getType() == IResource.FILE
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   156
                                && resource.getFileExtension().equals("js")) {
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   157
                            resource.touch(new NullProgressMonitor());
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   158
                        }
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   159
                        return true;
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   160
                    }
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   161
                });
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   162
            }
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   163
        }
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   164
    }
200
830136ec8316 Wizard can now import projects of any time (i.e. Dreamweaver, WRT IDE) from the filesystem
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 156
diff changeset
   165
236
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   166
    private static final String DEFAULT_APTANA_WORKSPACE = "Aptana Studio Workspace";
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   167
    private static final Collection<String> EXCLUDED;
200
830136ec8316 Wizard can now import projects of any time (i.e. Dreamweaver, WRT IDE) from the filesystem
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 156
diff changeset
   168
236
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   169
    public static final String PREVIEW_FOLDER = "preview";
200
830136ec8316 Wizard can now import projects of any time (i.e. Dreamweaver, WRT IDE) from the filesystem
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 156
diff changeset
   170
236
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   171
    public static final String PREVIEW_FRAME_FILE = "wrt_preview_frame.html";
200
830136ec8316 Wizard can now import projects of any time (i.e. Dreamweaver, WRT IDE) from the filesystem
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 156
diff changeset
   172
236
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   173
    public static final String PREVIEW_MAIN_FILE = "wrt_preview_main.html";
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   174
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   175
    static {
200
830136ec8316 Wizard can now import projects of any time (i.e. Dreamweaver, WRT IDE) from the filesystem
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 156
diff changeset
   176
        EXCLUDED = new TreeSet<String>(Arrays.asList(".project", ProjectUtils.PREVIEW_FOLDER,
830136ec8316 Wizard can now import projects of any time (i.e. Dreamweaver, WRT IDE) from the filesystem
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 156
diff changeset
   177
                ProjectUtils.PREVIEW_FRAME_FILE, ProjectUtils.PREVIEW_MAIN_FILE));
830136ec8316 Wizard can now import projects of any time (i.e. Dreamweaver, WRT IDE) from the filesystem
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 156
diff changeset
   178
    }
830136ec8316 Wizard can now import projects of any time (i.e. Dreamweaver, WRT IDE) from the filesystem
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 156
diff changeset
   179
236
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   180
    private static boolean accepted(Object object) {
200
830136ec8316 Wizard can now import projects of any time (i.e. Dreamweaver, WRT IDE) from the filesystem
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 156
diff changeset
   181
        final String name;
830136ec8316 Wizard can now import projects of any time (i.e. Dreamweaver, WRT IDE) from the filesystem
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 156
diff changeset
   182
        if (object instanceof ZipEntry) {
830136ec8316 Wizard can now import projects of any time (i.e. Dreamweaver, WRT IDE) from the filesystem
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 156
diff changeset
   183
            name = ((ZipEntry) object).getName();
830136ec8316 Wizard can now import projects of any time (i.e. Dreamweaver, WRT IDE) from the filesystem
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 156
diff changeset
   184
        } else if (object instanceof TarEntry) {
830136ec8316 Wizard can now import projects of any time (i.e. Dreamweaver, WRT IDE) from the filesystem
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 156
diff changeset
   185
            name = ((TarEntry) object).getName();
830136ec8316 Wizard can now import projects of any time (i.e. Dreamweaver, WRT IDE) from the filesystem
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 156
diff changeset
   186
        } else if (object instanceof File) {
830136ec8316 Wizard can now import projects of any time (i.e. Dreamweaver, WRT IDE) from the filesystem
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 156
diff changeset
   187
            name = ((File) object).getAbsolutePath();
830136ec8316 Wizard can now import projects of any time (i.e. Dreamweaver, WRT IDE) from the filesystem
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 156
diff changeset
   188
        } else {
830136ec8316 Wizard can now import projects of any time (i.e. Dreamweaver, WRT IDE) from the filesystem
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 156
diff changeset
   189
            throw new IllegalArgumentException("Unforeseen entry type: " + object.getClass());
830136ec8316 Wizard can now import projects of any time (i.e. Dreamweaver, WRT IDE) from the filesystem
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 156
diff changeset
   190
        }
830136ec8316 Wizard can now import projects of any time (i.e. Dreamweaver, WRT IDE) from the filesystem
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 156
diff changeset
   191
        IPath path = new Path(name);
830136ec8316 Wizard can now import projects of any time (i.e. Dreamweaver, WRT IDE) from the filesystem
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 156
diff changeset
   192
        return isValidProjectFile(path.lastSegment());
830136ec8316 Wizard can now import projects of any time (i.e. Dreamweaver, WRT IDE) from the filesystem
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 156
diff changeset
   193
    }
830136ec8316 Wizard can now import projects of any time (i.e. Dreamweaver, WRT IDE) from the filesystem
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 156
diff changeset
   194
236
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   195
    public static void addWrtNature(IProject project) {
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   196
        if (!hasWrtNature(project)) {
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   197
            try {
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   198
                IProjectDescription description = project.getDescription();
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   199
                String[] natureIds = description.getNatureIds();
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   200
                String[] newNatures = new String[natureIds.length + 1];
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   201
                System.arraycopy(natureIds, 0, newNatures, 1, natureIds.length);
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   202
                newNatures[0] = WidgetProjectNature.ID;
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   203
                description.setNatureIds(newNatures);
200
830136ec8316 Wizard can now import projects of any time (i.e. Dreamweaver, WRT IDE) from the filesystem
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 156
diff changeset
   204
236
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   205
                ICommand[] buildSpec = description.getBuildSpec();
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   206
                for (int i = 0; i < buildSpec.length; i++) {
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   207
                    ICommand command = buildSpec[i];
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   208
                    if (JavaScriptCore.BUILDER_ID.equals(command.getBuilderName())) {
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   209
                        buildSpec[i] = buildSpec[buildSpec.length - 1];
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   210
                        buildSpec[buildSpec.length - 1] = command;
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   211
                        description.setBuildSpec(buildSpec);
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   212
                        break;
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   213
                    }
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   214
                }
200
830136ec8316 Wizard can now import projects of any time (i.e. Dreamweaver, WRT IDE) from the filesystem
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 156
diff changeset
   215
236
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   216
                project.setDescription(description, new NullProgressMonitor());
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   217
            } catch (CoreException e) {
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   218
                Activator.log(e);
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   219
            }
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   220
        }
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   221
    }
200
830136ec8316 Wizard can now import projects of any time (i.e. Dreamweaver, WRT IDE) from the filesystem
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 156
diff changeset
   222
236
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   223
    private static void checkParent(IContainer parent) throws CoreException {
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   224
        if (parent.getType() == IResource.FOLDER && !parent.exists()) {
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   225
            checkParent(parent.getParent());
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   226
            ((IFolder) parent).create(false, true, new NullProgressMonitor());
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   227
        }
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   228
    }
200
830136ec8316 Wizard can now import projects of any time (i.e. Dreamweaver, WRT IDE) from the filesystem
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 156
diff changeset
   229
236
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   230
    public static void copyFile(IProject project, String name, ZipInputStream stream, long size,
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   231
            IProgressMonitor monitor) throws CoreException, IOException {
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   232
        IFile file = project.getFile(name);
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   233
        file.create(new NonClosingStream(stream), true, new SubProgressMonitor(monitor, 1));
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   234
    }
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   235
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   236
    public static IProject createWrtProject(String name, URI uri, IProgressMonitor monitor) throws CoreException {
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   237
        uri = isDefaultProjectLocation(uri) ? null : uri;
438
99afbaa8a4bc Bug 3037 - Delete project and recreation causes javascript parsing problem
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 351
diff changeset
   238
        monitor.beginTask("Create project resources", 30);
236
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   239
        IWorkspace workspace = ResourcesPlugin.getWorkspace();
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   240
        IProject project = workspace.getRoot().getProject(name);
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   241
        BuildPathsBlock.createProject(project, uri, new SubProgressMonitor(monitor, 10));
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   242
        BuildPathsBlock.addJavaNature(project, new SubProgressMonitor(monitor, 10));
200
830136ec8316 Wizard can now import projects of any time (i.e. Dreamweaver, WRT IDE) from the filesystem
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 156
diff changeset
   243
236
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   244
        ValidationFramework.getDefault().addValidationBuilder(project);
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   245
        ValidationFramework.getDefault().applyChanges(ValidationFramework.getDefault().getProjectSettings(project),
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   246
                true);
200
830136ec8316 Wizard can now import projects of any time (i.e. Dreamweaver, WRT IDE) from the filesystem
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 156
diff changeset
   247
216
914d053d42b1 Bug 2070 - added code completion for browser objects (window, navigator, etc) and core WRT objects (widget, device)
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 203
diff changeset
   248
        IJavaScriptProject jsProject = JavaScriptCore.create(project);
438
99afbaa8a4bc Bug 3037 - Delete project and recreation causes javascript parsing problem
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 351
diff changeset
   249
        jsProject.setRawIncludepath(null, new SubProgressMonitor(monitor, 5)); // See bug 3037
216
914d053d42b1 Bug 2070 - added code completion for browser objects (window, navigator, etc) and core WRT objects (widget, device)
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 203
diff changeset
   250
        final IIncludePathEntry[] includepath = jsProject.getRawIncludepath();
914d053d42b1 Bug 2070 - added code completion for browser objects (window, navigator, etc) and core WRT objects (widget, device)
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 203
diff changeset
   251
        final IIncludePathEntry[] newIncludePath = new IIncludePathEntry[includepath.length + 1];
914d053d42b1 Bug 2070 - added code completion for browser objects (window, navigator, etc) and core WRT objects (widget, device)
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 203
diff changeset
   252
914d053d42b1 Bug 2070 - added code completion for browser objects (window, navigator, etc) and core WRT objects (widget, device)
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 203
diff changeset
   253
        System.arraycopy(includepath, 0, newIncludePath, 0, includepath.length);
914d053d42b1 Bug 2070 - added code completion for browser objects (window, navigator, etc) and core WRT objects (widget, device)
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 203
diff changeset
   254
        newIncludePath[includepath.length] = JavaScriptCore.newContainerEntry(new Path(
914d053d42b1 Bug 2070 - added code completion for browser objects (window, navigator, etc) and core WRT objects (widget, device)
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 203
diff changeset
   255
                WrtLibraryWizardPage.CONTAINER_ID));
914d053d42b1 Bug 2070 - added code completion for browser objects (window, navigator, etc) and core WRT objects (widget, device)
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 203
diff changeset
   256
914d053d42b1 Bug 2070 - added code completion for browser objects (window, navigator, etc) and core WRT objects (widget, device)
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 203
diff changeset
   257
        jsProject.setRawIncludepath(newIncludePath, new SubProgressMonitor(monitor, 5));
914d053d42b1 Bug 2070 - added code completion for browser objects (window, navigator, etc) and core WRT objects (widget, device)
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 203
diff changeset
   258
914d053d42b1 Bug 2070 - added code completion for browser objects (window, navigator, etc) and core WRT objects (widget, device)
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 203
diff changeset
   259
        LibrarySuperType superType = new LibrarySuperType(new Path(WrtLibraryWizardPage.CONTAINER_ID), jsProject,
914d053d42b1 Bug 2070 - added code completion for browser objects (window, navigator, etc) and core WRT objects (widget, device)
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 203
diff changeset
   260
                "Window");
914d053d42b1 Bug 2070 - added code completion for browser objects (window, navigator, etc) and core WRT objects (widget, device)
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 203
diff changeset
   261
        ((JavaProject) jsProject).setCommonSuperType(superType);
200
830136ec8316 Wizard can now import projects of any time (i.e. Dreamweaver, WRT IDE) from the filesystem
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 156
diff changeset
   262
236
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   263
        addWrtNature(project);
200
830136ec8316 Wizard can now import projects of any time (i.e. Dreamweaver, WRT IDE) from the filesystem
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 156
diff changeset
   264
283
c035b31473c1 Configuration files are excluded from packaging
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 282
diff changeset
   265
        excludeResources(project);
c035b31473c1 Configuration files are excluded from packaging
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 282
diff changeset
   266
236
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   267
        monitor.done();
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   268
        return project;
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   269
    }
200
830136ec8316 Wizard can now import projects of any time (i.e. Dreamweaver, WRT IDE) from the filesystem
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 156
diff changeset
   270
283
c035b31473c1 Configuration files are excluded from packaging
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 282
diff changeset
   271
    private static void excludeResources(IProject project) {
c035b31473c1 Configuration files are excluded from packaging
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 282
diff changeset
   272
        IFile file = project.getFile(IProjectDescription.DESCRIPTION_FILE_NAME);
c035b31473c1 Configuration files are excluded from packaging
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 282
diff changeset
   273
        if (file.exists()) {
c035b31473c1 Configuration files are excluded from packaging
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 282
diff changeset
   274
            exclude(file);
c035b31473c1 Configuration files are excluded from packaging
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 282
diff changeset
   275
        }
c035b31473c1 Configuration files are excluded from packaging
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 282
diff changeset
   276
        IFolder settings = project.getFolder(".settings");
c035b31473c1 Configuration files are excluded from packaging
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 282
diff changeset
   277
        if (settings.exists()) {
c035b31473c1 Configuration files are excluded from packaging
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 282
diff changeset
   278
            excludeFolder(settings);
c035b31473c1 Configuration files are excluded from packaging
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 282
diff changeset
   279
            exclude(settings);
c035b31473c1 Configuration files are excluded from packaging
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 282
diff changeset
   280
        }
c035b31473c1 Configuration files are excluded from packaging
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 282
diff changeset
   281
    }
c035b31473c1 Configuration files are excluded from packaging
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 282
diff changeset
   282
c035b31473c1 Configuration files are excluded from packaging
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 282
diff changeset
   283
    private static void excludeFolder(IFolder folder) {
c035b31473c1 Configuration files are excluded from packaging
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 282
diff changeset
   284
        exclude(folder);
c035b31473c1 Configuration files are excluded from packaging
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 282
diff changeset
   285
        try {
c035b31473c1 Configuration files are excluded from packaging
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 282
diff changeset
   286
            IResource[] members = folder.members();
c035b31473c1 Configuration files are excluded from packaging
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 282
diff changeset
   287
            for (IResource resource : members) {
c035b31473c1 Configuration files are excluded from packaging
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 282
diff changeset
   288
                if (resource.getType() == IResource.FOLDER) {
c035b31473c1 Configuration files are excluded from packaging
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 282
diff changeset
   289
                    excludeFolder((IFolder) resource);
c035b31473c1 Configuration files are excluded from packaging
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 282
diff changeset
   290
                } else {
c035b31473c1 Configuration files are excluded from packaging
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 282
diff changeset
   291
                    exclude(resource);
c035b31473c1 Configuration files are excluded from packaging
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 282
diff changeset
   292
                }
c035b31473c1 Configuration files are excluded from packaging
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 282
diff changeset
   293
            }
c035b31473c1 Configuration files are excluded from packaging
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 282
diff changeset
   294
        } catch (CoreException e) {
c035b31473c1 Configuration files are excluded from packaging
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 282
diff changeset
   295
            Activator.log(e);
c035b31473c1 Configuration files are excluded from packaging
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 282
diff changeset
   296
        }
c035b31473c1 Configuration files are excluded from packaging
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 282
diff changeset
   297
    }
c035b31473c1 Configuration files are excluded from packaging
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 282
diff changeset
   298
236
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   299
    public static List<Object> filterExternalProjectEntries(List<Object> fileSystemObjects) {
200
830136ec8316 Wizard can now import projects of any time (i.e. Dreamweaver, WRT IDE) from the filesystem
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 156
diff changeset
   300
        List<Object> result = new LinkedList<Object>();
830136ec8316 Wizard can now import projects of any time (i.e. Dreamweaver, WRT IDE) from the filesystem
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 156
diff changeset
   301
        for (Object object : fileSystemObjects) {
830136ec8316 Wizard can now import projects of any time (i.e. Dreamweaver, WRT IDE) from the filesystem
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 156
diff changeset
   302
            if (accepted(object)) {
830136ec8316 Wizard can now import projects of any time (i.e. Dreamweaver, WRT IDE) from the filesystem
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 156
diff changeset
   303
                result.add(object);
830136ec8316 Wizard can now import projects of any time (i.e. Dreamweaver, WRT IDE) from the filesystem
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 156
diff changeset
   304
            }
830136ec8316 Wizard can now import projects of any time (i.e. Dreamweaver, WRT IDE) from the filesystem
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 156
diff changeset
   305
        }
830136ec8316 Wizard can now import projects of any time (i.e. Dreamweaver, WRT IDE) from the filesystem
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 156
diff changeset
   306
        return result;
830136ec8316 Wizard can now import projects of any time (i.e. Dreamweaver, WRT IDE) from the filesystem
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 156
diff changeset
   307
    }
830136ec8316 Wizard can now import projects of any time (i.e. Dreamweaver, WRT IDE) from the filesystem
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 156
diff changeset
   308
236
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   309
    public static void focusOn(IProject... projects) {
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   310
        new FocusOnProjectJob(projects, Display.getCurrent()).schedule(50);
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   311
    }
200
830136ec8316 Wizard can now import projects of any time (i.e. Dreamweaver, WRT IDE) from the filesystem
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 156
diff changeset
   312
236
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   313
    public static String getDefaultAptanaLocation() {
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   314
        File myDocuments = FileSystemView.getFileSystemView().getDefaultDirectory();
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   315
        File file = new File(myDocuments, DEFAULT_APTANA_WORKSPACE); // Windows
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   316
        if (file.exists()) {
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   317
            return file.getAbsolutePath();
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   318
        }
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   319
        file = new File(myDocuments, "Documents" + File.separator + DEFAULT_APTANA_WORKSPACE); // Mac OS X
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   320
        if (file.exists()) {
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   321
            return file.getAbsolutePath();
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   322
        }
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   323
        return "";
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   324
    }
200
830136ec8316 Wizard can now import projects of any time (i.e. Dreamweaver, WRT IDE) from the filesystem
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 156
diff changeset
   325
236
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   326
    public static boolean hasWrtNature(IProject project) {
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   327
        try {
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   328
            return project.hasNature(WidgetProjectNature.ID);
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   329
        } catch (CoreException e) {
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   330
            Activator.log(e);
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   331
            return false;
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   332
        }
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   333
    }
200
830136ec8316 Wizard can now import projects of any time (i.e. Dreamweaver, WRT IDE) from the filesystem
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 156
diff changeset
   334
203
bb3a18c4e037 Refactoring, some messages were updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 200
diff changeset
   335
    public static File isWrtProject(File[] contents) {
236
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   336
        for (int i = 0; i < contents.length; i++) {
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   337
            File file = contents[i];
200
830136ec8316 Wizard can now import projects of any time (i.e. Dreamweaver, WRT IDE) from the filesystem
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 156
diff changeset
   338
            if (file.isFile() && file.getName().equalsIgnoreCase(CoreUtil.METADATA_FILE)) {
830136ec8316 Wizard can now import projects of any time (i.e. Dreamweaver, WRT IDE) from the filesystem
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 156
diff changeset
   339
                return file.getParentFile();
236
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   340
            }
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   341
        }
200
830136ec8316 Wizard can now import projects of any time (i.e. Dreamweaver, WRT IDE) from the filesystem
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 156
diff changeset
   342
        return null;
236
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   343
    }
200
830136ec8316 Wizard can now import projects of any time (i.e. Dreamweaver, WRT IDE) from the filesystem
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 156
diff changeset
   344
830136ec8316 Wizard can now import projects of any time (i.e. Dreamweaver, WRT IDE) from the filesystem
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 156
diff changeset
   345
    private static boolean isDefaultProjectLocation(URI uri) {
236
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   346
        if (uri == null) {
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   347
            return true;
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   348
        }
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   349
        File file = new File(uri);
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   350
        IPath project = new Path(file.getAbsolutePath());
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   351
        IPath workspace = ResourcesPlugin.getWorkspace().getRoot().getLocation();
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   352
        return workspace.isPrefixOf(project);
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   353
    }
200
830136ec8316 Wizard can now import projects of any time (i.e. Dreamweaver, WRT IDE) from the filesystem
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 156
diff changeset
   354
830136ec8316 Wizard can now import projects of any time (i.e. Dreamweaver, WRT IDE) from the filesystem
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 156
diff changeset
   355
    public static boolean isPlist(IResource resource) {
830136ec8316 Wizard can now import projects of any time (i.e. Dreamweaver, WRT IDE) from the filesystem
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 156
diff changeset
   356
        return resource.getType() == IResource.FILE && resource.getName().equalsIgnoreCase(CoreUtil.METADATA_FILE);
236
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   357
    }
200
830136ec8316 Wizard can now import projects of any time (i.e. Dreamweaver, WRT IDE) from the filesystem
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 156
diff changeset
   358
830136ec8316 Wizard can now import projects of any time (i.e. Dreamweaver, WRT IDE) from the filesystem
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 156
diff changeset
   359
    private static boolean isValidProjectFile(String fileName) {
830136ec8316 Wizard can now import projects of any time (i.e. Dreamweaver, WRT IDE) from the filesystem
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 156
diff changeset
   360
        return !EXCLUDED.contains(fileName);
830136ec8316 Wizard can now import projects of any time (i.e. Dreamweaver, WRT IDE) from the filesystem
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 156
diff changeset
   361
    }
830136ec8316 Wizard can now import projects of any time (i.e. Dreamweaver, WRT IDE) from the filesystem
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 156
diff changeset
   362
236
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   363
    public static void unzip(String archiveFile, IContainer location, int trimSegments, IProgressMonitor progressMonitor)
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   364
            throws IOException, CoreException {
309
c01f5ab28a11 Refactored to add extended support for JS Libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 308
diff changeset
   365
        unzip(new FileInputStream(archiveFile), location, trimSegments, archiveFile, progressMonitor);
c01f5ab28a11 Refactored to add extended support for JS Libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 308
diff changeset
   366
    }
c01f5ab28a11 Refactored to add extended support for JS Libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 308
diff changeset
   367
c01f5ab28a11 Refactored to add extended support for JS Libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 308
diff changeset
   368
    public static void unzip(InputStream in, IContainer location, int trimSegments, String label,
c01f5ab28a11 Refactored to add extended support for JS Libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 308
diff changeset
   369
            IProgressMonitor progressMonitor) throws IOException, CoreException {
c01f5ab28a11 Refactored to add extended support for JS Libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 308
diff changeset
   370
        progressMonitor.beginTask(MessageFormat.format("Unpacking {0}", label), IProgressMonitor.UNKNOWN);
c01f5ab28a11 Refactored to add extended support for JS Libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 308
diff changeset
   371
        ZipInputStream stream = new ZipInputStream(in);
236
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   372
        try {
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   373
            ZipEntry nextEntry;
351
e317b108976d Bug 2888 - IDE does not properly explain the reason for failure if the WGZ file is broken
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 349
diff changeset
   374
            int count = 0;
236
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   375
            while ((nextEntry = stream.getNextEntry()) != null) {
351
e317b108976d Bug 2888 - IDE does not properly explain the reason for failure if the WGZ file is broken
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 349
diff changeset
   376
                count++;
236
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   377
                IPath p = new Path(nextEntry.getName()).removeFirstSegments(trimSegments);
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   378
                if (!isIgnored(p) && !nextEntry.isDirectory()) {
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   379
                    IFile file = location.getFile(p);
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   380
                    checkParent(file.getParent());
271
4ff7e6f31c66 WGZ import issue was fixed
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 236
diff changeset
   381
                    if (file.exists()) {
4ff7e6f31c66 WGZ import issue was fixed
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 236
diff changeset
   382
                        file.setContents(new NonClosingStream(stream), false, true, new SubProgressMonitor(
4ff7e6f31c66 WGZ import issue was fixed
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 236
diff changeset
   383
                                progressMonitor, 1));
4ff7e6f31c66 WGZ import issue was fixed
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 236
diff changeset
   384
                    } else {
4ff7e6f31c66 WGZ import issue was fixed
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 236
diff changeset
   385
                        file.create(new NonClosingStream(stream), true, new SubProgressMonitor(progressMonitor, 1));
4ff7e6f31c66 WGZ import issue was fixed
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 236
diff changeset
   386
                    }
236
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   387
                }
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   388
            }
351
e317b108976d Bug 2888 - IDE does not properly explain the reason for failure if the WGZ file is broken
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 349
diff changeset
   389
            if (count == 0) {
e317b108976d Bug 2888 - IDE does not properly explain the reason for failure if the WGZ file is broken
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 349
diff changeset
   390
                throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID,
e317b108976d Bug 2888 - IDE does not properly explain the reason for failure if the WGZ file is broken
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 349
diff changeset
   391
                        "Selected archive file does not contain application files"));
e317b108976d Bug 2888 - IDE does not properly explain the reason for failure if the WGZ file is broken
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 349
diff changeset
   392
            }
236
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   393
        } finally {
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   394
            stream.close();
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   395
        }
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   396
        progressMonitor.done();
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   397
    }
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   398
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   399
    private static boolean isIgnored(IPath p) {
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   400
        if (p.segmentCount() == 1) {
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   401
            return IProjectDescription.DESCRIPTION_FILE_NAME.equals(p.lastSegment());
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   402
        }
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   403
        return false;
167f22364544 Bug 2087 - Import ->WGZ sources lets you import WGZ archive from another WRT launch configuration, but ends up creating an empty folder
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 216
diff changeset
   404
    }
200
830136ec8316 Wizard can now import projects of any time (i.e. Dreamweaver, WRT IDE) from the filesystem
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 156
diff changeset
   405
282
39bbb3a15d6f Bug 2341 - Files excluded from widget archive are not clearly marked
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 281
diff changeset
   406
    public static boolean isExcluded(IResource resource) {
468
a05c6e5cc7d9 Previewer now is TMWed (can support projects with different natures). Note: this commit does not compile. This previewer still only supports WRT libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 458
diff changeset
   407
        if (resource.getType() == IResource.PROJECT || resource.getType() == IResource.ROOT) {
a05c6e5cc7d9 Previewer now is TMWed (can support projects with different natures). Note: this commit does not compile. This previewer still only supports WRT libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 458
diff changeset
   408
            return false;
a05c6e5cc7d9 Previewer now is TMWed (can support projects with different natures). Note: this commit does not compile. This previewer still only supports WRT libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 458
diff changeset
   409
        }
308
c521df56b15d Bug 2514 - Allow the user to package applications even if there are errors
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 300
diff changeset
   410
        if (!resource.exists()) {
c521df56b15d Bug 2514 - Allow the user to package applications even if there are errors
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 300
diff changeset
   411
            return false;
c521df56b15d Bug 2514 - Allow the user to package applications even if there are errors
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 300
diff changeset
   412
        }
282
39bbb3a15d6f Bug 2341 - Files excluded from widget archive are not clearly marked
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 281
diff changeset
   413
        try {
479
518afa7c6d2f Minor refactoring to make API more clear
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 470
diff changeset
   414
            IMarker[] markers = resource.findMarkers(EXCLUDE_MARKER_ID, false, IResource.DEPTH_ZERO);
349
59ccacde8910 Bug 2277 - Project metadata is packaged into WGZ file
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 309
diff changeset
   415
            IPath path = resource.getProjectRelativePath();
468
a05c6e5cc7d9 Previewer now is TMWed (can support projects with different natures). Note: this commit does not compile. This previewer still only supports WRT libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 458
diff changeset
   416
            return markers.length != 0 || (path.segmentCount() > 1 && ".settings".equals(path.segment(0)))
a05c6e5cc7d9 Previewer now is TMWed (can support projects with different natures). Note: this commit does not compile. This previewer still only supports WRT libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 458
diff changeset
   417
                    || isExcluded(resource.getParent());
282
39bbb3a15d6f Bug 2341 - Files excluded from widget archive are not clearly marked
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 281
diff changeset
   418
        } catch (CoreException e) {
39bbb3a15d6f Bug 2341 - Files excluded from widget archive are not clearly marked
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 281
diff changeset
   419
            Activator.log(e);
39bbb3a15d6f Bug 2341 - Files excluded from widget archive are not clearly marked
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 281
diff changeset
   420
            return false;
39bbb3a15d6f Bug 2341 - Files excluded from widget archive are not clearly marked
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 281
diff changeset
   421
        }
39bbb3a15d6f Bug 2341 - Files excluded from widget archive are not clearly marked
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 281
diff changeset
   422
39bbb3a15d6f Bug 2341 - Files excluded from widget archive are not clearly marked
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 281
diff changeset
   423
    }
39bbb3a15d6f Bug 2341 - Files excluded from widget archive are not clearly marked
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 281
diff changeset
   424
39bbb3a15d6f Bug 2341 - Files excluded from widget archive are not clearly marked
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 281
diff changeset
   425
    public static void exclude(IResource resource) {
39bbb3a15d6f Bug 2341 - Files excluded from widget archive are not clearly marked
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 281
diff changeset
   426
        try {
39bbb3a15d6f Bug 2341 - Files excluded from widget archive are not clearly marked
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 281
diff changeset
   427
            resource.createMarker(EXCLUDE_MARKER_ID);
39bbb3a15d6f Bug 2341 - Files excluded from widget archive are not clearly marked
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 281
diff changeset
   428
            resource.setPersistentProperty(WRTPackagerConstants.EXCLUDE_PROPERTY, Boolean.TRUE.toString());
39bbb3a15d6f Bug 2341 - Files excluded from widget archive are not clearly marked
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 281
diff changeset
   429
        } catch (CoreException e) {
39bbb3a15d6f Bug 2341 - Files excluded from widget archive are not clearly marked
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 281
diff changeset
   430
            Activator.log(e);
39bbb3a15d6f Bug 2341 - Files excluded from widget archive are not clearly marked
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 281
diff changeset
   431
        }
39bbb3a15d6f Bug 2341 - Files excluded from widget archive are not clearly marked
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 281
diff changeset
   432
    }
39bbb3a15d6f Bug 2341 - Files excluded from widget archive are not clearly marked
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 281
diff changeset
   433
39bbb3a15d6f Bug 2341 - Files excluded from widget archive are not clearly marked
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 281
diff changeset
   434
    public static void include(IResource resource) {
39bbb3a15d6f Bug 2341 - Files excluded from widget archive are not clearly marked
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 281
diff changeset
   435
        try {
479
518afa7c6d2f Minor refactoring to make API more clear
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 470
diff changeset
   436
            IMarker[] markers = resource.findMarkers(EXCLUDE_MARKER_ID, false, IResource.DEPTH_ZERO);
282
39bbb3a15d6f Bug 2341 - Files excluded from widget archive are not clearly marked
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 281
diff changeset
   437
            resource.setPersistentProperty(WRTPackagerConstants.EXCLUDE_PROPERTY, null);
39bbb3a15d6f Bug 2341 - Files excluded from widget archive are not clearly marked
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 281
diff changeset
   438
            for (IMarker marker : markers) {
39bbb3a15d6f Bug 2341 - Files excluded from widget archive are not clearly marked
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 281
diff changeset
   439
                marker.delete();
39bbb3a15d6f Bug 2341 - Files excluded from widget archive are not clearly marked
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 281
diff changeset
   440
            }
39bbb3a15d6f Bug 2341 - Files excluded from widget archive are not clearly marked
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 281
diff changeset
   441
        } catch (CoreException e) {
39bbb3a15d6f Bug 2341 - Files excluded from widget archive are not clearly marked
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 281
diff changeset
   442
            Activator.log(e);
39bbb3a15d6f Bug 2341 - Files excluded from widget archive are not clearly marked
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 281
diff changeset
   443
        }
39bbb3a15d6f Bug 2341 - Files excluded from widget archive are not clearly marked
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 281
diff changeset
   444
    }
3
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   445
}