# HG changeset patch # User Eugene Ostroukhov # Date 1269624330 25200 # Node ID 5a06888861c3028e6cb4f6edaba069a28fa94ca3 # Parent c035b31473c1682682f7f391f68d39157ac18999# Parent 7f932d48152115d8e0dae1f8e97c1a20f465e7dd Merged heads diff -r 7f932d481521 -r 5a06888861c3 org.symbian.tools.wrttools/icons/excluded.gif Binary file org.symbian.tools.wrttools/icons/excluded.gif has changed diff -r 7f932d481521 -r 5a06888861c3 org.symbian.tools.wrttools/plugin.xml --- 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 @@ - - - - - - - - - @@ -665,10 +642,16 @@ + + @@ -679,12 +662,85 @@ + id="org.symbian.tools.wrttools.toolbars.deploy"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -692,6 +748,25 @@ class="org.symbian.tools.wrttools.handlers.DeployHandler" commandId="org.symbian.tools.wrttools.commands.deploy"> + + + + + + + + + + + + + @@ -725,7 +800,28 @@ - - + + + + + + + + + diff -r 7f932d481521 -r 5a06888861c3 org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/WRTImages.java --- 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); + } + } diff -r 7f932d481521 -r 5a06888861c3 org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/packager/ExcludeFileAction.java --- 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 selectedFiles = new ArrayList(); - private List selectedFolders = new ArrayList(); + private final List selectedFiles = new ArrayList(); + private final List selectedFolders = new ArrayList(); 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; } diff -r 7f932d481521 -r 5a06888861c3 org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/packager/IncludeFileAction.java --- 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 selectedFiles = new ArrayList(); - private List selectedFolders = new ArrayList(); + private final List selectedFiles = new ArrayList(); + private final List selectedFolders = new ArrayList(); 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; } diff -r 7f932d481521 -r 5a06888861c3 org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/packager/WrtPackageActionDelegate.java --- 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(); diff -r 7f932d481521 -r 5a06888861c3 org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/handlers/DeployHandler.java --- 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(); } diff -r 7f932d481521 -r 5a06888861c3 org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/handlers/PackageApplicationHandler.java --- /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; + } + +} diff -r 7f932d481521 -r 5a06888861c3 org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/navigator/PackagingInformationDecorator.java --- /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 + + } + +} diff -r 7f932d481521 -r 5a06888861c3 org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/util/ProjectUtils.java --- 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 filterExternalProjectEntries(List fileSystemObjects) { List result = new LinkedList(); 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); + } + } + }