Merged heads
authorEugene Ostroukhov <eugeneo@symbian.org>
Fri, 26 Mar 2010 10:25:30 -0700
changeset 284 5a06888861c3
parent 283 c035b31473c1 (diff)
parent 280 7f932d481521 (current diff)
child 285 bf9d8e184dd0
Merged heads
Binary file org.symbian.tools.wrttools/icons/excluded.gif has changed
--- a/org.symbian.tools.wrttools/plugin.xml	Thu Mar 25 16:12:09 2010 -0700
+++ b/org.symbian.tools.wrttools/plugin.xml	Fri Mar 26 10:25:30 2010 -0700
@@ -26,13 +26,6 @@
         
 <!-- Validator Marker -->
    
-        <extension
-           id="org.symbian.tools.wrttools.core.validator.marker"
-           name="Validator Marker"
-           point="org.eclipse.core.resources.markers">
-                 <super type="org.eclipse.core.resources.problemmarker"/>
-                 <persistent value ="true"/>
-        </extension>
         
 <!-- Web Runtime Preferences --> 
  <extension
@@ -64,22 +57,6 @@
 -->                
     
       
-	  <objectContribution
-           objectClass="org.eclipse.core.resources.IResource" 
-		   adaptable="true"         
-           id="org.symbian.tools.wrttools.widget.wrttool">
-	 	   <filter
-	     	name="projectNature"
-	     	value="org.symbian.tools.wrttools.WidgetProjectNature"/>
-	       <action
-	             class="org.symbian.tools.wrttools.core.packager.WrtPackageActionDelegate"
-	             enablesFor="+"
-	             icon="icons/package_widget.gif"
-	             id="org.symbian.tools.wrttools.widget.package.WrtPackageActionDelegate"
-	             label="Package WRT Application"
-	             menubarPath="org.symbian.tools.wrttools.contextMenuGroupMarker">
-	       </action>
-      </objectContribution> 
       <objectContribution
             objectClass="org.eclipse.core.resources.IResource"            
             id="org.symbian.tools.wrttools.widget.wrttool.packageoptions">
@@ -665,10 +642,16 @@
     </category>
     <command
           categoryId="org.symbian.tools.wrttools.commands.maincategory"
-          description="Deploys application to phone or emulator"
+          description="Deploys an application to phone or emulator"
           id="org.symbian.tools.wrttools.commands.deploy"
           name="Deploy Application">
     </command>
+    <command
+          categoryId="org.symbian.tools.wrttools.commands.maincategory"
+          description="Packages an application for distribution or deployment"
+          id="org.symbian.tools.wrttools.commands.package"
+          name="Package Application">
+    </command>
  </extension>
  <extension
        point="org.eclipse.ui.menus">
@@ -679,12 +662,85 @@
           <command
                 commandId="org.symbian.tools.wrttools.commands.deploy"
                 icon="icons/deploy_widget.gif"
-                id="org.symbian.tools.wrttools.toolbars.deploy"
-                label="Deploy"
-                tooltip="Deploy application">
+                id="org.symbian.tools.wrttools.toolbars.deploy">
+          </command>
+          <command
+                commandId="org.symbian.tools.wrttools.commands.package"
+                icon="icons/package_widget.gif"
+                id="org.symbian.tools.wrttools.toolbars.package">
           </command>
        </toolbar>
     </menuContribution>
