# HG changeset patch # User Eugene Ostroukhov # Date 1279736803 25200 # Node ID 38d6944cff88027d89cb1e53e927bf93c7a8dfad # Parent 68002774437ee09884db30cc8c48bb08c7358a45 Bug 3352 - Replace our Navigator View with the JSDT one diff -r 68002774437e -r 38d6944cff88 org.symbian.tools.mtw.ui/.classpath --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.mtw.ui/.classpath Wed Jul 21 11:26:43 2010 -0700 @@ -0,0 +1,7 @@ + + + + + + + diff -r 68002774437e -r 38d6944cff88 org.symbian.tools.mtw.ui/.project --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.mtw.ui/.project Wed Jul 21 11:26:43 2010 -0700 @@ -0,0 +1,28 @@ + + + org.symbian.tools.mtw.ui + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff -r 68002774437e -r 38d6944cff88 org.symbian.tools.mtw.ui/.settings/org.eclipse.jdt.core.prefs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.mtw.ui/.settings/org.eclipse.jdt.core.prefs Wed Jul 21 11:26:43 2010 -0700 @@ -0,0 +1,8 @@ +#Tue Jul 20 13:28:21 PDT 2010 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.5 diff -r 68002774437e -r 38d6944cff88 org.symbian.tools.mtw.ui/META-INF/MANIFEST.MF --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.mtw.ui/META-INF/MANIFEST.MF Wed Jul 21 11:26:43 2010 -0700 @@ -0,0 +1,17 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Mobile Tools for Web main UI plug-in +Bundle-SymbolicName: org.symbian.tools.mtw.ui;singleton:=true +Bundle-Version: 1.0.0.qualifier +Bundle-Activator: org.symbian.tools.mtw.ui.Activator +Bundle-Vendor: Symbian Foundation +Require-Bundle: org.eclipse.ui, + org.eclipse.core.runtime, + org.eclipse.core.resources;bundle-version="3.6.0", + org.symbian.tools.wrttools;bundle-version="1.0.0", + org.eclipse.ui.navigator;bundle-version="3.5.0", + org.eclipse.ui.navigator.resources;bundle-version="3.4.200", + org.eclipse.wst.jsdt.ui;bundle-version="1.1.0", + org.eclipse.wst.jsdt.core;bundle-version="1.1.0" +Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-ActivationPolicy: lazy diff -r 68002774437e -r 38d6944cff88 org.symbian.tools.mtw.ui/build.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.mtw.ui/build.properties Wed Jul 21 11:26:43 2010 -0700 @@ -0,0 +1,6 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + plugin.xml,\ + icons/ diff -r 68002774437e -r 38d6944cff88 org.symbian.tools.mtw.ui/plugin.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.mtw.ui/plugin.xml Wed Jul 21 11:26:43 2010 -0700 @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 68002774437e -r 38d6944cff88 org.symbian.tools.mtw.ui/src/org/symbian/tools/mtw/ui/Activator.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.mtw.ui/src/org/symbian/tools/mtw/ui/Activator.java Wed Jul 21 11:26:43 2010 -0700 @@ -0,0 +1,60 @@ +package org.symbian.tools.mtw.ui; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle + */ +public class Activator extends AbstractUIPlugin { + + // The plug-in ID + public static final String PLUGIN_ID = "org.symbian.tools.mtw.ui"; //$NON-NLS-1$ + + // The shared instance + private static Activator plugin; + + /** + * The constructor + */ + public Activator() { + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static Activator getDefault() { + return plugin; + } + + public static void log(String message, Exception e) { + getDefault().getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, message, e)); + } + + public static void log(Exception e) { + log(null, e); + } + +} diff -r 68002774437e -r 38d6944cff88 org.symbian.tools.mtw.ui/src/org/symbian/tools/mtw/ui/navigator/PackagingInformationDecorator.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.mtw.ui/src/org/symbian/tools/mtw/ui/navigator/PackagingInformationDecorator.java Wed Jul 21 11:26:43 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.mtw.ui.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 && resource.isAccessible() && 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 68002774437e -r 38d6944cff88 org.symbian.tools.mtw.ui/src/org/symbian/tools/mtw/ui/navigator/RenameMoveActionProvider.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.mtw.ui/src/org/symbian/tools/mtw/ui/navigator/RenameMoveActionProvider.java Wed Jul 21 11:26:43 2010 -0700 @@ -0,0 +1,101 @@ +/** + * 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.mtw.ui.navigator; + +import java.util.Collection; +import java.util.HashSet; + +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.action.IMenuManager; +import org.eclipse.jface.action.Separator; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.ISelectionProvider; +import org.eclipse.ui.IActionBars; +import org.eclipse.ui.IViewPart; +import org.eclipse.ui.IWorkbenchPartSite; +import org.eclipse.ui.actions.ActionContext; +import org.eclipse.ui.actions.ActionFactory; +import org.eclipse.ui.navigator.CommonActionProvider; +import org.eclipse.ui.navigator.ICommonActionExtensionSite; +import org.eclipse.ui.navigator.ICommonViewerWorkbenchSite; +import org.eclipse.wst.jsdt.ui.IContextMenuConstants; +import org.eclipse.wst.jsdt.ui.actions.IJavaEditorActionDefinitionIds; +import org.eclipse.wst.jsdt.ui.actions.JdtActionConstants; +import org.eclipse.wst.jsdt.ui.actions.MoveAction; +import org.eclipse.wst.jsdt.ui.actions.RenameAction; +import org.eclipse.wst.jsdt.ui.actions.SelectionDispatchAction; + +public class RenameMoveActionProvider extends CommonActionProvider { + private SelectionDispatchAction fMoveAction; + private SelectionDispatchAction fRenameAction; + + private final Collection fActions = new HashSet(); + + public void fillActionBars(IActionBars actionBars) { + if (fActions.size() > 0) { + actionBars.setGlobalActionHandler(JdtActionConstants.RENAME, fRenameAction); + actionBars.setGlobalActionHandler(ActionFactory.RENAME.getId(), fRenameAction); + + actionBars.setGlobalActionHandler(JdtActionConstants.MOVE, fMoveAction); + actionBars.setGlobalActionHandler(ActionFactory.MOVE.getId(), fMoveAction); + } + } + + public void fillContextMenu(IMenuManager menu) { + menu.appendToGroup(IContextMenuConstants.GROUP_REORGANIZE, new Separator()); + for (IAction action : fActions) { + menu.appendToGroup(IContextMenuConstants.GROUP_REORGANIZE, action); + } + } + + public void init(ICommonActionExtensionSite site) { + ICommonViewerWorkbenchSite workbenchSite= null; + if (site.getViewSite() instanceof ICommonViewerWorkbenchSite) { + workbenchSite= (ICommonViewerWorkbenchSite) site.getViewSite(); + } + + // we only initialize the refactor group when in a view part + // (required for the constructor) + if (workbenchSite != null) { + if (workbenchSite.getPart() != null && workbenchSite.getPart() instanceof IViewPart) { + IViewPart viewPart= (IViewPart) workbenchSite.getPart(); + IWorkbenchPartSite s = viewPart.getSite(); + + fRenameAction= new RenameAction(s); + initUpdatingAction(fRenameAction, workbenchSite.getSelectionProvider(), workbenchSite.getSelectionProvider().getSelection(), IJavaEditorActionDefinitionIds.RENAME_ELEMENT); + fMoveAction= new MoveAction(s); + initUpdatingAction(fMoveAction, workbenchSite.getSelectionProvider(), workbenchSite.getSelectionProvider().getSelection(), IJavaEditorActionDefinitionIds.RENAME_ELEMENT); + } + } + } + + private void initUpdatingAction(SelectionDispatchAction action, ISelectionProvider provider, ISelection selection, String actionDefinitionId){ + action.setActionDefinitionId(actionDefinitionId); + action.update(selection); + if (provider != null) { + provider.addSelectionChangedListener(action); + } + fActions.add(action); + } + + + public void setContext(ActionContext context) { + // Do nothing + } +} diff -r 68002774437e -r 38d6944cff88 org.symbian.tools.wrttools.previewer/plugin.xml --- a/org.symbian.tools.wrttools.previewer/plugin.xml Wed Jul 21 10:18:21 2010 -0700 +++ b/org.symbian.tools.wrttools.previewer/plugin.xml Wed Jul 21 11:26:43 2010 -0700 @@ -6,7 +6,7 @@ point="org.eclipse.ui.views"> - - + + diff -r 68002774437e -r 38d6944cff88 org.symbian.tools.wrttools.product/src/org/symbian/tools/wrttools/product/perspective/WRTPerspective.java --- a/org.symbian.tools.wrttools.product/src/org/symbian/tools/wrttools/product/perspective/WRTPerspective.java Wed Jul 21 10:18:21 2010 -0700 +++ b/org.symbian.tools.wrttools.product/src/org/symbian/tools/wrttools/product/perspective/WRTPerspective.java Wed Jul 21 11:26:43 2010 -0700 @@ -8,7 +8,6 @@ import org.eclipse.ui.console.IConsoleConstants; import org.eclipse.ui.progress.IProgressConstants; import org.eclipse.wst.jsdt.ui.JavaScriptUI; -import org.symbian.tools.wrttools.Activator; import org.symbian.tools.wrttools.previewer.PreviewerPlugin; public class WRTPerspective implements IPerspectiveFactory { @@ -17,7 +16,7 @@ String editorArea = layout.getEditorArea(); IFolderLayout folder= layout.createFolder("left", IPageLayout.LEFT, (float)0.15, editorArea); //$NON-NLS-1$ - folder.addView(Activator.NAVIGATOR_ID); + folder.addView(IPageLayout.ID_PROJECT_EXPLORER); IFolderLayout snippetsFolder = layout.createFolder("snippets", IPageLayout.BOTTOM, (float) 0.5, "left"); //$NON-NLS-1$ snippetsFolder.addView("org.eclipse.wst.common.snippets.internal.ui.SnippetsView"); @@ -42,6 +41,7 @@ // views - java layout.addShowViewShortcut(JavaScriptUI.ID_TYPE_HIERARCHY); + layout.addShowViewShortcut(IPageLayout.ID_PROJECT_EXPLORER); layout.addShowViewShortcut(JavaScriptUI.ID_SOURCE_VIEW); layout.addShowViewShortcut(JavaScriptUI.ID_JAVADOC_VIEW); layout.addShowViewShortcut("org.symbian.tools.wrttools.wrtnavigator"); diff -r 68002774437e -r 38d6944cff88 org.symbian.tools.wrttools.product/wrt-ide.product --- a/org.symbian.tools.wrttools.product/wrt-ide.product Wed Jul 21 10:18:21 2010 -0700 +++ b/org.symbian.tools.wrttools.product/wrt-ide.product Wed Jul 21 11:26:43 2010 -0700 @@ -1,298 +1,299 @@ - - - - - - - - - %productBlurb - - - - - - - - -os linux -ws gtk -arch x86 - -os macosx -ws cocoa -arch x86 - -os win32 -ws win32 -arch x86 - -Xms128m -Xmx768m -XX:MaxPermSize=192m - -XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts - - - - - - - - - - - - - - - - - org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5 - org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + %productBlurb + + + + + + + + -os linux -ws gtk -arch x86 + -os macosx -ws cocoa -arch x86 + -os win32 -ws win32 -arch x86 + -Xms128m -Xmx768m -XX:MaxPermSize=192m + -XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts + + + + + + + + + + + + + + + + + org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5 + org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 68002774437e -r 38d6944cff88 org.symbian.tools.wrttools/META-INF/MANIFEST.MF --- a/org.symbian.tools.wrttools/META-INF/MANIFEST.MF Wed Jul 21 10:18:21 2010 -0700 +++ b/org.symbian.tools.wrttools/META-INF/MANIFEST.MF Wed Jul 21 11:26:43 2010 -0700 @@ -51,6 +51,7 @@ org.eclipse.ui.internal.ide.dialogs, org.eclipse.ui.wizards.newresource Export-Package: org.symbian.tools.wrttools, + org.symbian.tools.wrttools.core, org.symbian.tools.wrttools.util, org.symbian.tools.wrttools.wizards Bundle-ClassPath: ., diff -r 68002774437e -r 38d6944cff88 org.symbian.tools.wrttools/plugin.xml --- a/org.symbian.tools.wrttools/plugin.xml Wed Jul 21 10:18:21 2010 -0700 +++ b/org.symbian.tools.wrttools/plugin.xml Wed Jul 21 11:26:43 2010 -0700 @@ -252,284 +252,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -827,8 +524,12 @@ label="Mobile Web Packaging Information" lightweight="true" location="TOP_RIGHT" - objectClass="org.eclipse.core.resources.IResource" state="true"> + + + + fActions = new HashSet(); - - public void fillActionBars(IActionBars actionBars) { - if (fActions.size() > 0) { - actionBars.setGlobalActionHandler(JdtActionConstants.RENAME, fRenameAction); - actionBars.setGlobalActionHandler(ActionFactory.RENAME.getId(), fRenameAction); - - actionBars.setGlobalActionHandler(JdtActionConstants.MOVE, fMoveAction); - actionBars.setGlobalActionHandler(ActionFactory.MOVE.getId(), fMoveAction); - } - } - - public void fillContextMenu(IMenuManager menu) { - menu.appendToGroup(IContextMenuConstants.GROUP_REORGANIZE, new Separator()); - for (IAction action : fActions) { - menu.appendToGroup(IContextMenuConstants.GROUP_REORGANIZE, action); - } - } - - public void init(ICommonActionExtensionSite site) { - ICommonViewerWorkbenchSite workbenchSite= null; - if (site.getViewSite() instanceof ICommonViewerWorkbenchSite) - workbenchSite= (ICommonViewerWorkbenchSite) site.getViewSite(); - - // we only initialize the refactor group when in a view part - // (required for the constructor) - if (workbenchSite != null) { - if (workbenchSite.getPart() != null && workbenchSite.getPart() instanceof IViewPart) { - IViewPart viewPart= (IViewPart) workbenchSite.getPart(); - IWorkbenchPartSite s = viewPart.getSite(); - - fRenameAction= new RenameAction(s); - initUpdatingAction(fRenameAction, workbenchSite.getSelectionProvider(), workbenchSite.getSelectionProvider().getSelection(), IJavaEditorActionDefinitionIds.RENAME_ELEMENT); - fMoveAction= new MoveAction(s); - initUpdatingAction(fMoveAction, workbenchSite.getSelectionProvider(), workbenchSite.getSelectionProvider().getSelection(), IJavaEditorActionDefinitionIds.RENAME_ELEMENT); - } - } - } - - private void initUpdatingAction(SelectionDispatchAction action, ISelectionProvider provider, ISelection selection, String actionDefinitionId){ - action.setActionDefinitionId(actionDefinitionId); - action.update(selection); - if (provider != null) - provider.addSelectionChangedListener(action); - fActions.add(action); - } - - - public void setContext(ActionContext context) { - // Do nothing - } -} diff -r 68002774437e -r 38d6944cff88 org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/navigator/WRTNavigatorContentProvider.java --- a/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/navigator/WRTNavigatorContentProvider.java Wed Jul 21 10:18:21 2010 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,160 +0,0 @@ -package org.symbian.tools.wrttools.navigator; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceChangeEvent; -import org.eclipse.core.resources.IResourceChangeListener; -import org.eclipse.core.resources.IResourceDelta; -import org.eclipse.core.resources.IResourceDeltaVisitor; -import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.jface.viewers.ITreeContentProvider; -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.wst.jsdt.core.IJavaScriptElement; -import org.eclipse.wst.jsdt.core.IJavaScriptProject; -import org.eclipse.wst.jsdt.core.JavaScriptCore; -import org.eclipse.wst.jsdt.core.JavaScriptModelException; -import org.eclipse.wst.jsdt.internal.ui.navigator.JavaNavigatorContentProvider; -import org.symbian.tools.wrttools.Activator; - -@SuppressWarnings("restriction") -public class WRTNavigatorContentProvider extends JavaNavigatorContentProvider - implements ITreeContentProvider { - private static final class RootResourceFinder implements - IResourceDeltaVisitor { - public IResource resource = null; - - private IResource getCommonAncestor(IResource r1, IResource r2) { - if (r1 == null) { - return r2; - } - if (r2 == null) { - return null; - } - if (r1.equals(r2)) { - return r1; - } - IPath p1 = r1.getFullPath(); - IPath p2 = r2.getFullPath(); - int l1 = p1.segmentCount(); - int l2 = p2.segmentCount(); - - if (l1 == 0 || l2 == 0) { - return null; - } - int l = Math.min(l1, l2); - do { - p1 = p1.uptoSegment(l); - p2 = p2.uptoSegment(l); - l = l - 1; - } while (l > 0 && (p1 != p2)); - IWorkspaceRoot r = r1.getWorkspace().getRoot(); - return l == 0 ? null : l == 1 ? r.getProject(p1.lastSegment()) : r - .getFolder(p1); - } - - public boolean visit(IResourceDelta delta) throws CoreException { - if ((delta.getKind() & (IResourceDelta.ADDED | IResourceDelta.REMOVED)) != 0) { - resource = getCommonAncestor(resource, delta.getResource() - .getParent()); - return false; - } - return true; - } - } - - private final IResourceChangeListener listener = new IResourceChangeListener() { - public void resourceChanged(IResourceChangeEvent event) { - IResource refresh = null; - if (event.getDelta() != null) { - RootResourceFinder visitor = new RootResourceFinder(); - try { - event.getDelta().accept(visitor); - } catch (CoreException e) { - Activator.log(e); - refreshViewer(null); - } - refresh = visitor.resource; - } - refreshViewer(refresh); - } - }; - private Viewer viewer; - - @Override - public void dispose() { - if (viewer != null) { - ResourcesPlugin.getWorkspace().removeResourceChangeListener( - listener); - } - super.dispose(); - } - - @Override - protected Object[] getFolderContent(IFolder folder) throws CoreException { - return folder.members(); - } - - @Override - protected Object[] getPackageFragmentRoots(IJavaScriptProject project) - throws JavaScriptModelException { - try { - return project.getProject().members(); - } catch (CoreException e) { - Activator.log(e); - } - return new Object[0]; - } - - @Override - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - if (this.viewer == null) { - ResourcesPlugin.getWorkspace().addResourceChangeListener(listener); - } - this.viewer = viewer; - super.inputChanged(viewer, oldInput, newInput); - } - - protected void refreshViewer(final IResource resource) { - viewer.getControl().getDisplay().asyncExec(new Runnable() { - public void run() { - if (!viewer.getControl().isDisposed()) { - ((TreeViewer) viewer).refresh(resource); - } - } - }); - } - - @Override - public Object[] getChildren(Object parentElement) { - if (parentElement instanceof IFile) { - IFile file = (IFile) parentElement; - IJavaScriptElement element = JavaScriptCore.create(file); - if (element != null) { - return super.getChildren(element); - } - } - return super.getChildren(parentElement); - } - - @Override - public Object getParent(Object element) { - Object parent = super.getParent(element); - if (parent instanceof IJavaScriptElement) { - IJavaScriptElement jsParent = (IJavaScriptElement) parent; - try { - IResource parentResource = jsParent.getCorrespondingResource(); - if (parentResource != null) { - return parentResource; - } - } catch (JavaScriptModelException e) { - Activator.log(e); - } - } - return parent; - } -} diff -r 68002774437e -r 38d6944cff88 org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/navigator/WrtNavigatorLinkHelper.java --- a/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/navigator/WrtNavigatorLinkHelper.java Wed Jul 21 10:18:21 2010 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,84 +0,0 @@ -/** - * 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.IFile; -import org.eclipse.core.resources.IResource; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorReference; -import org.eclipse.ui.IFileEditorInput; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.navigator.ILinkHelper; -import org.eclipse.wst.jsdt.core.IJavaScriptElement; -import org.symbian.tools.wrttools.Activator; - -public class WrtNavigatorLinkHelper implements ILinkHelper { - - public void activateEditor(IWorkbenchPage aPage, IStructuredSelection aSelection) { - IResource selection = filter(aSelection.toArray()); - if (selection == null) { - return; - } - IEditorReference[] references = aPage.getEditorReferences(); - for (IEditorReference editorReference : references) { - IEditorInput input; - try { - input = editorReference.getEditorInput(); - Object resource = input.getAdapter(IResource.class); - if (resource != null && selection.equals(resource)) { - IWorkbenchPart part = editorReference.getPart(true); - if (part != null) { - aPage.activate(part); - } - return; - } - } catch (PartInitException e) { - Activator.log(e); - } - } - } - - private IResource filter(Object[] array) { - IResource selection = null; - for (Object object : array) { - IResource resource = null; - if (object instanceof IResource) { - resource = (IResource) object; - } else if (object instanceof IJavaScriptElement) { - resource = ((IJavaScriptElement) object).getResource(); - } - if (selection == null) { - selection = resource; - } else if (!selection.equals(resource)) { - return null; - } - } - return selection; - } - - public IStructuredSelection findSelection(IEditorInput anInput) { - final IFileEditorInput input = (IFileEditorInput) anInput.getAdapter(IFileEditorInput.class); - IFile file = input.getFile(); - return new StructuredSelection(file); - } -} diff -r 68002774437e -r 38d6944cff88 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 Wed Jul 21 10:18:21 2010 -0700 +++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/util/ProjectUtils.java Wed Jul 21 11:26:43 2010 -0700 @@ -66,6 +66,7 @@ import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IPageLayout; import org.eclipse.ui.IViewReference; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchPart; @@ -124,7 +125,7 @@ public void run() { IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow() .getActivePage(); - IViewReference reference = activePage.findViewReference(Activator.NAVIGATOR_ID); + IViewReference reference = activePage.findViewReference(IPageLayout.ID_PROJECT_EXPLORER); IWorkbenchPart part = reference.getPart(false); if (part instanceof ISetSelectionTarget) { StructuredSelection selection;