# HG changeset patch # User Eugene Ostroukhov # Date 1269039105 25200 # Node ID c4e6bebd078c2f42d760323bf3a2cdc052123da6 # Parent 2c8fd0932460c0aedb61ad7850c618dc1fffeffe Bug 2306 - Synchronize Package and Deployment Options Bug 2305 - Right click on .js file and select Package - nothing happens diff -r 2c8fd0932460 -r c4e6bebd078c org.symbian.tools.wrttools/plugin.xml --- a/org.symbian.tools.wrttools/plugin.xml Fri Mar 19 11:59:35 2010 -0700 +++ b/org.symbian.tools.wrttools/plugin.xml Fri Mar 19 15:51:45 2010 -0700 @@ -64,22 +64,6 @@ --> - - - - - @@ -665,10 +649,16 @@ + + @@ -679,12 +669,85 @@ + id="org.symbian.tools.wrttools.toolbars.deploy"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -692,6 +755,25 @@ class="org.symbian.tools.wrttools.handlers.DeployHandler" commandId="org.symbian.tools.wrttools.commands.deploy"> + + + + + + + + + + + + + @@ -725,7 +807,6 @@ - - + diff -r 2c8fd0932460 -r c4e6bebd078c 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 Fri Mar 19 11:59:35 2010 -0700 +++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/handlers/DeployHandler.java Fri Mar 19 15:51:45 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 2c8fd0932460 -r c4e6bebd078c 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 Fri Mar 19 11:59:35 2010 -0700 +++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/util/ProjectUtils.java Fri Mar 19 15:51:45 2010 -0700 @@ -34,6 +34,7 @@ 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; @@ -46,6 +47,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 +56,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; @@ -359,4 +365,27 @@ 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; + } + }