+    <menuContribution
+          locationURI="menu:project?after=additions">
+       <separator
+             name="org.symbian.tools.wrttools.beginwert"
+             visible="true">
+       </separator>
+       <command
+             commandId="org.symbian.tools.wrttools.commands.deploy"
+             icon="icons/deploy_widget.gif"
+             id="org.symbian.tools.wrttools.toolbars.deploy">
+       </command>
+       <command
+             commandId="org.symbian.tools.wrttools.commands.package"
+             icon="icons/package_widget.gif"
+             id="org.symbian.tools.wrttools.toolbars.package">
+       </command>
+       <separator
+             name="org.symbian.tools.wrttools.endwrt"
+             visible="true">
+       </separator>
+    </menuContribution>
+    <menuContribution
+          locationURI="popup:org.eclipse.ui.popup.any?after=sourceMenuId">
+       <separator
+             name="org.symbian.tools.wrttools.beginwert"
+             visible="true">
+       </separator>
+       <command
+             commandId="org.symbian.tools.wrttools.commands.deploy"
+             icon="icons/deploy_widget.gif"
+             id="org.symbian.tools.wrttools.toolbars.deploy">
+          <visibleWhen>
+             <and>
+                <iterate
+                      ifEmpty="false"
+                      operator="and">
+                   <adapt
+                         type="org.eclipse.core.resources.IProject">
+                   </adapt>
+                </iterate>
+                <count
+                      value="1">
+                </count>
+             </and>
+          </visibleWhen>
+       </command>
+       <command
+             commandId="org.symbian.tools.wrttools.commands.package"
+             icon="icons/package_widget.gif"
+             id="org.symbian.tools.wrttools.toolbars.package">
+          <visibleWhen>
+             <and>
+                <iterate
+                      ifEmpty="false"
+                      operator="and">
+                   <adapt
+                         type="org.eclipse.core.resources.IProject">
+                   </adapt>
+                </iterate>
+                <count
+                      value="1">
+                </count>
+             </and>
+          </visibleWhen>
+       </command>
+       <separator
+             name="org.symbian.tools.wrttools.endwrt"
+             visible="true">
+       </separator>
+    </menuContribution>
  </extension>
  <extension
        point="org.eclipse.ui.handlers">
@@ -692,6 +748,25 @@
           class="org.symbian.tools.wrttools.handlers.DeployHandler"
           commandId="org.symbian.tools.wrttools.commands.deploy">
        <enabledWhen>
+          <reference
+                definitionId="org.symbian.tools.wrttools.symbianproject">
+          </reference>
+       </enabledWhen>
+    </handler>
+    <handler
+          class="org.symbian.tools.wrttools.handlers.PackageApplicationHandler"
+          commandId="org.symbian.tools.wrttools.commands.package">
+       <enabledWhen>
+          <reference
+                definitionId="org.symbian.tools.wrttools.symbianproject">
+          </reference>
+       </enabledWhen>
+    </handler>
+ </extension>
+ <extension
+       point="org.eclipse.core.expressions.definitions">
+    <definition
+          id="org.symbian.tools.wrttools.symbianproject">
           <or>
              <with
                    variable="selection">
@@ -725,7 +800,28 @@
                 </with>
              </and>
           </or>
-       </enabledWhen>
-    </handler>
+    </definition>
+ </extension>
+ <extension
+       point="org.eclipse.ui.decorators">
+    <decorator
+          adaptable="true"
+          class="org.symbian.tools.wrttools.navigator.PackagingInformationDecorator"
+          icon="icons/main16.gif"
+          id="org.symbian.tools.wrttools.packagingDeclarator"
+          label="WebRuntime Packaging Information"
+          lightweight="true"
+          location="TOP_RIGHT"
+          objectClass="org.eclipse.core.resources.IResource"
+          state="true">
+    </decorator>
+ </extension>
+ <extension
+       id="org.symbian.tools.wrttools.excluded"
+       name="Excluded from WRT packaging marker"
+       point="org.eclipse.core.resources.markers">
+    <persistent
+          value="true">
+    </persistent>
  </extension>
 </plugin>
--- a/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/WRTImages.java	Thu Mar 25 16:12:09 2010 -0700
+++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/WRTImages.java	Fri Mar 26 10:25:30 2010 -0700
@@ -29,6 +29,7 @@
     private static final String IMAGE_NEW_WIZARD_BANNER = "WRT_wizard_banner.png";
     private static final String IMAGE_EMULATOR = "deploy_widget.gif";
     private static final String IMAGE_BLUETOOTH = "bluetooth.gif";
