### Eclipse Workspace Patch 1.0 #P org.eclipse.releng.tools Index: src/org/eclipse/releng/tools/CVSTagHelper.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.releng.tools/src/org/eclipse/releng/tools/CVSTagHelper.java,v retrieving revision 1.1 diff -u -r1.1 CVSTagHelper.java --- src/org/eclipse/releng/tools/CVSTagHelper.java 2 Nov 2007 20:34:06 -0000 1.1 +++ src/org/eclipse/releng/tools/CVSTagHelper.java 9 Jun 2010 12:35:51 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. + * Copyright (c) 2007, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -11,13 +11,17 @@ package org.eclipse.releng.tools; import java.util.ArrayList; + +import org.eclipse.releng.tools.preferences.MapProjectPreferencePage; +import org.eclipse.team.internal.ccvs.core.CVSTag; + +import org.eclipse.core.runtime.CoreException; + import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; + import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.releng.tools.preferences.MapProjectPreferencePage; -import org.eclipse.team.internal.ccvs.core.CVSTag; /** * This is a helper class used for obtaining CVSTags and checking for projects that have no corresponding @@ -60,13 +64,19 @@ * @throws CVSException */ private CVSTag getTag(IResource resource) { - MapProject selectedMapProject = getSelectedMapProject(); - if (selectedMapProject == null) - return CVSTag.DEFAULT; - MapEntry entry = selectedMapProject.getMapEntry(resource.getProject()); - if (entry == null) - return CVSTag.DEFAULT; - return entry.getTag(); + MapProject selectedMapProject= null; + try { + selectedMapProject= getSelectedMapProject(); + if (selectedMapProject == null) + return CVSTag.DEFAULT; + MapEntry entry = selectedMapProject.getMapEntry(resource.getProject()); + if (entry == null) + return CVSTag.DEFAULT; + return entry.getTag(); + } finally { + if (selectedMapProject != null) + selectedMapProject.dispose(); + } } //returns the MapProject that was selected by the user in the MapProjectSelectionWizard Index: src/org/eclipse/releng/tools/CompareLocalToMap.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.releng.tools/src/org/eclipse/releng/tools/CompareLocalToMap.java,v retrieving revision 1.14 diff -u -r1.14 CompareLocalToMap.java --- src/org/eclipse/releng/tools/CompareLocalToMap.java 2 Nov 2007 20:34:06 -0000 1.14 +++ src/org/eclipse/releng/tools/CompareLocalToMap.java 9 Jun 2010 12:35:51 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -11,18 +11,29 @@ package org.eclipse.releng.tools; import java.lang.reflect.InvocationTargetException; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.preference.IPreferenceStore; + import org.eclipse.releng.tools.preferences.MapProjectPreferencePage; -import org.eclipse.team.internal.ccvs.core.*; +import org.eclipse.team.internal.ccvs.core.CVSCompareSubscriber; +import org.eclipse.team.internal.ccvs.core.CVSException; +import org.eclipse.team.internal.ccvs.core.CVSTag; import org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction; import org.eclipse.team.internal.ccvs.ui.subscriber.CompareParticipant; import org.eclipse.team.ui.TeamUI; import org.eclipse.team.ui.synchronize.ISynchronizeParticipant; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.OperationCanceledException; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IResourceProxy; +import org.eclipse.core.resources.IResourceProxyVisitor; +import org.eclipse.core.resources.ResourcesPlugin; + +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.preference.IPreferenceStore; + + /** * This class compares the locally selected projects againsts the versions * found in the releng map files. The releng map files are searched for in the @@ -30,6 +41,7 @@ */ public class CompareLocalToMap extends WorkspaceAction { + /** * Returns true if the super would enable the option *and* * only projects are selected. There is no concept of "releasing" @@ -41,17 +53,46 @@ if (!super.isEnabled()) return false; - //if any of the projects in the current workspace contain valid map files, return true - IProject[] workspaceProjects = RelEngPlugin.getWorkspace().getRoot().getProjects(); - for (int i=0; i 0) { - mapFiles = (MapFile[]) maps.toArray(new MapFile[maps.size()]); - } else { - mapFiles = new MapFile[0]; - } + mapFiles = MapFile.findAllMapFiles(project); } private MapFile getMapFileFor(IFile file) throws CoreException{ @@ -258,9 +245,4 @@ set.add(aFile); mapFiles = (MapFile[])set.toArray(new MapFile[set.size()]); } - private boolean isMapFile(IFile aFile){ - String extension = aFile.getFileExtension(); - //In case file has no extension name or is not validate map file - return ( extension != null && extension.equals(MapFile.MAP_FILE_EXTENSION)); - } } Index: src/org/eclipse/releng/tools/MapProjectSelectionPage.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.releng.tools/src/org/eclipse/releng/tools/MapProjectSelectionPage.java,v retrieving revision 1.9 diff -u -r1.9 MapProjectSelectionPage.java --- src/org/eclipse/releng/tools/MapProjectSelectionPage.java 2 Nov 2007 20:34:06 -0000 1.9 +++ src/org/eclipse/releng/tools/MapProjectSelectionPage.java 9 Jun 2010 12:35:51 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. + * Copyright (c) 2003, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -10,24 +10,37 @@ *******************************************************************************/ package org.eclipse.releng.tools; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogSettings; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.*; -import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.team.core.RepositoryProvider; + import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.*; -import org.eclipse.team.core.RepositoryProvider; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Tree; + +import org.eclipse.core.runtime.CoreException; + +import org.eclipse.core.resources.IProject; + +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.dialogs.IDialogSettings; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.jface.viewers.TreeViewer; +import org.eclipse.jface.wizard.WizardPage; + import org.eclipse.ui.model.WorkbenchContentProvider; import org.eclipse.ui.model.WorkbenchLabelProvider; import org.eclipse.ui.views.navigator.ResourceComparator; + public class MapProjectSelectionPage extends WizardPage { private MapProject selectedMapProject; @@ -88,7 +101,10 @@ } private void updateMapProject(){ - selectedMapProject = null; + if (selectedMapProject != null) { + selectedMapProject.dispose(); + selectedMapProject = null; + } IStructuredSelection selection = (IStructuredSelection)projectTree.getSelection(); if( !selection.isEmpty()){ @@ -97,6 +113,7 @@ try { selectedMapProject = new MapProject((IProject)obj); if(selectedMapProject.getValidMapFiles().length == 0){ + selectedMapProject.dispose(); selectedMapProject = null; } } catch (CoreException e) { @@ -106,6 +123,18 @@ } setPageComplete(isValid(selectedMapProject)); } + + /* + * @see org.eclipse.jface.dialogs.DialogPage#dispose() + * @since 3.6 + */ + public void dispose() { + if (selectedMapProject != null) { + selectedMapProject.dispose(); + selectedMapProject = null; + } + super.dispose(); + } private void initializedViewer(){ readSettings(); Index: src/org/eclipse/releng/tools/RelEngPlugin.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.releng.tools/src/org/eclipse/releng/tools/RelEngPlugin.java,v retrieving revision 1.5 diff -u -r1.5 RelEngPlugin.java --- src/org/eclipse/releng/tools/RelEngPlugin.java 1 Dec 2005 21:16:42 -0000 1.5 +++ src/org/eclipse/releng/tools/RelEngPlugin.java 9 Jun 2010 12:35:51 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -8,19 +8,25 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ - package org.eclipse.releng.tools; import java.util.MissingResourceException; import java.util.ResourceBundle; -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.team.core.RepositoryProvider; + +import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.resources.ResourcesPlugin; + import org.eclipse.ui.plugin.AbstractUIPlugin; + /** * A Plugin for performing certain important RelEng tasks. * Currentley this Plugin provides support for: @@ -31,6 +37,8 @@ public static final String ID = "org.eclipse.releng.tools"; //$NON-NLS-1$ public static final String MAP_PROJECT_NAME = Messages.getString("RelEngPlugin.1"); //$NON-NLS-1$ public static final String MAP_FOLDER = Messages.getString("RelEngPlugin.2"); //$NON-NLS-1$ + private static final String BINARY_REPOSITORY_PROVIDER_CLASS_NAME= "org.eclipse.pde.internal.core.BinaryRepositoryProvider"; //$NON-NLS-1$ + //The shared instance. private static RelEngPlugin plugin; @@ -121,7 +129,24 @@ } return plugin; } - + + /** + * Tells whether the given project is shared. + * + * @param project the project + * @return true if the project is shared + * @since 3.6 + */ + static boolean isShared(IProject project) { + Assert.isLegal(project != null); + if (!RepositoryProvider.isShared(project)) + return false; + + // Check for PDE's binary projects that also connect a provider to the project + RepositoryProvider provider= RepositoryProvider.getProvider(project); + return provider != null && !BINARY_REPOSITORY_PROVIDER_CLASS_NAME.equals(provider.getClass().getName()); + } + /** * The following code is a sample of how to assign a * RelEng nature to a project. This only ever needed Index: src/org/eclipse/releng/tools/ReleaseWizard.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.releng.tools/src/org/eclipse/releng/tools/ReleaseWizard.java,v retrieving revision 1.18 diff -u -r1.18 ReleaseWizard.java --- src/org/eclipse/releng/tools/ReleaseWizard.java 25 Nov 2009 09:03:24 -0000 1.18 +++ src/org/eclipse/releng/tools/ReleaseWizard.java 9 Jun 2010 12:35:51 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -208,7 +208,19 @@ if (defaultBeingUsed) broadcastMapProjectChange(mapProject); } - + + /* + * @see org.eclipse.jface.wizard.Wizard#dispose() + * @since 3.6 + */ + public void dispose() { + if (mapProject != null) { + mapProject.dispose(); + mapProject= null; + } + super.dispose(); + } + private void addMapSelectionPage() { mapSelectionPage = new MapProjectSelectionPage("MapProjectSelectionPage", //$NON-NLS-1$ Messages.getString("ReleaseWizard.4"), //$NON-NLS-1$ @@ -511,9 +523,6 @@ return true; } - public MapProject getMapProject(){ - return mapProject; - } public void broadcastMapProjectChange(MapProject m){ mapProject = m; projectSelectionPage.updateMapProject(m); Index: src/org/eclipse/releng/tools/ReplaceLocalFromMap.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.releng.tools/src/org/eclipse/releng/tools/ReplaceLocalFromMap.java,v retrieving revision 1.9 diff -u -r1.9 ReplaceLocalFromMap.java --- src/org/eclipse/releng/tools/ReplaceLocalFromMap.java 2 Nov 2007 20:34:06 -0000 1.9 +++ src/org/eclipse/releng/tools/ReplaceLocalFromMap.java 9 Jun 2010 12:35:51 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -11,20 +11,27 @@ package org.eclipse.releng.tools; import java.lang.reflect.InvocationTargetException; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.*; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.jface.preference.IPreferenceStore; + import org.eclipse.releng.tools.preferences.MapProjectPreferencePage; import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.*; +import org.eclipse.team.internal.ccvs.core.CVSException; +import org.eclipse.team.internal.ccvs.core.CVSTag; +import org.eclipse.team.internal.ccvs.core.ICVSResource; import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo; import org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction; import org.eclipse.team.internal.ccvs.ui.operations.ReplaceOperation; import org.eclipse.team.internal.core.InfiniteSubProgressMonitor; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.SubProgressMonitor; + +import org.eclipse.core.resources.IResource; + +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.operation.IRunnableWithProgress; +import org.eclipse.jface.preference.IPreferenceStore; + + /** * This action replaces one or more projects in the local workspace * with the versions released to the RelEng map file. @@ -77,26 +84,16 @@ public boolean isEnabled() { if (!(super.isEnabled())) return false; - - IResource[] resources = super.getSelectedResources(); + + IResource[] resources = getSelectedResources(); for (int i = 0; i < resources.length; i++) { IResource resource = resources[i]; if (resource.getType() != IResource.PROJECT) { return false; } } - - //if any of the projects in the current workspace contain valid map files, return true - IProject[] workspaceProjects = RelEngPlugin.getWorkspace().getRoot().getProjects(); - for (int i=0; i 0) { + MapProject selectedMapProject= null; try { selectedMapProject = new MapProject(ResourcesPlugin.getWorkspace().getRoot().getProject(path)); + isMapProjectSelected = true; } catch (CoreException e) { - //do nothing + isMapProjectSelected = false; + } finally { + if (selectedMapProject != null) + selectedMapProject.dispose(); } } - if (selectedMapProject == null) { + if (!isMapProjectSelected) { alwaysPromptButton.setEnabled(true); preferenceStore.setValue(USE_DEFAULT_MAP_PROJECT, false); } else { @@ -236,20 +252,4 @@ } } } - - private boolean isValid(final MapProject mapProject) { - //Check if map project is accessible - if (mapProject == null || (!mapProject.getProject().isAccessible())) { - setErrorMessage(Messages.getString("MapProjectPreferencePage.3")); //$NON-NLS-1$ - return false; - } - - //Check if the map project is shared - if (RepositoryProvider.getProvider(mapProject.getProject()) == null) { - setErrorMessage(Messages.getString("MapProjectPreferencePage.4") + mapProject.getProject().getName() + Messages.getString("MapProjectPreferencePage.5")); //$NON-NLS-1$ //$NON-NLS-2$ - return false; - } - setErrorMessage(null); - return true; - } }