+    private static final String IMAGE_EXCLUDED = "excluded.gif";
 
     public static void init(ImageRegistry reg) {
         add(reg, IMAGE_IMPORT_WIZARD_BANNER);
@@ -36,6 +37,7 @@
         add(reg, IMAGE_NEW_WIZARD_BANNER);
         add(reg, IMAGE_EMULATOR);
         add(reg, IMAGE_BLUETOOTH);
+        add(reg, IMAGE_EXCLUDED);
     }
 
     private static void add(ImageRegistry reg, String key) {
@@ -62,4 +64,12 @@
         return Activator.getDefault().getImageRegistry().get(IMAGE_BLUETOOTH);
     }
 
+    public static Image getExcludedImage() {
+        return Activator.getDefault().getImageRegistry().get(IMAGE_EXCLUDED);
+    }
+
+    public static ImageDescriptor getExcludedImageDescriptor() {
+        return Activator.getDefault().getImageRegistry().getDescriptor(IMAGE_EXCLUDED);
+    }
+
 }
--- a/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/packager/ExcludeFileAction.java	Thu Mar 25 16:12:09 2010 -0700
+++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/packager/ExcludeFileAction.java	Fri Mar 26 10:25:30 2010 -0700
@@ -35,13 +35,13 @@
 import org.eclipse.ui.IObjectActionDelegate;
 import org.eclipse.ui.IWorkbenchPart;
 import org.eclipse.ui.PlatformUI;
-
 import org.symbian.tools.wrttools.Activator;
+import org.symbian.tools.wrttools.util.ProjectUtils;
 
 public class ExcludeFileAction implements IObjectActionDelegate {
 	
-	private List<IFile> selectedFiles = new ArrayList<IFile>();
-	private List<IFolder> selectedFolders = new ArrayList<IFolder>();
+	private final List<IFile> selectedFiles = new ArrayList<IFile>();
+	private final List<IFolder> selectedFolders = new ArrayList<IFolder>();
 	public ExcludeFileAction() {
 		super();
 	}
@@ -51,16 +51,12 @@
 
 	public void run(IAction action) {
 		for (IFile file : selectedFiles) {
-			try {
-				file.setPersistentProperty(WRTPackagerConstants.EXCLUDE_PROPERTY, Boolean.TRUE.toString());
-			} catch (CoreException x) {
-				Activator.log(IStatus.ERROR, "error setting exclude property on file: "+file.getName(), x);
-			}
+            ProjectUtils.exclude(file);
 		}
 		
 		for(IFolder folder : selectedFolders){
 			try{
-				folder.setPersistentProperty(WRTPackagerConstants.EXCLUDE_PROPERTY, Boolean.TRUE.toString());
+                ProjectUtils.exclude(folder);
 				excludeFolder( folder);
 			}
 			catch (CoreException x) {
@@ -71,7 +67,8 @@
 		PlatformUI.getWorkbench().getDecoratorManager().update("org.symbian.tools.wrttools.decorator"); 
 	}
 	
-	public void selectionChanged(IAction action, ISelection selection) {
+    @SuppressWarnings("unchecked")
+    public void selectionChanged(IAction action, ISelection selection) {
 		selectedFiles.clear();
 		selectedFolders.clear();
 		if (selection instanceof IStructuredSelection) {
@@ -105,11 +102,11 @@
 			public boolean visit(IResource resource)throws CoreException {
 				if (resource instanceof IFile) {
 					IFile file = (IFile) resource;
-					file.setPersistentProperty(WRTPackagerConstants.EXCLUDE_PROPERTY, Boolean.TRUE.toString());
+                    ProjectUtils.exclude(file);
 				}
 				else if (resource instanceof IFolder) {
 					IFolder folder = (IFolder) resource;
-					folder.setPersistentProperty(WRTPackagerConstants.EXCLUDE_PROPERTY, Boolean.TRUE.toString());	
+                    ProjectUtils.exclude(folder);
 				}
 				return true;
 			}
--- a/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/packager/IncludeFileAction.java	Thu Mar 25 16:12:09 2010 -0700
+++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/packager/IncludeFileAction.java	Fri Mar 26 10:25:30 2010 -0700
@@ -36,13 +36,13 @@
 import org.eclipse.ui.IObjectActionDelegate;
 import org.eclipse.ui.IWorkbenchPart;
 import org.eclipse.ui.PlatformUI;
-
 import org.symbian.tools.wrttools.Activator;
+import org.symbian.tools.wrttools.util.ProjectUtils;
 
 public class IncludeFileAction implements IObjectActionDelegate {
 	
-	private List<IFile> selectedFiles = new ArrayList<IFile>();
-	private List<IFolder> selectedFolders = new ArrayList<IFolder>();
+	private final List<IFile> selectedFiles = new ArrayList<IFile>();
+	private final List<IFolder> selectedFolders = new ArrayList<IFolder>();
 
 
 	public IncludeFileAction() {
@@ -54,16 +54,12 @@
 
 	public void run(IAction action) {
 		for (IFile file : selectedFiles) {			
-			try {
-				file.setPersistentProperty(WRTPackagerConstants.EXCLUDE_PROPERTY, null);
-			} catch (CoreException x) {
-				Activator.log(IStatus.ERROR, "error setting exclude property on file: "+file.getName(), x);
-			}
+            ProjectUtils.include(file);
 		}
 		
 		for(IFolder folder : selectedFolders){
 			try{
-				folder.setPersistentProperty(WRTPackagerConstants.EXCLUDE_PROPERTY, null);
+                ProjectUtils.include(folder);
 				includeFolder( folder);				
 			}
 			catch (CoreException x) {
@@ -77,7 +73,8 @@
 	/**
 	 * @see IActionDelegate#selectionChanged(IAction, ISelection)
 	 */
-	public void selectionChanged(IAction action, ISelection selection) {
+    @SuppressWarnings("unchecked")
+    public void selectionChanged(IAction action, ISelection selection) {
 		selectedFiles.clear();
 		selectedFolders.clear();
 		if (selection instanceof IStructuredSelection) {
@@ -108,11 +105,11 @@
 			public boolean visit(IResource resource)	throws CoreException {
 				if (resource instanceof IFile) {
 					IFile file = (IFile) resource;
-					file.setPersistentProperty(WRTPackagerConstants.EXCLUDE_PROPERTY, null);		
+                    ProjectUtils.include(file);
 				}
 				else if (resource instanceof IFolder) {
 					IFolder folder = (IFolder) resource;
-					folder.setPersistentProperty(WRTPackagerConstants.EXCLUDE_PROPERTY, null);		
+                    ProjectUtils.include(folder);
 				}
 				return true;
 			}
--- a/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/packager/WrtPackageActionDelegate.java	Thu Mar 25 16:12:09 2010 -0700
+++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/packager/WrtPackageActionDelegate.java	Fri Mar 26 10:25:30 2010 -0700
@@ -47,6 +47,7 @@
 import org.symbian.tools.wrttools.core.status.IWRTConstants;
 import org.symbian.tools.wrttools.core.status.IWRTStatusListener;
 import org.symbian.tools.wrttools.core.status.WRTStatus;
+import org.symbian.tools.wrttools.util.ProjectUtils;
 
 public class WrtPackageActionDelegate extends ActionDelegate implements
 		IObjectActionDelegate {
@@ -105,8 +106,8 @@
 							IFile file = (IFile) resource;
 							boolean add = true;
 							// skip user-excluded and automatically-excluded files
-							String value = file.getPersistentProperty(WRTPackagerConstants.EXCLUDE_PROPERTY);
-							if (value != null) {
+                            boolean value = ProjectUtils.isExcluded(file);
+                            if (value) {
 								add = false;
 							}
 							String name = file.getName();
@@ -134,6 +135,7 @@
 						}		
 						return true;
 					}
+
 				});
 				//<<--<<
 
@@ -156,7 +158,7 @@
 					project.refreshLocal(IResource.DEPTH_ONE, pm);
 					wgz = project.getFile(wgzPath);
 					if (wgz.exists()) {
-						wgz.setPersistentProperty(WRTPackagerConstants.EXCLUDE_PROPERTY, Boolean.TRUE.toString());
+                        ProjectUtils.exclude(wgz);
 					}
 					
 				} catch (PackageException e) {
@@ -171,10 +173,11 @@
 		}	
 		return packaedSucess;
 	}
-	/**
-	 * Reporting status
-	 * @param statusMessage
-	 */
+
+    /**
+     * Reporting status
+     * @param statusMessage
+     */
 	private void reportStatus(String statusMessage) {
 		WRTStatus status = new WRTStatus();
 		WRTStatusListener statusListener = new WRTStatusListener();
--- a/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/handlers/DeployHandler.java	Thu Mar 25 16:12:09 2010 -0700
+++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/handlers/DeployHandler.java	Fri Mar 26 10:25:30 2010 -0700
@@ -1,18 +1,32 @@
+/**
+ * Copyright (c) 2010 Symbian Foundation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Symbian Foundation - initial contribution.
+ * Contributors:
+ * Description:
+ * Overview:
+ * Details:
+ * Platforms/Drives/Compatibility:
+ * Assumptions/Requirement/Pre-requisites:
+ * Failures and causes:
+ */
 package org.symbian.tools.wrttools.handlers;
 
 import org.eclipse.core.commands.AbstractHandler;
 import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.core.resources.IProject;
 import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchPart;
 import org.eclipse.ui.IWorkbenchWindow;
 import org.eclipse.ui.handlers.HandlerUtil;
 import org.symbian.tools.wrttools.WRTProject;
+import org.symbian.tools.wrttools.util.ProjectUtils;
 import org.symbian.tools.wrttools.wizards.deploy.DeployWizard;
 
 /**
@@ -34,24 +48,10 @@
     public Object execute(ExecutionEvent event) throws ExecutionException {
         IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
 
-        IResource resource = null;
-
-        IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
-        if (activePart instanceof IEditorPart) {
-            resource = (IResource) ((IEditorPart) activePart).getEditorInput().getAdapter(IResource.class);
-        } else {
-            ISelection selection = HandlerUtil.getCurrentSelection(event);
-            if (!selection.isEmpty() && selection instanceof IStructuredSelection) {
-                Object[] array = ((IStructuredSelection) selection).toArray();
-                if (array.length == 1 && array[0] instanceof IAdaptable) {
-                    resource = (IResource) ((IAdaptable) array[0]).getAdapter(IResource.class);
-                }
-            }
-        }
-        if (resource != null) {
+        IProject project = ProjectUtils.getProjectFromCommandContext(event);
+        if (project != null) {
             window.getActivePage().saveAllEditors(true);
-            WizardDialog dialog = new WizardDialog(window.getShell(), new DeployWizard(new WRTProject(resource
-                    .getProject())));
+            WizardDialog dialog = new WizardDialog(window.getShell(), new DeployWizard(new WRTProject(project)));
             dialog.open();
         }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/handlers/PackageApplicationHandler.java	Fri Mar 26 10:25:30 2010 -0700
@@ -0,0 +1,46 @@
+/**
+ * Copyright (c) 2010 Symbian Foundation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Symbian Foundation - initial contribution.
+ * Contributors:
+ * Description:
+ * Overview:
+ * Details:
+ * Platforms/Drives/Compatibility:
+ * Assumptions/Requirement/Pre-requisites:
+ * Failures and causes:
+ */
+package org.symbian.tools.wrttools.handlers;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.IHandler;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.ui.PlatformUI;
+import org.symbian.tools.wrttools.WRTStatusListener;
+import org.symbian.tools.wrttools.core.packager.WrtPackageActionDelegate;
+import org.symbian.tools.wrttools.util.ProjectUtils;
+
+public class PackageApplicationHandler extends AbstractHandler implements IHandler {
+
+    public Object execute(ExecutionEvent event) throws ExecutionException {
+        IProject project = ProjectUtils.getProjectFromCommandContext(event);
+
+        if (project != null) {
+            PlatformUI.getWorkbench().saveAllEditors(true);
+            if (project != null) {
+                WRTStatusListener statusListener = new WRTStatusListener();
+                new WrtPackageActionDelegate().packageProject(project, statusListener);
+            }
+        }
+        return null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/navigator/PackagingInformationDecorator.java	Fri Mar 26 10:25:30 2010 -0700
@@ -0,0 +1,63 @@
+/**
+ * Copyright (c) 2010 Symbian Foundation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Symbian Foundation - initial contribution.
+ * Contributors:
+ * Description:
+ * Overview:
+ * Details:
+ * Platforms/Drives/Compatibility:
+ * Assumptions/Requirement/Pre-requisites:
+ * Failures and causes:
+ */
+package org.symbian.tools.wrttools.navigator;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.viewers.IDecoration;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.ILightweightLabelDecorator;
+import org.symbian.tools.wrttools.core.WRTImages;
+import org.symbian.tools.wrttools.util.ProjectUtils;
+
+public class PackagingInformationDecorator implements ILightweightLabelDecorator {
+
+    public void decorate(Object element, IDecoration decoration) {
+        IResource resource = null;
+        if (element instanceof IResource) {
+            resource = (IResource) element;
+        } else if (element instanceof IAdaptable) {
+            resource = (IResource) ((IAdaptable) element).getAdapter(IResource.class);
+        }
+        if (resource != null && ProjectUtils.isExcluded(resource)) {
+            decoration.addOverlay(WRTImages.getExcludedImageDescriptor(), IDecoration.TOP_RIGHT);
+        }
+    }
+
+    public void addListener(ILabelProviderListener listener) {
+        // Do nothing
+
+    }
+
+    public void dispose() {
+        // Do nothing
+
+    }
+
+    public boolean isLabelProperty(Object element, String property) {
+        // Do nothing
+        return false;
+    }
+
+    public void removeListener(ILabelProviderListener listener) {
+        // Do nohing
+
+    }
+
+}
--- a/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/util/ProjectUtils.java	Thu Mar 25 16:12:09 2010 -0700
+++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/util/ProjectUtils.java	Fri Mar 26 10:25:30 2010 -0700
@@ -34,10 +34,12 @@
 
 import javax.swing.filechooser.FileSystemView;
 
+import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.resources.ICommand;
 import org.eclipse.core.resources.IContainer;
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IMarker;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.IProjectDescription;
 import org.eclipse.core.resources.IResource;
@@ -46,6 +48,7 @@
 import org.eclipse.core.resources.IWorkspaceRunnable;
 import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
@@ -54,12 +57,16 @@
 import org.eclipse.core.runtime.Status;
 import org.eclipse.core.runtime.SubProgressMonitor;
 import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.jface.viewers.StructuredSelection;
 import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IEditorPart;
 import org.eclipse.ui.IViewReference;
 import org.eclipse.ui.IWorkbenchPage;
 import org.eclipse.ui.IWorkbenchPart;
 import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.handlers.HandlerUtil;
 import org.eclipse.ui.ide.IDE;
 import org.eclipse.ui.internal.wizards.datatransfer.TarEntry;
 import org.eclipse.ui.part.ISetSelectionTarget;
@@ -72,10 +79,13 @@
 import org.eclipse.wst.validation.ValidationFramework;
 import org.symbian.tools.wrttools.Activator;
 import org.symbian.tools.wrttools.WidgetProjectNature;
+import org.symbian.tools.wrttools.core.packager.WRTPackagerConstants;
 import org.symbian.tools.wrttools.wizards.WrtLibraryWizardPage;
 
 @SuppressWarnings("restriction")
 public class ProjectUtils {
+    private static final String EXCLUDE_MARKER_ID = "org.symbian.tools.wrttools.excluded";
+
     private static final class FocusOnProjectJob extends Job {
 
         private final Display display;
@@ -258,10 +268,40 @@
 
         addWrtNature(project);
 
+        excludeResources(project);
+
         monitor.done();
         return project;
     }
 
+    private static void excludeResources(IProject project) {
+        IFile file = project.getFile(IProjectDescription.DESCRIPTION_FILE_NAME);
+        if (file.exists()) {
+            exclude(file);
+        }
+        IFolder settings = project.getFolder(".settings");
+        if (settings.exists()) {
+            excludeFolder(settings);
+            exclude(settings);
+        }
+    }
+
+    private static void excludeFolder(IFolder folder) {
+        exclude(folder);
+        try {
+            IResource[] members = folder.members();
+            for (IResource resource : members) {
+                if (resource.getType() == IResource.FOLDER) {
+                    excludeFolder((IFolder) resource);
+                } else {
+                    exclude(resource);
+                }
+            }
+        } catch (CoreException e) {
+            Activator.log(e);
+        }
+    }
+
     public static List<Object> filterExternalProjectEntries(List<Object> fileSystemObjects) {
         List<Object> result = new LinkedList<Object>();
         for (Object object : fileSystemObjects) {
@@ -359,4 +399,61 @@
         return false;
     }
 
+    public static IProject getProjectFromCommandContext(ExecutionEvent event) {
+        IResource resource = null;
+        IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
+        if (activePart instanceof IEditorPart) {
+            resource = (IResource) ((IEditorPart) activePart).getEditorInput().getAdapter(IResource.class);
+        } else {
+            ISelection selection = HandlerUtil.getCurrentSelection(event);
+            if (!selection.isEmpty() && selection instanceof IStructuredSelection) {
+                Object[] array = ((IStructuredSelection) selection).toArray();
+                if (array.length == 1 && array[0] instanceof IAdaptable) {
+                    resource = (IResource) ((IAdaptable) array[0]).getAdapter(IResource.class);
+                }
+            }
+        }
+        if (resource != null) {
+            IProject project = resource.getProject();
+            if (hasWrtNature(project)) {
+                return project;
+            }
+        }
+        return null;
+    }
+
+    public static boolean isExcluded(IResource resource) {
+        try {
+            IMarker[] markers = resource
+                    .findMarkers(EXCLUDE_MARKER_ID, false, IResource.DEPTH_ZERO);
+            return markers.length != 0;
+        } catch (CoreException e) {
+            Activator.log(e);
+            return false;
+        }
+
+    }
+
+    public static void exclude(IResource resource) {
+        try {
+            resource.createMarker(EXCLUDE_MARKER_ID);
+            resource.setPersistentProperty(WRTPackagerConstants.EXCLUDE_PROPERTY, Boolean.TRUE.toString());
+        } catch (CoreException e) {
+            Activator.log(e);
+        }
+    }
+
+    public static void include(IResource resource) {
+        try {
+            IMarker[] markers = resource
+                    .findMarkers(EXCLUDE_MARKER_ID, false, IResource.DEPTH_ZERO);
+            resource.setPersistentProperty(WRTPackagerConstants.EXCLUDE_PROPERTY, null);
+            for (IMarker marker : markers) {
+                marker.delete();
+            }
+        } catch (CoreException e) {
+            Activator.log(e);
+        }
+    }
+
 }