Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 173314 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/releng/tools/TagMap.java (-18 / +23 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others.
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 24-30 Link Here
24
 * Tags the versions in a map file with another tag
24
 * Tags the versions in a map file with another tag
25
 */
25
 */
26
public class TagMap extends TagInRepositoryAction {
26
public class TagMap extends TagInRepositoryAction {
27
	
27
28
	/* (non-Javadoc)
28
	/* (non-Javadoc)
29
	 * @see org.eclipse.team.internal.ccvs.ui.actions.CVSAction#getSelectedCVSResources()
29
	 * @see org.eclipse.team.internal.ccvs.ui.actions.CVSAction#getSelectedCVSResources()
30
	 */
30
	 */
Lines 34-40 Link Here
34
		for (int i = 0; i < resources.length; i++) {
34
		for (int i = 0; i < resources.length; i++) {
35
			IResource resource = resources[i];
35
			IResource resource = resources[i];
36
			try {
36
			try {
37
				String[] strings = LoadMap.readReferenceStrings((IFile)resource);
37
				String[] strings = LoadMap.readReferenceStrings((IFile) resource);
38
				identifiers.addAll(Arrays.asList(strings));
38
				identifiers.addAll(Arrays.asList(strings));
39
			} catch (CoreException e) {
39
			} catch (CoreException e) {
40
				RelEngPlugin.log(e);
40
				RelEngPlugin.log(e);
Lines 57-67 Link Here
57
			try {
57
			try {
58
				String repo = tokenizer.nextToken();
58
				String repo = tokenizer.nextToken();
59
				ICVSRepositoryLocation storedlocation = getLocationFromString(repo);
59
				ICVSRepositoryLocation storedlocation = getLocationFromString(repo);
60
				ICVSRepositoryLocation location = (ICVSRepositoryLocation)previouslySelectedRepositories.get(storedlocation);
60
				ICVSRepositoryLocation location = (ICVSRepositoryLocation) previouslySelectedRepositories.get(storedlocation);
61
				if (location == null) {
61
				if (location == null) {
62
					location = getWritableRepositoryLocation(storedlocation);
62
					location = getWritableRepositoryLocation(storedlocation);
63
					previouslySelectedRepositories.put(storedlocation, location);
63
					previouslySelectedRepositories.put(storedlocation, location);
64
					if (location == null) return new ICVSRemoteResource[0];
64
					if (location == null)
65
						return new ICVSRemoteResource[0];
65
				}
66
				}
66
				String module = tokenizer.nextToken();
67
				String module = tokenizer.nextToken();
67
				tokenizer.nextToken(); /* project name */
68
				tokenizer.nextToken(); /* project name */
Lines 72-83 Link Here
72
				}
73
				}
73
				result.add(location.getRemoteFolder(module, tag));
74
				result.add(location.getRemoteFolder(module, tag));
74
			} catch (CVSException e) {
75
			} catch (CVSException e) {
75
			    RelEngPlugin.log(e);
76
				RelEngPlugin.log(e);
76
			}
77
			}
77
		}
78
		}
78
		return (ICVSRemoteResource[]) result.toArray(new ICVSRemoteResource[result.size()]);
79
		return (ICVSRemoteResource[]) result.toArray(new ICVSRemoteResource[result.size()]);
79
	}
80
	}
80
	
81
81
	private ICVSRepositoryLocation getLocationFromString(String repo) throws CVSException {
82
	private ICVSRepositoryLocation getLocationFromString(String repo) throws CVSException {
82
		// create the new location
83
		// create the new location
83
		ICVSRepositoryLocation newLocation = CVSRepositoryLocation.fromString(repo);
84
		ICVSRepositoryLocation newLocation = CVSRepositoryLocation.fromString(repo);
Lines 86-101 Link Here
86
			ICVSRepositoryLocation[] locations = CVSProviderPlugin.getPlugin().getKnownRepositories();
87
			ICVSRepositoryLocation[] locations = CVSProviderPlugin.getPlugin().getKnownRepositories();
87
			for (int i = 0; i < locations.length; i++) {
88
			for (int i = 0; i < locations.length; i++) {
88
				ICVSRepositoryLocation location = locations[i];
89
				ICVSRepositoryLocation location = locations[i];
89
				if (location.getMethod() == newLocation.getMethod()
90
				if (location.getMethod() == newLocation.getMethod() && location.getHost().equals(newLocation.getHost()) && location.getPort() == newLocation.getPort() && location.getRootDirectory().equals(newLocation.getRootDirectory()))
90
					&& location.getHost().equals(newLocation.getHost())
91
					return location;
91
					&& location.getPort() == newLocation.getPort()
92
					&& location.getRootDirectory().equals(newLocation.getRootDirectory()))
93
						return location;
94
			}
92
			}
95
		}
93
		}
96
		return newLocation;
94
		return newLocation;
97
	}
95
	}
98
	
96
99
	private ICVSRepositoryLocation getWritableRepositoryLocation(ICVSRepositoryLocation storedLocation) {
97
	private ICVSRepositoryLocation getWritableRepositoryLocation(ICVSRepositoryLocation storedLocation) {
100
		// Find out which repo locations are appropriate
98
		// Find out which repo locations are appropriate
101
		ICVSRepositoryLocation[] locations = CVSUIPlugin.getPlugin().getRepositoryManager().getKnownRepositoryLocations();
99
		ICVSRepositoryLocation[] locations = CVSUIPlugin.getPlugin().getRepositoryManager().getKnownRepositoryLocations();
Lines 103-125 Link Here
103
		for (int i = 0; i < locations.length; i++) {
101
		for (int i = 0; i < locations.length; i++) {
104
			ICVSRepositoryLocation location = locations[i];
102
			ICVSRepositoryLocation location = locations[i];
105
			// Only locations with the same host and root are eligible
103
			// Only locations with the same host and root are eligible
106
			if (!location.getHost().equals(storedLocation.getHost())) continue;
104
			if (!location.getHost().equals(storedLocation.getHost()))
107
			if (!location.getRootDirectory().equals(storedLocation.getRootDirectory())) continue;
105
				continue;
106
			if (!location.getRootDirectory().equals(storedLocation.getRootDirectory()))
107
				continue;
108
			compatibleLocations.add(location);
108
			compatibleLocations.add(location);
109
		}
109
		}
110
		RepositorySelectionDialog dialog = new RepositorySelectionDialog(getShell());
110
		RepositorySelectionDialog dialog = new RepositorySelectionDialog(getShell());
111
		dialog.setLocations((ICVSRepositoryLocation[])compatibleLocations.toArray(new ICVSRepositoryLocation[compatibleLocations.size()]));
111
		dialog.setLocations((ICVSRepositoryLocation[]) compatibleLocations.toArray(new ICVSRepositoryLocation[compatibleLocations.size()]));
112
		dialog.open();
112
		dialog.open();
113
		ICVSRepositoryLocation location = dialog.getLocation();
113
		ICVSRepositoryLocation location = dialog.getLocation();
114
		return location;
114
		return location;
115
	}
115
	}
116
	
116
117
	/* (non-Javadoc)
117
	/* (non-Javadoc)
118
	 * @see org.eclipse.team.internal.ui.actions.TeamAction#isEnabled()
118
	 * @see org.eclipse.team.internal.ui.actions.TeamAction#isEnabled()
119
	 */
119
	 */
120
	public boolean isEnabled() {
120
	public boolean isEnabled() {
121
		IResource[] resources = getSelectedResources();
121
		IResource[] resources = getSelectedResources();
122
		return (resources.length >= 0  && MapProject.getDefaultMapProject().mapsAreLoaded());
122
		if (resources.length <= 0)
123
			return false;
124
		for (int i = 0; i < resources.length; i++)
125
			if (MapProject.getDefaultMapProject().getMapEntry(resources[i].getProject()) == null)
126
				return false;
127
		return true;
123
	}
128
	}
124
129
125
}
130
}
(-)src/org/eclipse/releng/tools/MapContentDocument.java (-26 / +27 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others.
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 10-22 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.releng.tools;
11
package org.eclipse.releng.tools;
12
12
13
import java.io.BufferedInputStream;
13
import java.io.*;
14
import java.io.BufferedReader;
15
import java.io.ByteArrayInputStream;
16
import java.io.IOException;
17
import java.io.InputStream;
18
import java.io.InputStreamReader;
19
20
import org.eclipse.compare.IStreamContentAccessor;
14
import org.eclipse.compare.IStreamContentAccessor;
21
import org.eclipse.compare.ITypedElement;
15
import org.eclipse.compare.ITypedElement;
22
import org.eclipse.core.resources.IProject;
16
import org.eclipse.core.resources.IProject;
Lines 25-38 Link Here
25
import org.eclipse.team.internal.ccvs.core.CVSException;
19
import org.eclipse.team.internal.ccvs.core.CVSException;
26
import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
20
import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
27
21
28
22
/*
29
public class MapContentDocument implements ITypedElement, IStreamContentAccessor{
23
 * TODO Its a shame that we use Strings here and it isn't backed by real MapEntry objects
24
 * but in order to do this we need to make changes outside of the MapEntryRegistry and then
25
 * commit them once the user commits the map file changes to the file-system.
26
 */
27
public class MapContentDocument implements ITypedElement, IStreamContentAccessor {
30
	private MapFile mapFile;
28
	private MapFile mapFile;
31
	private String oldContents = "";
29
	private String oldContents = "";
32
	private String newContents = "";
30
	private String newContents = "";
33
31
34
	public MapContentDocument(MapFile aMapFile) {
32
	public MapContentDocument(MapFile aMapFile) {
35
		mapFile = aMapFile;	
33
		mapFile = aMapFile;
36
		initialize();
34
		initialize();
37
	}
35
	}
38
36
Lines 40-62 Link Here
40
	 * Update the tag associated with the given project in the new contents.
38
	 * Update the tag associated with the given project in the new contents.
41
	 */
39
	 */
42
	public void updateTag(IProject project, String tag) throws CVSException {
40
	public void updateTag(IProject project, String tag) throws CVSException {
43
		InputStream inputStream = new BufferedInputStream(
41
		MapEntry realEntry = mapFile.getMapEntry(project);
44
				new ByteArrayInputStream(newContents.getBytes()));
42
		if (realEntry == null)
43
			return;
44
		String mapString = realEntry.getMapString();
45
		InputStream inputStream = new BufferedInputStream(new ByteArrayInputStream(newContents.getBytes()));
45
		boolean match = false;
46
		boolean match = false;
46
		StringBuffer buffer = new StringBuffer();
47
		StringBuffer buffer = new StringBuffer();
47
		try {
48
		try {
48
			BufferedReader aReader = new BufferedReader(new InputStreamReader(
49
			BufferedReader aReader = new BufferedReader(new InputStreamReader(inputStream));
49
					inputStream));
50
			String aLine = aReader.readLine();
50
			String aLine = aReader.readLine();
51
			while (aLine != null) {
51
			while (aLine != null) {
52
				if (aLine.trim().length() != 0 && !aLine.startsWith("!")) {
52
				if (aLine.trim().length() != 0 && !aLine.startsWith("!")) {
53
					// Found a possible match
53
					// Found a possible match
54
					MapEntry entry = new MapEntry(aLine);
54
					MapEntry entry = MapEntry.parse(aLine, mapFile);
55
					if (!entry.isValid()) {
55
					if (entry != null && mapString.equals(entry.getMapString())) {
56
						throw new CVSException("Malformed map file line: "
57
								+ aLine);
58
					}
59
					if (entry.isMappedTo(project)) {
60
						// Now for sure we have a match. Replace the line.
56
						// Now for sure we have a match. Replace the line.
61
						entry.setTagName(tag);
57
						entry.setTagName(tag);
62
						aLine = entry.getMapString();
58
						aLine = entry.getMapString();
Lines 69-76 Link Here
69
					buffer.append(System.getProperty("line.separator")); //$NON-NLS-1$
65
					buffer.append(System.getProperty("line.separator")); //$NON-NLS-1$
70
				}
66
				}
71
			}
67
			}
72
		} catch (CoreException e) {
73
			throw CVSException.wrapException(e);
74
		} catch (IOException e) {
68
		} catch (IOException e) {
75
			throw CVSException.wrapException(e);
69
			throw CVSException.wrapException(e);
76
		} finally {
70
		} finally {
Lines 78-83 Link Here
78
				try {
72
				try {
79
					inputStream.close();
73
					inputStream.close();
80
				} catch (IOException e) {
74
				} catch (IOException e) {
75
					// ignore
81
				}
76
				}
82
			}
77
			}
83
		}
78
		}
Lines 85-93 Link Here
85
			newContents = buffer.toString();
80
			newContents = buffer.toString();
86
		}
81
		}
87
	}
82
	}
83
88
	public boolean isChanged() {
84
	public boolean isChanged() {
89
		return !(oldContents.equals(newContents));
85
		return !(oldContents.equals(newContents));
90
	}
86
	}
87
91
	/*
88
	/*
92
	 * (non-Javadoc)
89
	 * (non-Javadoc)
93
	 * 
90
	 * 
Lines 96-101 Link Here
96
	public String getName() {
93
	public String getName() {
97
		return mapFile.getFile().getName();
94
		return mapFile.getFile().getName();
98
	}
95
	}
96
99
	/*
97
	/*
100
	 * (non-Javadoc)
98
	 * (non-Javadoc)
101
	 * 
99
	 * 
Lines 104-109 Link Here
104
	public Image getImage() {
102
	public Image getImage() {
105
		return null;
103
		return null;
106
	}
104
	}
105
107
	/*
106
	/*
108
	 * (non-Javadoc)
107
	 * (non-Javadoc)
109
	 * 
108
	 * 
Lines 112-117 Link Here
112
	public String getType() {
111
	public String getType() {
113
		return mapFile.getFile().getFileExtension();
112
		return mapFile.getFile().getFileExtension();
114
	}
113
	}
114
115
	/*
115
	/*
116
	 * (non-Javadoc)
116
	 * (non-Javadoc)
117
	 * 
117
	 * 
Lines 120-139 Link Here
120
	public InputStream getContents() throws CoreException {
120
	public InputStream getContents() throws CoreException {
121
		return new ByteArrayInputStream(getNewContent().getBytes());
121
		return new ByteArrayInputStream(getNewContent().getBytes());
122
	}
122
	}
123
123
	public MapFile getMapFile() {
124
	public MapFile getMapFile() {
124
		return mapFile;
125
		return mapFile;
125
	}
126
	}
126
	
127
127
	private String getNewContent() {
128
	private String getNewContent() {
128
		return newContents;
129
		return newContents;
129
	}
130
	}
131
130
	private void initialize() {
132
	private void initialize() {
131
		InputStream inputStream;
133
		InputStream inputStream;
132
		StringBuffer buffer = new StringBuffer();
134
		StringBuffer buffer = new StringBuffer();
133
		try {
135
		try {
134
			inputStream = mapFile.getFile().getContents();
136
			inputStream = mapFile.getFile().getContents();
135
			BufferedReader aReader = new BufferedReader(new InputStreamReader(
137
			BufferedReader aReader = new BufferedReader(new InputStreamReader(inputStream));
136
					inputStream));
137
			String aLine = aReader.readLine();
138
			String aLine = aReader.readLine();
138
			while (aLine != null) {
139
			while (aLine != null) {
139
				buffer.append(aLine);
140
				buffer.append(aLine);
(-)src/org/eclipse/releng/tools/RelEngPlugin.java (-9 / +30 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others.
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 8-24 Link Here
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
10
 *******************************************************************************/
11
12
package org.eclipse.releng.tools;
11
package org.eclipse.releng.tools;
13
12
14
import java.util.MissingResourceException;
13
import java.util.*;
15
import java.util.ResourceBundle;
16
17
import org.eclipse.core.resources.IWorkspace;
14
import org.eclipse.core.resources.IWorkspace;
18
import org.eclipse.core.resources.ResourcesPlugin;
15
import org.eclipse.core.resources.ResourcesPlugin;
19
import org.eclipse.core.runtime.CoreException;
16
import org.eclipse.core.runtime.*;
20
import org.eclipse.core.runtime.IStatus;
21
import org.eclipse.core.runtime.Status;
22
import org.eclipse.ui.plugin.AbstractUIPlugin;
17
import org.eclipse.ui.plugin.AbstractUIPlugin;
23
18
24
/**
19
/**
Lines 36-41 Link Here
36
	private static RelEngPlugin plugin;
31
	private static RelEngPlugin plugin;
37
	//Resource bundle.
32
	//Resource bundle.
38
	private ResourceBundle resourceBundle;
33
	private ResourceBundle resourceBundle;
34
	private static Set fetchCommands;
39
	
35
	
40
	/**
36
	/**
41
	 * The constructor.
37
	 * The constructor.
Lines 121-127 Link Here
121
		}
117
		}
122
		return plugin;
118
		return plugin;
123
	}
119
	}
124
	
120
121
	/*
122
	 * Return true if the given string is a valid fetch command
123
	 * and false otherwise. CVS and GET come with Eclipse by default.
124
	 */
125
	public static boolean isValidFetchCommand(String command) {
126
		if (fetchCommands == null) {
127
			IExtensionPoint extpt = Platform.getExtensionRegistry().getExtensionPoint("org.eclipse.pde.build.fetchFactories");
128
			if (extpt == null)
129
				return false;
130
			fetchCommands = new HashSet();
131
			IExtension[] extensions = extpt.getExtensions();
132
			for (int i=0; i<extensions.length; i++) {
133
				IExtension ext = extensions[i];
134
				IConfigurationElement[] configs = ext.getConfigurationElements();
135
				for (int j=0; j<configs.length; j++) {
136
					IConfigurationElement config = configs[j];
137
					String id = config.getAttribute("id");
138
					if (id != null)
139
						fetchCommands.add(id);
140
				}
141
			}
142
		}
143
		return fetchCommands.contains(command);
144
	}
145
125
	/**
146
	/**
126
	 * The following code is a sample of how to assign a
147
	 * The following code is a sample of how to assign a
127
	 * RelEng nature to a project.  This only ever needed
148
	 * RelEng nature to a project.  This only ever needed
(-)src/org/eclipse/releng/tools/CompareLocalToMap.java (-15 / +30 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others.
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 11-22 Link Here
11
package org.eclipse.releng.tools;
11
package org.eclipse.releng.tools;
12
12
13
import java.lang.reflect.InvocationTargetException;
13
import java.lang.reflect.InvocationTargetException;
14
14
import org.eclipse.core.resources.IProject;
15
import org.eclipse.core.resources.IResource;
15
import org.eclipse.core.resources.IResource;
16
import org.eclipse.jface.action.IAction;
16
import org.eclipse.jface.action.IAction;
17
import org.eclipse.team.internal.ccvs.core.CVSCompareSubscriber;
17
import org.eclipse.jface.dialogs.*;
18
import org.eclipse.team.internal.ccvs.core.CVSException;
18
import org.eclipse.jface.dialogs.Dialog;
19
import org.eclipse.team.internal.ccvs.core.CVSTag;
19
import org.eclipse.swt.widgets.*;
20
import org.eclipse.team.core.RepositoryProvider;
21
import org.eclipse.team.internal.ccvs.core.*;
20
import org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction;
22
import org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction;
21
import org.eclipse.team.internal.ccvs.ui.subscriber.CompareParticipant;
23
import org.eclipse.team.internal.ccvs.ui.subscriber.CompareParticipant;
22
import org.eclipse.team.ui.TeamUI;
24
import org.eclipse.team.ui.TeamUI;
Lines 38-47 Link Here
38
	 */
40
	 */
39
	protected CVSTag getTag(IResource resource) {
41
	protected CVSTag getTag(IResource resource) {
40
		MapEntry entry = getMapProject().getMapEntry(resource.getProject());
42
		MapEntry entry = getMapProject().getMapEntry(resource.getProject());
41
		if (entry == null) return CVSTag.DEFAULT;
43
		if (entry == null)
44
			return CVSTag.DEFAULT;
42
		return entry.getTag();
45
		return entry.getTag();
43
	}
46
	}
44
	
47
45
	/**
48
	/**
46
	 * Returns true if the super would enable the option *and*
49
	 * Returns true if the super would enable the option *and*
47
	 * only projects are selected.  There is no concept of "releasing"
50
	 * only projects are selected.  There is no concept of "releasing"
Lines 50-70 Link Here
50
	 * @see org.eclipse.team.internal.ui.actions.TeamAction#isEnabled()
53
	 * @see org.eclipse.team.internal.ui.actions.TeamAction#isEnabled()
51
	 */
54
	 */
52
	public boolean isEnabled() {
55
	public boolean isEnabled() {
53
		
56
54
		boolean result = super.isEnabled();
57
		boolean result = super.isEnabled();
55
		if (!result) {
58
		if (!result) {
56
			return false;
59
			return false;
57
		}	
60
		}
58
		return (getMapProject() != null && getMapProject().mapsAreLoaded());
61
		IResource[] resources = getSelectedResources();
62
		if (resources == null || resources.length == 0)
63
			return false;
64
		for (int i = 0; i < resources.length; i++) {
65
			IResource resource = resources[i];
66
			if (resource.getType() != IResource.PROJECT)
67
				return false;
68
			if (getMapProject().getMapEntry((IProject) resource) == null)
69
				return false;
70
		}
71
		return true;
59
	}
72
	}
60
73
61
	/**
74
	/**
62
	 * @see org.eclipse.team.internal.ccvs.ui.actions.CVSAction#execute(org.eclipse.jface.action.IAction)
75
	 * @see org.eclipse.team.internal.ccvs.ui.actions.CVSAction#execute(org.eclipse.jface.action.IAction)
63
	 */
76
	 */
64
	protected void execute(IAction action) throws InvocationTargetException, InterruptedException {		
77
	protected void execute(IAction action) throws InvocationTargetException, InterruptedException {
65
		IResource[] resources = getSelectedResources();
78
		IResource[] resources = getSelectedResources();
66
		if (resources.length == 0) return;
79
		if (resources.length == 0)
67
		CVSTag[] tags = new CVSTag[resources.length];		
80
			return;
81
		CVSTag[] tags = new CVSTag[resources.length];
68
		for (int i = 0; i < resources.length; i++) {
82
		for (int i = 0; i < resources.length; i++) {
69
			tags[i] = getTag(resources[i]);
83
			tags[i] = getTag(resources[i]);
70
		}
84
		}
Lines 78-87 Link Here
78
			RelEngPlugin.log(e);
92
			RelEngPlugin.log(e);
79
		}
93
		}
80
		CompareParticipant participant = new CompareParticipant(s);
94
		CompareParticipant participant = new CompareParticipant(s);
81
		TeamUI.getSynchronizeManager().addSynchronizeParticipants(new ISynchronizeParticipant[]{participant});
95
		TeamUI.getSynchronizeManager().addSynchronizeParticipants(new ISynchronizeParticipant[] {participant});
82
		participant.refresh(resources, "Refreshing", "Refreshing", getTargetPart().getSite());
96
		participant.refresh(resources, "Refreshing", "Refreshing", getTargetPart().getSite());
83
	}
97
	}
84
	private MapProject getMapProject(){
98
99
	private MapProject getMapProject() {
85
		return MapProject.getDefaultMapProject();
100
		return MapProject.getDefaultMapProject();
86
	}
101
	}
87
}
102
}
(-)src/org/eclipse/releng/tools/MapEntry.java (-107 / +81 lines)
Lines 1-28 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others.
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
7
 * 
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.releng.tools;
11
package org.eclipse.releng.tools;
12
12
13
import java.util.*;
13
import java.util.*;
14
import org.eclipse.core.resources.IProject;
15
import org.eclipse.core.runtime.IPath;
16
import org.eclipse.core.runtime.Path;
14
import org.eclipse.core.runtime.Path;
17
import org.eclipse.team.internal.ccvs.core.*;
15
import org.eclipse.team.internal.ccvs.core.CVSTag;
18
import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
19
import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
20
16
21
/**
17
/**
22
 * This class provides access to information stored in RelEng map files
18
 * This class provides access to information stored in RelEng map files
23
 */
19
 */
24
public class MapEntry {
20
public class MapEntry {
25
	
21
26
	private static final String KEY_TAG = "tag"; //$NON-NLS-1$
22
	private static final String KEY_TAG = "tag"; //$NON-NLS-1$
27
	private static final String KEY_PATH = "path"; //$NON-NLS-1$
23
	private static final String KEY_PATH = "path"; //$NON-NLS-1$
28
	private static final String KEY_CVSROOT = "cvsRoot"; //$NON-NLS-1$
24
	private static final String KEY_CVSROOT = "cvsRoot"; //$NON-NLS-1$
Lines 35-79 Link Here
35
	private OrderedMap arguments = new OrderedMap();
31
	private OrderedMap arguments = new OrderedMap();
36
	private boolean legacy = false;
32
	private boolean legacy = false;
37
	private String version;
33
	private String version;
34
	private MapFile file;
38
35
39
	public static void main (String[] args)  {
36
	public static void main(String[] args) {
40
		// For testing only
37
		// For testing only
41
		
38
42
		String[] strings = {
39
		String[] strings = { //
43
			"",
40
		"", //
44
			" ",
41
				" ", //
45
			"type",
42
				"type", //
46
			"type@",
43
				"type@", //
47
			"type@id",
44
				"type@id", //
48
			"type@id=",
45
				"type@id=", //
49
			"type@id=tag,",
46
				"type@id=tag,", //
50
			"type@id=tag, connectString",
47
				"type@id=tag, connectString", //
51
			"type@id=tag, connectString,",
48
				"type@id=tag, connectString,", //
52
			"type@id=tag, connectString,password",
49
				"type@id=tag, connectString,password", //
53
			"type@id=tag, connectString,password,",
50
				"type@id=tag, connectString,password,", //
54
			"type@id=tag, connectString,password,moduleName",
51
				"type@id=tag, connectString,password,moduleName", //
55
			"type@id=tag, connectString,,moduleName",
52
				"type@id=tag, connectString,,moduleName", //
56
			"!***************  FEATURE CONTRIBUTION  ******************************************************",
53
				"!***************  FEATURE CONTRIBUTION  ******************************************************", //
57
			"@",
54
				"@", //
58
			"=",
55
				"=", //
59
			",,,",
56
				",,,", //
60
			"@=,,,,",
57
				"@=,,,,", //
61
			"type@id,version=CVS,tag=myTag,cvsRoot=myCvsRoot,password=password,path=myPath",
58
				"type@id,version=CVS,tag=myTag,cvsRoot=myCvsRoot,password=password,path=myPath", //
62
		};
59
		};
63
		
60
64
		for (int i = 0; i < strings.length; i++) {
61
		for (int i = 0; i < strings.length; i++) {
65
			String string = strings[i];
62
			String string = strings[i];
66
			MapEntry anEntry = new MapEntry(string);
63
			MapEntry anEntry = new MapEntry(string, null);
67
64
68
			System.out.println("-----------------------------------------------");
65
			System.out.println("-----------------------------------------------");
69
			System.out.println("input: " + string);
66
			System.out.println("input: " + string);
70
			System.out.println("map string: " + anEntry.getMapString());
67
			System.out.println("map string: " + anEntry.getMapString());
71
//			System.out.println(anEntry.getReferenceString());
68
			//			System.out.println(anEntry.getReferenceString());
72
			anEntry.display();
69
			anEntry.display();
73
		}
70
		}
74
		
71
75
	}
72
	}
76
	
73
77
	/**
74
	/**
78
	 * 
75
	 * 
79
	 */
76
	 */
Lines 89-116 Link Here
89
		System.out.println("Password: " + getPassword());
86
		System.out.println("Password: " + getPassword());
90
		System.out.println("CVS Module: " + getCVSModule());
87
		System.out.println("CVS Module: " + getCVSModule());
91
	}
88
	}
92
	
89
93
	public MapEntry(String entryLine) {
90
	/*
91
	 * Return a new MapEntry object based on the given line from a Map
92
	 * file. If the line isn't a valid entry (comment, unknown fetch type, etc)
93
	 * then return null.
94
	 */
95
	public static MapEntry parse(String line, MapFile file) {
96
		MapEntry result = new MapEntry(line, file);
97
		return result.isValid() ? result : null;
98
	}
99
100
	private MapEntry(String entryLine, MapFile file) {
101
		this.file = file;
94
		init(entryLine);
102
		init(entryLine);
95
	}
103
	}
96
104
105
	public MapFile getFile() {
106
		return file;
107
	}
108
97
	/**
109
	/**
98
	 * Parse a map file entry line
110
	 * Parse a map file entry line
99
	 * @param entryLine
111
	 * @param entryLine
100
	 */	
112
	 */
101
	private void init(String entryLine) {
113
	private void init(String entryLine) {
102
		valid = false;
114
		valid = false;
103
	
115
104
		// Type	
116
		// Type	
105
		int start = 0;
117
		int start = 0;
106
		int end = entryLine.indexOf('@');
118
		int end = entryLine.indexOf('@');
107
		if (end == -1)  return;
119
		if (end == -1)
120
			return;
108
		type = entryLine.substring(start, end).trim();
121
		type = entryLine.substring(start, end).trim();
109
		
122
110
		// Project Name
123
		// Project Name
111
		start = end + 1;
124
		start = end + 1;
112
		end = entryLine.indexOf('=', start);
125
		end = entryLine.indexOf('=', start);
113
		if (end == -1) return;
126
		if (end == -1)
127
			return;
114
		id = entryLine.substring(start, end).trim();
128
		id = entryLine.substring(start, end).trim();
115
		// we have a version that we have to strip off
129
		// we have a version that we have to strip off
116
		int comma = id.indexOf(',');
130
		int comma = id.indexOf(',');
Lines 134-146 Link Here
134
	 */
148
	 */
135
	private OrderedMap populate(String[] entries) {
149
	private OrderedMap populate(String[] entries) {
136
		OrderedMap result = new OrderedMap();
150
		OrderedMap result = new OrderedMap();
137
		for (int i=0; i<entries.length; i++) {
151
		for (int i = 0; i < entries.length; i++) {
138
			String entry = entries[i];
152
			String entry = entries[i];
139
			int index = entry.indexOf('=');
153
			int index = entry.indexOf('=');
140
			if (index == -1) {
154
			if (index == -1) {
141
				// we only handle CVS entries
155
				if (RelEngPlugin.isValidFetchCommand(entry)) {
142
				if (i == 0 && "CVS".equalsIgnoreCase(entry)) 
156
					// we only handle CVS entries
143
					continue;
157
					if (i == 0 && "CVS".equalsIgnoreCase(entry))
158
						continue;
159
					// if we have GET or something then just return
160
					return result;
161
				}
144
				// legacy story...
162
				// legacy story...
145
				return legacyPopulate(entries);
163
				return legacyPopulate(entries);
146
			}
164
			}
Lines 151-157 Link Here
151
		result.toString();
169
		result.toString();
152
		return result;
170
		return result;
153
	}
171
	}
154
	
172
155
	private OrderedMap legacyPopulate(String[] entries) {
173
	private OrderedMap legacyPopulate(String[] entries) {
156
		legacy = true;
174
		legacy = true;
157
		OrderedMap result = new OrderedMap();
175
		OrderedMap result = new OrderedMap();
Lines 161-171 Link Here
161
			result.put(KEY_TAG, entries[0]);
179
			result.put(KEY_TAG, entries[0]);
162
			// Repo Connect String
180
			// Repo Connect String
163
			result.put(KEY_CVSROOT, entries[1]);
181
			result.put(KEY_CVSROOT, entries[1]);
164
			
182
165
			// Optional Password.
183
			// Optional Password.
166
			if (entries.length >= 3)
184
			if (entries.length >= 3)
167
				result.put(KEY_PASSWORD, entries[2]);
185
				result.put(KEY_PASSWORD, entries[2]);
168
			
186
169
			// Optional CVS Module Name
187
			// Optional CVS Module Name
170
			if (entries.length >= 4)
188
			if (entries.length >= 4)
171
				result.put(KEY_PATH, entries[3]);
189
				result.put(KEY_PATH, entries[3]);
Lines 203-214 Link Here
203
		String value = (String) arguments.get(KEY_TAG);
221
		String value = (String) arguments.get(KEY_TAG);
204
		return value == null ? EMPTY_STRING : value;
222
		return value == null ? EMPTY_STRING : value;
205
	}
223
	}
206
	
224
207
	public CVSTag getTag() {
225
	public CVSTag getTag() {
208
		if (getTagName().equals("HEAD")) return CVSTag.DEFAULT;
226
		if (getTagName().equals("HEAD"))
227
			return CVSTag.DEFAULT;
209
		return new CVSTag(getTagName(), CVSTag.VERSION);
228
		return new CVSTag(getTagName(), CVSTag.VERSION);
210
	}
229
	}
211
	
230
212
	public String getPassword() {
231
	public String getPassword() {
213
		String value = (String) arguments.get(KEY_PASSWORD);
232
		String value = (String) arguments.get(KEY_PASSWORD);
214
		return value == null ? EMPTY_STRING : value;
233
		return value == null ? EMPTY_STRING : value;
Lines 218-228 Link Here
218
		return id;
237
		return id;
219
	}
238
	}
220
239
221
	private String internalGetCVSModule()  {
240
	private String internalGetCVSModule() {
222
		String module = (String) arguments.get(KEY_PATH);
241
		String module = (String) arguments.get(KEY_PATH);
223
		return module == null ? id : module;
242
		return module == null ? id : module;
224
	}
243
	}
225
	
244
226
	public String getCVSModule() {
245
	public String getCVSModule() {
227
		String value = (String) arguments.get(KEY_PATH);
246
		String value = (String) arguments.get(KEY_PATH);
228
		return value == null ? EMPTY_STRING : value;
247
		return value == null ? EMPTY_STRING : value;
Lines 240-248 Link Here
240
	public boolean isValid() {
259
	public boolean isValid() {
241
		return valid;
260
		return valid;
242
	}
261
	}
243
	
262
244
	public String getReferenceString()  {
263
	public String getReferenceString() {
245
		if (!isValid()) return null;
264
		if (!isValid())
265
			return null;
246
		// This is the format used by the CVS IProjectSerializer
266
		// This is the format used by the CVS IProjectSerializer
247
		String projectName = new Path(internalGetCVSModule()).lastSegment();
267
		String projectName = new Path(internalGetCVSModule()).lastSegment();
248
		return "1.0," + getRepo() + "," + internalGetCVSModule() + "," + projectName + "," + getTagName();
268
		return "1.0," + getRepo() + "," + internalGetCVSModule() + "," + projectName + "," + getTagName();
Lines 278-284 Link Here
278
		}
298
		}
279
		result.append('=');
299
		result.append('=');
280
		result.append("CVS");
300
		result.append("CVS");
281
		for (Iterator iter = arguments.keys().iterator(); iter.hasNext(); ) {
301
		for (Iterator iter = arguments.keys().iterator(); iter.hasNext();) {
282
			String key = (String) iter.next();
302
			String key = (String) iter.next();
283
			String value = (String) arguments.get(key);
303
			String value = (String) arguments.get(key);
284
			if (value != null && value.length() > 0)
304
			if (value != null && value.length() > 0)
Lines 293-299 Link Here
293
	public String getVersion() {
313
	public String getVersion() {
294
		return version;
314
		return version;
295
	}
315
	}
296
	
316
297
	public void setPassword(String password) {
317
	public void setPassword(String password) {
298
		arguments.put(KEY_PASSWORD, password);
318
		arguments.put(KEY_PASSWORD, password);
299
	}
319
	}
Lines 321-327 Link Here
321
	public void setValid(boolean valid) {
341
	public void setValid(boolean valid) {
322
		this.valid = valid;
342
		this.valid = valid;
323
	}
343
	}
324
	
344
325
	public String toString() {
345
	public String toString() {
326
		return "Entry: " + getMapString();
346
		return "Entry: " + getMapString();
327
	}
347
	}
Lines 331-384 Link Here
331
	 */
351
	 */
332
	public boolean equals(Object obj) {
352
	public boolean equals(Object obj) {
333
		if (obj instanceof MapEntry) {
353
		if (obj instanceof MapEntry) {
334
			return ((MapEntry)obj).getMapString().equals(getMapString());
354
			return ((MapEntry) obj).getMapString().equals(getMapString());
335
		}
355
		}
336
		return super.equals(obj);
356
		return super.equals(obj);
337
	}
357
	}
338
	
339
	/**
340
	 * Return true if this map entry is mapped to the given CVS module
341
	 * @param moduleName
342
	 */
343
	public boolean isMappedTo(String moduleName) {
344
		IPath entryPath = new Path(internalGetCVSModule());
345
		IPath modulePath = new Path(moduleName);
346
		if (entryPath.segmentCount() != modulePath.segmentCount()) return false;
347
		for (int i = 0; i < entryPath.segmentCount(); i++) {
348
			if (!entryPath.segment(i).equals(modulePath.segment(i))) {
349
				return false;
350
			}
351
		}
352
		return true;
353
	}
354
355
	/**
356
	 * Return <code>true</code> if the entry is mapped to the given project
357
	 * and <code>false</code> otherwise.
358
	 */
359
	public boolean isMappedTo(IProject project) {
360
		String moduleName;
361
		try {
362
			moduleName = getCVSModule(project);
363
			if (moduleName == null) return false;
364
			return isMappedTo(moduleName);
365
		} catch (CVSException e) {
366
			RelEngPlugin.getDefault().getLog().log(e.getStatus());
367
			return false;
368
		}
369
	}
370
	
371
	/**
372
	 * Get the remote CVS module for the project or <code>null</code>
373
	 * if the project is not a CVS project.
374
	 */
375
	private String getCVSModule(IProject project) throws CVSException {
376
		ICVSFolder folder = CVSWorkspaceRoot.getCVSFolderFor(project);
377
		FolderSyncInfo info = folder.getFolderSyncInfo();
378
		if (info == null) {
379
			return null;
380
		}
381
		return info.getRepository();
382
	}
383
384
}
358
}
(-)src/org/eclipse/releng/tools/ReplaceLocalFromMap.java (-26 / +24 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others.
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 40-50 Link Here
40
	 * @throws CVSException
40
	 * @throws CVSException
41
	 */
41
	 */
42
	protected CVSTag getTag(IResource resource) {
42
	protected CVSTag getTag(IResource resource) {
43
		MapEntry entry = MapProject.getDefaultMapProject().getMapEntry((IProject)resource);
43
		MapEntry entry = MapProject.getDefaultMapProject().getMapEntry((IProject) resource);
44
		if (entry == null) return CVSTag.DEFAULT;
44
		if (entry == null)
45
			return CVSTag.DEFAULT;
45
		return entry.getTag();
46
		return entry.getTag();
46
	}
47
	}
47
	
48
48
	/**
49
	/**
49
	 * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForAddedResources()
50
	 * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForAddedResources()
50
	 */
51
	 */
Lines 58-64 Link Here
58
	protected boolean isEnabledForNonExistantResources() {
59
	protected boolean isEnabledForNonExistantResources() {
59
		return true;
60
		return true;
60
	}
61
	}
61
	
62
62
	/**
63
	/**
63
	 * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForCVSResource(org.eclipse.team.internal.ccvs.core.ICVSResource)
64
	 * @see org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction#isEnabledForCVSResource(org.eclipse.team.internal.ccvs.core.ICVSResource)
64
	 */
65
	 */
Lines 70-76 Link Here
70
				if (info != null && info.getTag() != null) {
71
				if (info != null && info.getTag() != null) {
71
					String revision = info.getRevision();
72
					String revision = info.getRevision();
72
					String tag = info.getTag().getName();
73
					String tag = info.getTag().getName();
73
					if (revision.equals(tag)) return false;
74
					if (revision.equals(tag))
75
						return false;
74
				}
76
				}
75
			}
77
			}
76
			return true;
78
			return true;
Lines 78-84 Link Here
78
			return false;
80
			return false;
79
		}
81
		}
80
	}
82
	}
81
	
83
82
	/**
84
	/**
83
	 * Returns true if the super would enable the option *and*
85
	 * Returns true if the super would enable the option *and*
84
	 * only projects are selected.  There is no concept of "releasing"
86
	 * only projects are selected.  There is no concept of "releasing"
Lines 87-107 Link Here
87
	 * @see org.eclipse.team.internal.ui.actions.TeamAction#isEnabled()
89
	 * @see org.eclipse.team.internal.ui.actions.TeamAction#isEnabled()
88
	 */
90
	 */
89
	public boolean isEnabled() {
91
	public boolean isEnabled() {
90
		
92
		if (!super.isEnabled()) 
91
		boolean result = super.isEnabled();
92
		if (!result) {
93
			return false;
93
			return false;
94
		}
94
95
		
96
		IResource[] resources = super.getSelectedResources();
95
		IResource[] resources = super.getSelectedResources();
97
		for (int i = 0; i < resources.length; i++) {
96
		for (int i = 0; i < resources.length; i++) {
98
			IResource resource = resources[i];
97
			IResource resource = resources[i];
99
			if (resource.getType() != IResource.PROJECT) {
98
			if (resource.getType() != IResource.PROJECT)
99
				return false;
100
			if (MapProject.getDefaultMapProject().getMapEntry((IProject) resource) == null)
100
				return false;
101
				return false;
101
			}
102
		}
102
		}
103
		
103
104
		return (getMapProject() != null && getMapProject().mapsAreLoaded());
104
		return true;
105
	}
105
	}
106
106
107
	/* (non-Javadoc)
107
	/* (non-Javadoc)
Lines 111-134 Link Here
111
		monitor.beginTask(null, 100 * resources.length);
111
		monitor.beginTask(null, 100 * resources.length);
112
		for (int i = 0; i < resources.length; i++) {
112
		for (int i = 0; i < resources.length; i++) {
113
			IResource resource = resources[i];
113
			IResource resource = resources[i];
114
			new ReplaceOperation(getTargetPart(), new IResource[] { resource }, getTag(resource), true).run(new SubProgressMonitor(monitor, 100));
114
			new ReplaceOperation(getTargetPart(), new IResource[] {resource}, getTag(resource), true).run(new SubProgressMonitor(monitor, 100));
115
		}
115
		}
116
		monitor.done();
116
		monitor.done();
117
	}
117
	}
118
	private MapProject getMapProject(){
119
		return MapProject.getDefaultMapProject();
120
	}
121
118
122
	/* (non-Javadoc)
119
	/* (non-Javadoc)
123
	 * @see org.eclipse.team.internal.ccvs.ui.actions.CVSAction#execute(org.eclipse.jface.action.IAction)
120
	 * @see org.eclipse.team.internal.ccvs.ui.actions.CVSAction#execute(org.eclipse.jface.action.IAction)
124
	 */
121
	 */
125
	protected void execute(IAction action) throws InvocationTargetException, InterruptedException {
122
	protected void execute(IAction action) throws InvocationTargetException, InterruptedException {
126
		
123
127
		final IResource[][] resources = new IResource[][] {null};
124
		final IResource[][] resources = new IResource[][] {null};
128
		run(new IRunnableWithProgress() {
125
		run(new IRunnableWithProgress() {
129
			public void run(IProgressMonitor monitor) throws InterruptedException, InvocationTargetException {
126
			public void run(IProgressMonitor monitor) throws InterruptedException, InvocationTargetException {
130
				try {
127
				try {
131
					monitor.beginTask(null, 100);					
128
					monitor.beginTask(null, 100);
132
					resources[0] = checkOverwriteOfDirtyResources(getSelectedResources(), new InfiniteSubProgressMonitor(monitor, 100));
129
					resources[0] = checkOverwriteOfDirtyResources(getSelectedResources(), new InfiniteSubProgressMonitor(monitor, 100));
133
				} catch (TeamException e) {
130
				} catch (TeamException e) {
134
					throw new InvocationTargetException(e);
131
					throw new InvocationTargetException(e);
Lines 137-145 Link Here
137
				}
134
				}
138
			}
135
			}
139
		}, false /* cancelable */, PROGRESS_BUSYCURSOR);
136
		}, false /* cancelable */, PROGRESS_BUSYCURSOR);
140
		
137
141
		if (resources[0] == null || resources[0].length == 0) return;
138
		if (resources[0] == null || resources[0].length == 0)
142
		
139
			return;
140
143
		run(new IRunnableWithProgress() {
141
		run(new IRunnableWithProgress() {
144
			public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
142
			public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
145
				try {
143
				try {
Lines 149-154 Link Here
149
				}
147
				}
150
			}
148
			}
151
		}, true, PROGRESS_DIALOG);
149
		}, true, PROGRESS_DIALOG);
152
		
150
153
	}
151
	}
154
}
152
}
(-)src/org/eclipse/releng/tools/MapFile.java (-58 / +198 lines)
Lines 1-58 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others.
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
7
 * 
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.releng.tools;
11
package org.eclipse.releng.tools;
12
12
13
import java.io.BufferedReader;
13
import java.io.*;
14
import java.io.IOException;
15
import java.io.InputStream;
16
import java.io.InputStreamReader;
17
import java.util.*;
14
import java.util.*;
15
import org.eclipse.core.resources.*;
16
import org.eclipse.core.runtime.*;
17
import org.eclipse.osgi.util.ManifestElement;
18
import org.osgi.framework.*;
18
19
19
import org.eclipse.core.resources.IFile;
20
/*
20
import org.eclipse.core.resources.IProject;
21
 * This class represents a build submission map file in the workspace.
21
import org.eclipse.core.resources.ResourcesPlugin;
22
 */
22
import org.eclipse.core.runtime.CoreException;
23
import org.eclipse.core.runtime.IStatus;
24
import org.eclipse.core.runtime.Status;
25
26
public class MapFile {
23
public class MapFile {
27
	
24
28
	public static final String MAP_FILE_EXTENSION = "map";
25
	public static final String MAP_FILE_EXTENSION = "map";
29
	
26
30
	protected IFile file;
27
	protected IFile file;
31
	protected MapEntry[] entries;
28
	// entries in the files...mixed Strings and MapEntry
32
	
29
	protected List entries = new ArrayList();
30
31
	/*
32
	 * Constructor for the class. Create a new map file on the given
33
	 * workspace file with the specified parent project.
34
	 */
33
	public MapFile(IFile aFile) throws CoreException {
35
	public MapFile(IFile aFile) throws CoreException {
34
		file = aFile;
36
		this.file = aFile;
35
		loadEntries();
37
		loadEntries();
36
	}
38
	}
37
	
39
38
	public IFile getFile(){
40
	/*
41
	 * Return the workspace file associated with this map file.
42
	 */
43
	public IFile getFile() {
39
		return file;
44
		return file;
40
	}
45
	}
41
	
46
47
	/*
48
	 * Load this map file's contents. Populate the entry list.
49
	 */
42
	protected void loadEntries() throws CoreException {
50
	protected void loadEntries() throws CoreException {
43
		InputStream inputStream = null;
51
		InputStream inputStream = null;
44
		List list = new ArrayList();		
45
46
		try {
52
		try {
47
			inputStream = file.getContents();
53
			inputStream = file.getContents();
48
			BufferedReader aReader = new BufferedReader(new InputStreamReader(
54
			BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
49
					inputStream));
55
			String lline = reader.readLine();
50
			String aLine = aReader.readLine();
56
			while (lline != null) {
51
			while (aLine != null) {
57
				MapEntry entry = MapEntry.parse(lline, this);
52
				if (isMapLine(aLine)) {
58
				entries.add(entry == null ? (Object) lline : entry);
53
					list.add(new MapEntry(aLine));
59
				lline = reader.readLine();
54
				}
55
				aLine = aReader.readLine();
56
			}
60
			}
57
		} catch (IOException e) {
61
		} catch (IOException e) {
58
			throw new CoreException(new Status(IStatus.ERROR, RelEngPlugin.ID, 0, "An I/O Error occurred process map file " + file.getFullPath().toString(), e));
62
			throw new CoreException(new Status(IStatus.ERROR, RelEngPlugin.ID, 0, "An I/O Error occurred process map file " + file.getFullPath().toString(), e));
Lines 65-117 Link Here
65
				}
69
				}
66
			}
70
			}
67
		}
71
		}
72
	}
68
73
69
		this.entries = (MapEntry[]) list.toArray(new MapEntry[list.size()]);
74
	/*
75
	 * Return a boolean value indicating whether or not this map file
76
	 * contains a valid map file entry for the given project.
77
	 */
78
	public boolean contains(IProject project) {
79
		return getMapEntry(project) != null;
70
	}
80
	}
71
	
81
72
	private boolean isMapLine(String line) {
82
	/*
73
		if (line.trim().length() == 0) return false;
83
	 * Return all of the map file entries registered for the given project.
74
		if (line.startsWith("!")) return false;
84
	 */
75
		return true;
85
	private List getAll(IProject project) {
76
	}
86
		List result = new ArrayList();
77
	
87
		if (entries == null || entries.size() == 0)
78
	public boolean contains(IProject project){
88
			return result;
79
		for(int j = 0;j < entries.length; j++){
89
		for (Iterator iter = entries.iterator(); iter.hasNext();) {
80
			if (entries[j].isMappedTo(project)){
90
			Object next = iter.next();
81
				return true;
91
			if (next instanceof String)
82
			}
92
				continue;
93
			MapEntry entry = (MapEntry) next;
94
			if (entry.getId().equals(project.getName()))
95
				result.add(entry);
83
		}
96
		}
84
		return false;
97
		return result;
85
	}
98
	}
86
99
100
	/*
101
	 * Return the map entry for the given project, or null
102
	 * if there isn't a match. Note that it only returns an entry
103
	 * if it is a member of this map file. 
104
	 */
87
	public MapEntry getMapEntry(IProject project) {
105
	public MapEntry getMapEntry(IProject project) {
88
		for(int j = 0;j < entries.length; j++){
106
		List mapEntries = getAll(project);
89
			if (entries[j].isMappedTo(project)){
107
		int count = mapEntries.size();
90
				return entries[j];
108
		if (mapEntries == null || count == 0)
109
			return null;
110
		if (count == 1)
111
			return (MapEntry) mapEntries.get(0);
112
113
		// get the version from the project
114
		Version projectVersion = getVersion(project);
115
		if (projectVersion == null)
116
			return null;
117
		// check for an exact match, also keep track if we have a null version entry
118
		MapEntry nullEntry = null;
119
		for (Iterator iter = mapEntries.iterator(); iter.hasNext();) {
120
			MapEntry entry = (MapEntry) iter.next();
121
			Version entryVersion = entry.getVersion() == null ? null : new Version(entry.getVersion());
122
			// we have an exact match
123
			if (projectVersion.equals(entryVersion))
124
				return entry;
125
			if (entryVersion == null)
126
				nullEntry = entry;
127
		}
128
		// we didn't have an exact match but there was an entry in the file
129
		// with a null version so return it
130
		if (nullEntry != null)
131
			return nullEntry;
132
		// otherwise try and guess the best version
133
		return bestMatch(projectVersion, mapEntries);
134
	}
135
136
	/*
137
	 * Try and determine the version of the given project by looking
138
	 * in its manifest file.
139
	 */
140
	private Version getVersion(IProject project) {
141
		// sort and pick the best based on version
142
		// get the version from the project
143
		IFile manifest = project.getFile(new Path("META-INF/MANIFEST.MF"));
144
		// we can't find the manifest file so we can't determine the version in the workspace
145
		// TODO we could try and parse the plugin.xml if one exists
146
		if (!manifest.exists())
147
			return null;
148
		String versionString = null;
149
		try {
150
			Map map = ManifestElement.parseBundleManifest(manifest.getContents(), null);
151
			versionString = (String) map.get(Constants.BUNDLE_VERSION);
152
		} catch (IOException e) {
153
			e.printStackTrace();
154
			return null;
155
		} catch (BundleException e) {
156
			e.printStackTrace();
157
			return null;
158
		} catch (CoreException e) {
159
			e.printStackTrace();
160
			return null;
161
		}
162
		if (versionString == null)
163
			return null;
164
		Version projectVersion = new Version(versionString);
165
		// TODO for now we strip off the qualifier
166
		return new Version(projectVersion.getMajor(), projectVersion.getMinor(), projectVersion.getMicro(), null);
167
	}
168
169
	/*
170
	 * Return the best map file entry match for the given version.
171
	 */
172
	private MapEntry bestMatch(Version version, List mapEntries) {
173
		MapEntry result = null;
174
		Version resultVersion = null;
175
		for (Iterator iter = mapEntries.iterator(); iter.hasNext();) {
176
			MapEntry entry = (MapEntry) iter.next();
177
			String versionString = entry.getVersion();
178
			if (versionString == null)
179
				return entry;
180
			Version entryVersion = new Version(versionString);
181
			// we require at least...
182
			int comparison = entryVersion.compareTo(version);
183
			if (comparison < 0)
184
				continue;
185
			// we should have already handled the equals case but
186
			// in case we didn't...
187
			if (comparison == 0)
188
				return entry;
189
			// grab the latest version
190
			if (result == null || entryVersion.compareTo(resultVersion) > 0) {
191
				result = entry;
192
				resultVersion = entryVersion;
193
				continue;
91
			}
194
			}
92
		}
195
		}
93
		return null;
196
		return result;
94
	}
197
	}
95
198
199
	/*
200
	 * Return an array of accessible workspace projects for this map file.
201
	 */
96
	public IProject[] getAccessibleProjects() {
202
	public IProject[] getAccessibleProjects() {
203
		if (entries == null || entries.size() == 0)
204
			return null;
97
		Set list = new HashSet();
205
		Set list = new HashSet();
98
		IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
206
		IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
99
		if(entries == null || entries.length ==0) return null;
100
		for (int i = 0; i < projects.length; i++) {
207
		for (int i = 0; i < projects.length; i++) {
101
			IProject project = projects[i];
208
			IProject workspaceProject = projects[i];
102
			if (project.isAccessible()) {
209
			if (workspaceProject.isAccessible()) {
103
				for (int j = 0; j < entries.length; j++){
210
				MapEntry entry = getMapEntry(workspaceProject);
104
					if (entries[j].isMappedTo(project)) {
211
				if (entry != null)
105
						list.add(project);
212
					list.add(workspaceProject);
106
					}
107
				}
108
			}
213
			}
109
		}
214
		}
110
		return (IProject[])list.toArray(new IProject[list.size()]);
215
		return (IProject[]) list.toArray(new IProject[list.size()]);
111
	}
216
	}
112
217
218
	/* (non-Javadoc)
219
	 * @see java.lang.Object#equals(java.lang.Object)
220
	 */
221
	public boolean equals(Object obj) {
222
		if (!(obj instanceof MapFile))
223
			return false;
224
		return getFile().equals(((MapFile) obj).getFile());
225
	}
226
227
	/* (non-Javadoc)
228
	 * @see java.lang.Object#hashCode()
229
	 */
230
	public int hashCode() {
231
		return file.hashCode();
232
	}
233
234
	/*
235
	 * Return the simple name of this map file's workspace file.
236
	 */
113
	public String getName() {
237
	public String getName() {
114
		return file.getName();
238
		return file.getName();
115
	}
239
	}
116
240
241
	/*
242
	 * Return a string representation of this map file.
243
	 */
244
	public String getContents() {
245
		StringBuffer buffer = new StringBuffer();
246
		for (Iterator iter = entries.iterator(); iter.hasNext();) {
247
			Object obj = iter.next();
248
			if (obj instanceof String)
249
				buffer.append(obj);
250
			else
251
				buffer.append(((MapEntry) obj).getMapString());
252
			if (iter.hasNext())
253
				buffer.append(System.getProperty("line.separator")); //$NON-NLS-1$
254
		}
255
		return buffer.toString();
256
	}
117
}
257
}
(-)src/org/eclipse/releng/tools/ProjectSelectionPage.java (-81 / +103 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others.
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 11-17 Link Here
11
package org.eclipse.releng.tools;
11
package org.eclipse.releng.tools;
12
12
13
import java.util.*;
13
import java.util.*;
14
15
import org.eclipse.core.resources.IProject;
14
import org.eclipse.core.resources.IProject;
16
import org.eclipse.core.resources.ResourcesPlugin;
15
import org.eclipse.core.resources.ResourcesPlugin;
17
import org.eclipse.jface.dialogs.IDialogSettings;
16
import org.eclipse.jface.dialogs.IDialogSettings;
Lines 30-36 Link Here
30
import org.eclipse.ui.model.WorkbenchContentProvider;
29
import org.eclipse.ui.model.WorkbenchContentProvider;
31
import org.eclipse.ui.model.WorkbenchLabelProvider;
30
import org.eclipse.ui.model.WorkbenchLabelProvider;
32
31
33
34
/**
32
/**
35
 * This class extends <code>WizardPage<code> class and use a <code>CheckboxTreeViewer<code> to 
33
 * This class extends <code>WizardPage<code> class and use a <code>CheckboxTreeViewer<code> to 
36
 * display selectable items. 
34
 * display selectable items. 
Lines 39-77 Link Here
39
	private CheckboxTreeViewer viewer;
37
	private CheckboxTreeViewer viewer;
40
	private IDialogSettings settings;
38
	private IDialogSettings settings;
41
	private Button compareButton;
39
	private Button compareButton;
42
	private boolean compareButtonChecked;	
40
	private boolean compareButtonChecked;
43
	private String SELECTED_ITEMS_KEY = Messages.getString("ProjectSelectionPage.0"); //$NON-NLS-1$
41
	private String SELECTED_ITEMS_KEY = Messages.getString("ProjectSelectionPage.0"); //$NON-NLS-1$
44
	private String COMPARE_BUTTON_KEY = Messages.getString("ProjectSelectionPage.1"); //$NON-NLS-1$
42
	private String COMPARE_BUTTON_KEY = Messages.getString("ProjectSelectionPage.1"); //$NON-NLS-1$
45
	private MapProject mapProject;
43
	private MapProject mapProject;
46
44
47
	private class MapFileLabelProvider extends LabelProvider {
45
	private class MapFileLabelProvider extends LabelProvider {
48
		WorkbenchLabelProvider provider = new WorkbenchLabelProvider();
46
		WorkbenchLabelProvider provider = new WorkbenchLabelProvider();
47
49
		public String getText(Object element) {
48
		public String getText(Object element) {
50
			if (element instanceof MapFile) {
49
			if (element instanceof MapFile) {
51
				return ((MapFile)element).getName();
50
				return ((MapFile) element).getName();
52
			}
51
			}
53
			return provider.getText(element);
52
			return provider.getText(element);
54
		}
53
		}
54
55
		public Image getImage(Object element) {
55
		public Image getImage(Object element) {
56
			if (element instanceof MapFile) {
56
			if (element instanceof MapFile) {
57
				return provider.getImage(((MapFile)element).getFile());
57
				return provider.getImage(((MapFile) element).getFile());
58
			}
58
			}
59
			return provider.getImage(element);
59
			return provider.getImage(element);
60
		}
60
		}
61
61
		public void dispose() {
62
		public void dispose() {
62
			provider.dispose();
63
			provider.dispose();
63
			super.dispose();
64
			super.dispose();
64
		}
65
		}
65
	}
66
	}
66
	
67
67
	public ProjectSelectionPage(String pageName, 
68
	public ProjectSelectionPage(String pageName, String title, IDialogSettings settings, ImageDescriptor image) {
68
			String title, 
69
			IDialogSettings settings, 
70
			ImageDescriptor image) {
71
		super(pageName, title, image);
69
		super(pageName, title, image);
72
		this.settings = settings;
70
		this.settings = settings;
73
	}
71
	}
74
	
72
75
	/*
73
	/*
76
	 * (non-Javadoc)
74
	 * (non-Javadoc)
77
	 * 
75
	 * 
Lines 79-110 Link Here
79
	 */
77
	 */
80
	public void createControl(Composite parent) {
78
	public void createControl(Composite parent) {
81
		Font font = parent.getFont();
79
		Font font = parent.getFont();
82
		
80
83
		Composite topContainer = new Composite(parent, SWT.NONE);
81
		Composite topContainer = new Composite(parent, SWT.NONE);
84
		topContainer.setLayout(new GridLayout());
82
		topContainer.setLayout(new GridLayout());
85
		topContainer.setLayoutData(new GridData(GridData.FILL_BOTH));
83
		topContainer.setLayoutData(new GridData(GridData.FILL_BOTH));
86
		
84
87
		Label label = new Label(topContainer, SWT.HORIZONTAL);
85
		Label label = new Label(topContainer, SWT.HORIZONTAL);
88
		label.setFont(font);
86
		label.setFont(font);
89
		label.setText(Messages.getString("ProjectSelectionPage.2")); //$NON-NLS-1$
87
		label.setText(Messages.getString("ProjectSelectionPage.2")); //$NON-NLS-1$
90
		
88
91
		viewer = new ContainerCheckedTreeViewer(topContainer, SWT.SINGLE | SWT.H_SCROLL
89
		viewer = new ContainerCheckedTreeViewer(topContainer, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
92
				| SWT.V_SCROLL | SWT.BORDER);
90
		GridData gd = new GridData(GridData.FILL_BOTH);
93
		GridData gd= new GridData(GridData.FILL_BOTH);
91
		gd.heightHint = viewer.getTree().getItemHeight() * 15;
94
		gd.heightHint= viewer.getTree().getItemHeight() * 15;
95
		viewer.getTree().setLayoutData(gd);
92
		viewer.getTree().setLayoutData(gd);
96
		viewer.getTree().setFont(font);
93
		viewer.getTree().setFont(font);
97
		viewer.setLabelProvider(new MapFileLabelProvider());
94
		viewer.setLabelProvider(new MapFileLabelProvider());
98
		viewer.setContentProvider(getContentProvider());
95
		viewer.setContentProvider(getContentProvider());
99
		viewer.setInput(mapProject);
96
		viewer.setInput(mapProject);
100
		viewer.expandAll();
97
		viewer.expandAll();
101
		viewer.addCheckStateListener(new ICheckStateListener(){
98
		viewer.addCheckStateListener(new ICheckStateListener() {
102
			public void checkStateChanged(CheckStateChangedEvent event) {
99
			public void checkStateChanged(CheckStateChangedEvent event) {
103
				updatePageComplete();				
100
				updatePageComplete();
104
			}
101
			}
105
		});
102
		});
106
		
103
107
		compareButton = new Button(topContainer,SWT.CHECK);
104
		compareButton = new Button(topContainer, SWT.CHECK);
108
		compareButton.setText(Messages.getString("ProjectSelectionPage.3")); //$NON-NLS-1$
105
		compareButton.setText(Messages.getString("ProjectSelectionPage.3")); //$NON-NLS-1$
109
		compareButton.setFont(font);
106
		compareButton.setFont(font);
110
		compareButton.addSelectionListener(new SelectionAdapter() {
107
		compareButton.addSelectionListener(new SelectionAdapter() {
Lines 112-139 Link Here
112
				compareButtonChecked = compareButton.getSelection();
109
				compareButtonChecked = compareButton.getSelection();
113
			}
110
			}
114
		});
111
		});
115
		
112
116
		initialize();
113
		initialize();
117
		setControl(topContainer);
114
		setControl(topContainer);
118
	}
115
	}
116
119
	/**
117
	/**
120
	 * Returns the content provider for the viewer
118
	 * Returns the content provider for the viewer
121
	 */
119
	 */
122
	private IContentProvider getContentProvider() {
120
	private IContentProvider getContentProvider() {
123
		return new WorkbenchContentProvider() {
121
		return new WorkbenchContentProvider() {
124
			public Object[] getChildren(Object parentElement) {
122
			public Object[] getChildren(Object parentElement) {
123
125
				if (parentElement instanceof MapProject) {
124
				if (parentElement instanceof MapProject) {
126
					return mapProject.getValidMapFiles();								
125
					MapFile[] files = mapProject.getValidMapFiles();
127
				}
126
					if (files == null)
128
				if (parentElement instanceof MapFile) {
127
						return null;
129
					return ((MapFile)parentElement).getAccessibleProjects();
128
					Set list = new TreeSet(new Comparator() {
129
						public int compare(Object o1, Object o2) {
130
							String m1 = ((MapFile) o1).getName().toLowerCase();
131
							String m2 = ((MapFile) o2).getName().toLowerCase();
132
							return m1.compareTo(m2);
133
						}
134
					});
135
					list.addAll(Arrays.asList(files));
136
					return list.toArray();
137
				} else if (parentElement instanceof MapFile) {
138
					IProject[] projects = ((MapFile) parentElement).getAccessibleProjects();
139
					if (projects == null)
140
						return null;
141
					Set list = new TreeSet(new Comparator() {
142
						public int compare(Object o1, Object o2) {
143
							String p1 = ((IProject) o1).getName().toLowerCase();
144
							String p2 = ((IProject) o2).getName().toLowerCase();
145
							return p1.compareTo(p2);
146
						}
147
					});
148
					list.addAll(Arrays.asList(projects));
149
					return list.toArray();
130
				}
150
				}
131
				return null;
151
				return null;
132
			}
152
			}
133
			
153
134
			public boolean hasChildren(Object element) {
154
			public boolean hasChildren(Object element) {
135
				if (element instanceof MapFile) {
155
				if (element instanceof MapFile) {
136
					return ((MapFile)element).getAccessibleProjects().length > 0;
156
					return ((MapFile) element).getAccessibleProjects().length > 0;
137
				}
157
				}
138
				return false;
158
				return false;
139
			}
159
			}
Lines 143-214 Link Here
143
	/**
163
	/**
144
	 * Returns all the checked items if they are IProject 
164
	 * Returns all the checked items if they are IProject 
145
	 */
165
	 */
146
	public IProject[] getCheckedProjects(){
166
	public IProject[] getCheckedProjects() {
147
		ArrayList projectsToRelease = new ArrayList();
167
		ArrayList projectsToRelease = new ArrayList();
148
		Object[] obj = viewer.getCheckedElements();
168
		Object[] obj = viewer.getCheckedElements();
149
		if (obj == null)return null;
169
		if (obj == null)
150
		for(int i = 0; i < obj.length; i++){
170
			return null;
171
		for (int i = 0; i < obj.length; i++) {
151
			if (obj[i] instanceof IProject)
172
			if (obj[i] instanceof IProject)
152
				projectsToRelease.add(obj[i]); 
173
				projectsToRelease.add(obj[i]);
153
		}
174
		}
154
		return (IProject[])projectsToRelease.toArray(new IProject[projectsToRelease.size()]);
175
		return (IProject[]) projectsToRelease.toArray(new IProject[projectsToRelease.size()]);
155
	}	
176
	}
156
	
177
157
	private void readProjectSettings(){
178
	private void readProjectSettings() {
158
		if( settings == null) return;
179
		if (settings == null)
159
		if(settings.getArray(SELECTED_ITEMS_KEY) != null){
180
			return;
181
		if (settings.getArray(SELECTED_ITEMS_KEY) != null) {
160
			ArrayList nameList = new ArrayList(Arrays.asList(settings.getArray(SELECTED_ITEMS_KEY)));
182
			ArrayList nameList = new ArrayList(Arrays.asList(settings.getArray(SELECTED_ITEMS_KEY)));
161
			if(nameList != null){
183
			if (nameList != null) {
162
				Iterator iter = nameList.iterator();
184
				Iterator iter = nameList.iterator();
163
				while(iter.hasNext()){
185
				while (iter.hasNext()) {
164
					String name = (String)iter.next();
186
					String name = (String) iter.next();
165
					IProject project = getProjectWithName(name);
187
					IProject project = getProjectWithName(name);
166
					if(project != null){
188
					if (project != null) {
167
						viewer.setChecked(project,true);
189
						viewer.setChecked(project, true);
168
					}					
190
					}
169
				}
191
				}
170
			}
192
			}
171
		}
193
		}
172
	}
194
	}
173
	
195
174
	private void initCompareEnablement(){
196
	private void initCompareEnablement() {
175
		if( settings == null || settings.get(COMPARE_BUTTON_KEY) == null) {
197
		if (settings == null || settings.get(COMPARE_BUTTON_KEY) == null) {
176
			compareButton.setSelection( true);
198
			compareButton.setSelection(true);
177
			compareButtonChecked = true;
199
			compareButtonChecked = true;
178
			return;
200
			return;
179
		}else{
201
		} else {
180
			boolean b = settings.getBoolean(COMPARE_BUTTON_KEY);
202
			boolean b = settings.getBoolean(COMPARE_BUTTON_KEY);
181
			compareButton.setSelection(b);
203
			compareButton.setSelection(b);
182
			compareButtonChecked = b;
204
			compareButtonChecked = b;
183
		}
205
		}
184
	}
206
	}
185
	
207
186
	/**
208
	/**
187
	 * Save the checked items and the checkbox options to dialog settings
209
	 * Save the checked items and the checkbox options to dialog settings
188
	 */
210
	 */
189
	public void saveSettings(){
211
	public void saveSettings() {
190
		Object[] obj = viewer.getCheckedElements();
212
		Object[] obj = viewer.getCheckedElements();
191
		ArrayList names = new ArrayList();
213
		ArrayList names = new ArrayList();
192
		for (int i = 0; i < obj.length; i++){
214
		for (int i = 0; i < obj.length; i++) {
193
			if(obj[i] instanceof IProject){
215
			if (obj[i] instanceof IProject) {
194
				names.add(((IProject)obj[i]).getName());
216
				names.add(((IProject) obj[i]).getName());
195
			}
217
			}
196
		}
218
		}
197
		settings.put(SELECTED_ITEMS_KEY, (String[])names.toArray(new String[names.size()]));
219
		settings.put(SELECTED_ITEMS_KEY, (String[]) names.toArray(new String[names.size()]));
198
		settings.put(COMPARE_BUTTON_KEY, compareButtonChecked);
220
		settings.put(COMPARE_BUTTON_KEY, compareButtonChecked);
199
	}
221
	}
200
	
222
201
	private void initialize(){
223
	private void initialize() {
202
		initCheckedProjects();
224
		initCheckedProjects();
203
		initCompareEnablement();
225
		initCompareEnablement();
204
		updatePageComplete();
226
		updatePageComplete();
205
	}
227
	}
206
	
228
207
	private void initCheckedProjects(){
229
	private void initCheckedProjects() {
208
		IProject[] p = ((ReleaseWizard)getWizard()).getPreSelectedProjects( );
230
		IProject[] p = ((ReleaseWizard) getWizard()).getPreSelectedProjects();
209
		if(p != null){
231
		if (p != null) {
210
			viewer.setCheckedElements(p);
232
			viewer.setCheckedElements(p);
211
		}else{
233
		} else {
212
			readProjectSettings();
234
			readProjectSettings();
213
		}
235
		}
214
	}
236
	}
Lines 216-263 Link Here
216
	/**
238
	/**
217
	 * Called by <code>readSettings()<code> to return the project associated with the given name
239
	 * Called by <code>readSettings()<code> to return the project associated with the given name
218
	 */
240
	 */
219
	private IProject getProjectWithName(String name){
241
	private IProject getProjectWithName(String name) {
220
		IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(name);
242
		IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(name);
221
		if(project.exists() && project.isAccessible())
243
		if (project.exists() && project.isAccessible())
222
			return project;
244
			return project;
223
		return null;
245
		return null;
224
	}
246
	}
225
247
226
	public boolean isCompareButtonChecked(){
248
	public boolean isCompareButtonChecked() {
227
		return compareButtonChecked;
249
		return compareButtonChecked;
228
	}
250
	}
229
	
251
230
	/**
252
	/**
231
	 *This page will not complete until at least one project is checked
253
	 *This page will not complete until at least one project is checked
232
	 */
254
	 */
233
	private void updatePageComplete(){
255
	private void updatePageComplete() {
234
		Object[] obj = viewer.getCheckedElements();
256
		Object[] obj = viewer.getCheckedElements();
235
		if(obj.length > 0){
257
		if (obj.length > 0) {
236
			for(int i = 0; i < obj.length; i++){
258
			for (int i = 0; i < obj.length; i++) {
237
				//Exclude the situation that an empty shown map file is selected
259
				//Exclude the situation that an empty shown map file is selected
238
				if(obj[i] instanceof IProject){
260
				if (obj[i] instanceof IProject) {
239
					setPageComplete(true);
261
					setPageComplete(true);
240
					break;
262
					break;
241
				}
263
				}
242
			}
264
			}
243
		}
265
		} else {
244
		else{
245
			setPageComplete(false);
266
			setPageComplete(false);
246
		}
267
		}
247
	}
268
	}
248
	
269
249
	private CheckboxTreeViewer getViewer(){
270
	private CheckboxTreeViewer getViewer() {
250
		return viewer;
271
		return viewer;
251
	}
272
	}
252
	
273
253
	public void setSelection(IProject[] projects) {
274
	public void setSelection(IProject[] projects) {
254
		if(projects != null && projects.length > 0){
275
		if (projects != null && projects.length > 0) {
255
			getViewer().setCheckedElements(projects);	
276
			getViewer().setCheckedElements(projects);
256
		}
277
		}
257
	}
278
	}
258
	public void updateMapProject(MapProject m){
279
280
	public void updateMapProject(MapProject m) {
259
		mapProject = m;
281
		mapProject = m;
260
		if(viewer != null){
282
		if (viewer != null) {
261
			viewer.setInput(mapProject);
283
			viewer.setInput(mapProject);
262
		}
284
		}
263
	}
285
	}
(-)src/org/eclipse/releng/tools/LoadMap.java (-12 / +13 lines)
Lines 1-10 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others.
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
7
 * 
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
10
 *******************************************************************************/
Lines 69-80 Link Here
69
		List allStrings = new ArrayList();
69
		List allStrings = new ArrayList();
70
		for (int i = 0; i < mapFiles.length; i++) {
70
		for (int i = 0; i < mapFiles.length; i++) {
71
			IResource resource = mapFiles[i];
71
			IResource resource = mapFiles[i];
72
			String[] referenceStrings = readReferenceStrings((IFile)resource);
72
			String[] referenceStrings = readReferenceStrings((IFile) resource);
73
			allStrings.addAll(Arrays.asList(referenceStrings));
73
			allStrings.addAll(Arrays.asList(referenceStrings));
74
		}
74
		}
75
		return (String[]) allStrings.toArray(new String[allStrings.size()]);
75
		return (String[]) allStrings.toArray(new String[allStrings.size()]);
76
	}
76
	}
77
	
77
78
	/**
78
	/**
79
	 * Method readReferenceStrings.
79
	 * Method readReferenceStrings.
80
	 * @param file
80
	 * @param file
Lines 88-97 Link Here
88
				String line = reader.readLine();
88
				String line = reader.readLine();
89
				List references = new ArrayList();
89
				List references = new ArrayList();
90
				while (line != null) {
90
				while (line != null) {
91
					String referenceString = new MapEntry(line).getReferenceString();
91
					MapEntry entry = MapEntry.parse(line, null);
92
					if (referenceString != null)  {
92
					if (entry != null && entry.getReferenceString() != null)
93
						references.add(referenceString);
93
						references.add(entry.getReferenceString());
94
					}
95
					line = reader.readLine();
94
					line = reader.readLine();
96
				}
95
				}
97
				return (String[]) references.toArray(new String[references.size()]);
96
				return (String[]) references.toArray(new String[references.size()]);
Lines 103-119 Link Here
103
		}
102
		}
104
	}
103
	}
105
104
106
107
	/**
105
	/**
108
	 * @see org.eclipse.team.internal.ui.actions.TeamAction#isEnabled()
106
	 * @see org.eclipse.team.internal.ui.actions.TeamAction#isEnabled()
109
	 */
107
	 */
110
	public boolean isEnabled() {
108
	public boolean isEnabled() {
111
		IResource[] resources = getSelectedResources();
109
		IResource[] resources = getSelectedResources();
112
		if (resources.length == 0) return false;
110
		if (resources.length == 0)
111
			return false;
113
		for (int i = 0; i < resources.length; i++) {
112
		for (int i = 0; i < resources.length; i++) {
114
			IResource resource = resources[i];
113
			IResource resource = resources[i];
115
			if (resource.getType() != IResource.FILE) return false;
114
			if (resource.getType() != IResource.FILE)
116
			if (!resource.getFileExtension().equals("map")) return false;
115
				return false;
116
			if (!resource.getFileExtension().equals("map"))
117
				return false;
117
		}
118
		}
118
		return true;
119
		return true;
119
	}
120
	}
(-)src/org/eclipse/releng/tools/MapProject.java (-86 / +119 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others.
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 9-17 Link Here
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.releng.tools;
11
package org.eclipse.releng.tools;
12
12
import java.lang.reflect.InvocationTargetException;
13
import java.lang.reflect.InvocationTargetException;
13
import java.util.*;
14
import java.util.*;
14
15
import org.eclipse.core.resources.*;
15
import org.eclipse.core.resources.*;
16
import org.eclipse.core.runtime.CoreException;
16
import org.eclipse.core.runtime.CoreException;
17
import org.eclipse.core.runtime.IProgressMonitor;
17
import org.eclipse.core.runtime.IProgressMonitor;
Lines 21-32 Link Here
21
import org.eclipse.team.internal.ccvs.ui.operations.CommitOperation;
21
import org.eclipse.team.internal.ccvs.ui.operations.CommitOperation;
22
import org.eclipse.team.internal.ccvs.ui.operations.RepositoryProviderOperation;
22
import org.eclipse.team.internal.ccvs.ui.operations.RepositoryProviderOperation;
23
23
24
/*
25
 * This class represents a workspace project which contains map files.
26
 */
24
public class MapProject implements IResourceChangeListener {
27
public class MapProject implements IResourceChangeListener {
25
	
28
26
	private static MapProject mapProject = null;
29
	private static MapProject mapProject;
27
	private IProject project;
30
	private IProject project;
28
	private MapFile[] mapFiles;
31
	private MapFile[] mapFiles;
29
	
32
30
	/**
33
	/**
31
	 * Return the default map project (org.eclipse.releng) or
34
	 * Return the default map project (org.eclipse.releng) or
32
	 * <code>null</code> if the project does not exist or there
35
	 * <code>null</code> if the project does not exist or there
Lines 34-40 Link Here
34
	 * will be logged.
37
	 * will be logged.
35
	 * @return the default map project
38
	 * @return the default map project
36
	 */
39
	 */
37
	public static MapProject getDefaultMapProject(){		
40
	public static MapProject getDefaultMapProject() {
38
		if (mapProject == null) {
41
		if (mapProject == null) {
39
			IProject project = getProjectFromWorkspace();
42
			IProject project = getProjectFromWorkspace();
40
			try {
43
			try {
Lines 43-52 Link Here
43
				RelEngPlugin.log(e);
46
				RelEngPlugin.log(e);
44
			}
47
			}
45
		}
48
		}
46
		
47
		return mapProject;
49
		return mapProject;
48
	}
50
	}
49
	
51
50
	private static IProject getProjectFromWorkspace() {
52
	private static IProject getProjectFromWorkspace() {
51
		IWorkspace workspace = ResourcesPlugin.getWorkspace();
53
		IWorkspace workspace = ResourcesPlugin.getWorkspace();
52
		IWorkspaceRoot root = workspace.getRoot();
54
		IWorkspaceRoot root = workspace.getRoot();
Lines 54-201 Link Here
54
		return project;
56
		return project;
55
	}
57
	}
56
58
59
	/*
60
	 * Create a new map project based on the given workspace project.
61
	 */
57
	public MapProject(IProject p) throws CoreException {
62
	public MapProject(IProject p) throws CoreException {
58
		this.project = p;
63
		this.project = p;
59
		ResourcesPlugin.getWorkspace().addResourceChangeListener(this, IResourceChangeEvent.POST_CHANGE);
64
		ResourcesPlugin.getWorkspace().addResourceChangeListener(this, IResourceChangeEvent.POST_CHANGE);
60
		loadMapFiles();
65
		loadMapFiles();
61
	}
66
	}
62
67
68
	/*
69
	 * Return the workspace project represented by this map project.
70
	 */
63
	public IProject getProject() {
71
	public IProject getProject() {
64
		return project;
72
		return project;
65
	}
73
	}
66
	
74
67
	public void setProject(IProject p){
75
	/*
68
		this.project = p;
76
	 * Return the map file which contains the entry for this project.
69
	}
77
	 */
70
	
78
	private MapFile getMapFile(IProject p) {
71
	private MapFile getMapFile(IProject p){
79
		MapEntry entry = getMapEntry(p);
72
		for (int i = 0; i< mapFiles.length; i++){
80
		return entry == null ? null : entry.getFile();
73
			if (mapFiles[i].contains(p)) {
74
				return mapFiles[i];
75
			}
76
		}		
77
		return null;
78
	}
81
	}
79
	
82
80
	/**
83
	/*
81
	 * Return the MapEntry for the given project
84
	 * Return the MapEntry for the given project. Do a lookup in the registry.
82
	 * @param string
83
	 * @param string1
84
	 */
85
	 */
85
	public MapEntry getMapEntry(IProject p) {
86
	public MapEntry getMapEntry(IProject p) {
86
		MapFile file = getMapFile(p);
87
		if (mapFiles == null)
87
		if (file != null) {
88
			return null;
88
			return file.getMapEntry(p);
89
		for (int i = 0; i < mapFiles.length; i++) {
90
			MapEntry result = mapFiles[i].getMapEntry(p);
91
			if (result != null)
92
				return result;
89
		}
93
		}
90
		return null;
94
		return null;
91
	}
95
	}
92
96
93
	public boolean mapsAreLoaded() {
97
	/*
94
		return project.exists();
98
	 * Return an array of the valid map files in this project.
95
	}
99
	 */
96
 
100
	public MapFile[] getValidMapFiles() {
97
	public MapFile[] getValidMapFiles(){
98
		List list = new ArrayList();
101
		List list = new ArrayList();
99
		for (int i = 0; i <mapFiles.length; i++){
102
		for (int i = 0; i < mapFiles.length; i++) {
100
			IProject[] projects = mapFiles[i].getAccessibleProjects(); 
103
			IProject[] projects = mapFiles[i].getAccessibleProjects();
101
			if( projects!= null && projects.length > 0){
104
			if (projects != null && projects.length > 0) {
102
				list.add(mapFiles[i]);
105
				list.add(mapFiles[i]);
103
			}
106
			}
104
		}
107
		}
105
		return (MapFile[])list.toArray(new MapFile[list.size()]);
108
		return (MapFile[]) list.toArray(new MapFile[list.size()]);
106
	}
109
	}
107
	
110
111
	public MapFile[] getMapFiles() {
112
		return mapFiles;
113
	}
114
108
	/**
115
	/**
116
	 * Update the map file entry for the given workspace project, with the specified tag.
117
	 * 
109
	 * @param aProject The map entry of the specified project will be changed to the specified tag
118
	 * @param aProject The map entry of the specified project will be changed to the specified tag
110
	 * @param tag The specified tag
119
	 * @param tag The specified tag
111
	 * @return returns if no map file having such a map entry is found 
112
	 */
120
	 */
113
	public void updateFile(IProject aProject, String tag) throws CoreException {
121
	public void updateFile(IProject aProject, String tag) throws CoreException {
114
		MapFile aFile = getMapFile(aProject);
122
		MapFile aFile = getMapFile(aProject);
115
		if (aFile == null)return;
123
		if (aFile == null)
124
			return;
116
		MapContentDocument changed = new MapContentDocument(aFile);
125
		MapContentDocument changed = new MapContentDocument(aFile);
117
		changed.updateTag(aProject, tag);
126
		changed.updateTag(aProject, tag);
118
		if (changed.isChanged()) {
127
		if (changed.isChanged()) {
119
			aFile.getFile().setContents(changed.getContents(), IFile.KEEP_HISTORY, null);
128
			aFile.getFile().setContents(changed.getContents(), IResource.KEEP_HISTORY, null);
120
		}
129
		}
121
	}
130
	}
122
	
131
123
	public void commitMapProject(String comment, IProgressMonitor  monitor) throws CoreException{
132
	/*
133
	 * Commit our changes to CVS.
134
	 */
135
	public void commitMapProject(String comment, IProgressMonitor monitor) throws CoreException {
124
		try {
136
		try {
125
			new CommitOperation(null, RepositoryProviderOperation.asResourceMappers(new IResource[] { project }), new Command.LocalOption[0], comment).run(monitor);
137
			new CommitOperation(null, RepositoryProviderOperation.asResourceMappers(new IResource[] {project}), new Command.LocalOption[0], comment).run(monitor);
126
		} catch (InvocationTargetException e) {
138
		} catch (InvocationTargetException e) {
127
			throw TeamException.asTeamException(e);
139
			throw TeamException.asTeamException(e);
128
		} catch (InterruptedException e) {
140
		} catch (InterruptedException e) {
129
			// Ignore;
141
			// Ignore;
130
		}
142
		}
131
	}
143
	}
132
	
144
133
	public MapFile[] getMapFilesFor(IProject[] projects){
145
	/*
134
		Set alist = new HashSet();		
146
	 * Return an array with the map files for the given projects.
135
		for(int i = 0; i<projects.length; i++){
147
	 */
148
	public MapFile[] getMapFilesFor(IProject[] projects) {
149
		Set alist = new HashSet();
150
		for (int i = 0; i < projects.length; i++) {
136
			MapFile aMapFile = getMapFile(projects[i]);
151
			MapFile aMapFile = getMapFile(projects[i]);
137
			alist.add(aMapFile);
152
			alist.add(aMapFile);
138
		}
153
		}
139
		return (MapFile[])alist.toArray(new MapFile[alist.size()]);
154
		return (MapFile[]) alist.toArray(new MapFile[alist.size()]);
140
	}
155
	}
141
156
142
	/**
157
	/**
143
	 * Get the tags for the given projects. If no tag is found
158
	 * Get the tags for the given projects. If no tag is found
144
	 * for whatever reason, HEAD is used.
159
	 * for whatever reason, HEAD is used.
160
	 * 
145
	 * @param projects
161
	 * @param projects
146
	 * @return
147
	 */
162
	 */
148
	public CVSTag[] getTagsFor(IProject[] projects){
163
	public CVSTag[] getTagsFor(IProject[] projects) {
149
		if(projects == null || projects.length == 0)return null;
164
		if (projects == null || projects.length == 0)
165
			return null;
150
		CVSTag[] tags = new CVSTag[projects.length];
166
		CVSTag[] tags = new CVSTag[projects.length];
151
		for (int i = 0; i < tags.length; i++){
167
		for (int i = 0; i < tags.length; i++) {
152
			MapEntry entry = getMapEntry(projects[i]);
168
			MapEntry entry = getMapEntry(projects[i]);
153
			if (entry == null) tags[i] = CVSTag.DEFAULT;
169
			if (entry == null)
154
			else tags[i] = entry.getTag();		
170
				tags[i] = CVSTag.DEFAULT;
171
			else
172
				tags[i] = entry.getTag();
155
		}
173
		}
156
		return tags;
174
		return tags;
157
	}
175
	}
176
158
	/**
177
	/**
159
	 * Deregister the IResourceChangeListner. It is reserved for use in the future. It is never called
178
	 * Unregister the IResourceChangeListner. It is reserved for use in the future. It is never called
160
	 * for now
179
	 * for now.
161
	 */
180
	 */
162
	public void dispose(){
181
	public void dispose() {
163
		ResourcesPlugin.getWorkspace().removeResourceChangeListener(this);
182
		ResourcesPlugin.getWorkspace().removeResourceChangeListener(this);
164
	}
183
	}
165
	
184
166
	/**
185
	/**
167
	 * @see IResourceChangeListener#resourceChanged(IResourceChangeEvent)
186
	 * @see IResourceChangeListener#resourceChanged(IResourceChangeEvent)
168
	 */
187
	 */
169
	public void resourceChanged(IResourceChangeEvent event) {
188
	public void resourceChanged(IResourceChangeEvent event) {
170
		IResourceDelta root = event.getDelta();
189
		IResourceDelta root = event.getDelta();
171
		
190
172
		//TODO: Need to add code to handle map project deletion, addition and rename			
191
		//TODO: Need to add code to handle map project deletion, addition and rename			
173
		IResourceDelta folderDelta = root.findMember(getMapFolder().getFullPath());
192
		IResourceDelta folderDelta = root.findMember(getMapFolder().getFullPath());
174
		if (folderDelta == null) return;
193
		if (folderDelta == null)
175
		
194
			return;
195
176
		//Handle map files deletion, addition and rename
196
		//Handle map files deletion, addition and rename
177
		IResourceDelta[] deltas = folderDelta.getAffectedChildren();
197
		IResourceDelta[] deltas = folderDelta.getAffectedChildren();
178
		if(deltas == null || deltas.length == 0) return;
198
		if (deltas == null || deltas.length == 0)
199
			return;
179
		for (int i = 0; i < deltas.length; i++) {
200
		for (int i = 0; i < deltas.length; i++) {
180
			IResourceDelta delta = deltas[i];
201
			IResourceDelta delta = deltas[i];
181
			if(delta.getResource().getType() == IResource.FILE){				
202
			if (delta.getResource().getType() == IResource.FILE) {
182
				try{
203
				try {
183
					IFile aFile = (IFile)(delta.getResource());
204
					IFile aFile = (IFile) (delta.getResource());
184
					MapFile mFile = null;
205
					MapFile mFile = null;
185
					if(isMapFile(aFile)){
206
					if (isMapFile(aFile)) {
186
						// Handle content change
207
						// Handle content change
187
						if(delta.getKind() == IResourceDelta.CHANGED){	
208
						if (delta.getKind() == IResourceDelta.CHANGED) {
188
							mFile = getMapFileFor(aFile);
209
							mFile = getMapFileFor(aFile);
189
							mFile.loadEntries();	
210
							mFile.loadEntries();
190
						}
211
						}
191
						//Handle deletion. We cannot simply remove the map file directly bacause we have to call
212
						//Handle deletion. We cannot simply remove the map file directly bacause we have to call
192
						//getMapFileFor(IFile) in order to do so. But the IFile is already deleted. So we have to 
213
						//getMapFileFor(IFile) in order to do so. But the IFile is already deleted. So we have to 
193
						//reconstuct the map files.
214
						//reconstuct the map files.
194
						if(delta.getKind() == IResourceDelta.REMOVED ){
215
						if (delta.getKind() == IResourceDelta.REMOVED) {
195
							loadMapFiles();
216
							loadMapFiles();
196
						}
217
						}
197
						// Handle addition
218
						// Handle addition
198
						if(delta.getKind() == IResourceDelta.ADDED ){
219
						if (delta.getKind() == IResourceDelta.ADDED) {
199
							mFile = getMapFileFor(aFile);
220
							mFile = getMapFileFor(aFile);
200
							addMapFile(mFile);
221
							addMapFile(mFile);
201
						}
222
						}
Lines 207-218 Link Here
207
		}
228
		}
208
	}
229
	}
209
230
210
	private IFolder getMapFolder(){
231
	private IFolder getMapFolder() {
211
		return getProject().getFolder(RelEngPlugin.MAP_FOLDER);
232
		return getProject().getFolder(RelEngPlugin.MAP_FOLDER);
212
	}
233
	}
234
213
	private void loadMapFiles() throws CoreException {
235
	private void loadMapFiles() throws CoreException {
214
		IFolder folder = project.getFolder(RelEngPlugin.MAP_FOLDER);
236
		IFolder folder = project.getFolder(RelEngPlugin.MAP_FOLDER);
215
		if(!folder.exists()) {
237
		if (!folder.exists()) {
216
			mapFiles = new MapFile[0];
238
			mapFiles = new MapFile[0];
217
			return;
239
			return;
218
		}
240
		}
Lines 221-254 Link Here
221
			List list = new ArrayList();
243
			List list = new ArrayList();
222
			for (int i = 0; i < resource.length; i++) {
244
			for (int i = 0; i < resource.length; i++) {
223
				//In case there are some sub folders
245
				//In case there are some sub folders
224
				if(resource[i].getType() == IResource.FILE){
246
				if (resource[i].getType() == IResource.FILE) {
225
					IFile file = (IFile) resource[i];
247
					IFile file = (IFile) resource[i];
226
					if(isMapFile(file)){
248
					if (isMapFile(file))
227
						list.add(new MapFile(file));
249
						list.add(new MapFile(file));
228
					}
229
				}
250
				}
230
			}
251
			}
231
			mapFiles = (MapFile[])list.toArray(new MapFile[list.size()]);
252
			mapFiles = (MapFile[]) list.toArray(new MapFile[list.size()]);
232
		} else {
253
		} else {
233
			mapFiles = new MapFile[0];
254
			mapFiles = new MapFile[0];
234
		}
255
		}
235
	}
256
	}
236
	
257
237
	private MapFile getMapFileFor(IFile file) throws CoreException{
258
	private MapFile getMapFileFor(IFile file) throws CoreException {
238
		for(int i = 0; i < mapFiles.length; i++){
259
		for (int i = 0; i < mapFiles.length; i++) {
239
			if (mapFiles[i].getFile().equals(file))
260
			if (mapFiles[i].getFile().equals(file))
240
				return mapFiles[i];
261
				return mapFiles[i];
241
		}
262
		}
242
		return new MapFile(file);
263
		return new MapFile(file);
243
	}
264
	}
244
	private void addMapFile(MapFile aFile){
265
266
	private void addMapFile(MapFile aFile) {
245
		Set set = new HashSet(Arrays.asList(mapFiles));
267
		Set set = new HashSet(Arrays.asList(mapFiles));
246
		set.add(aFile);
268
		set.add(aFile);
247
		mapFiles = (MapFile[])set.toArray(new MapFile[set.size()]); 
269
		mapFiles = (MapFile[]) set.toArray(new MapFile[set.size()]);
248
	}
270
	}
249
	private boolean isMapFile(IFile aFile){
271
250
		String extension = aFile.getFileExtension();
272
	/*
251
		//In case file has no extension name or is not validate map file
273
	 * Return a boolean value indicating whether or not the given
252
		return ( extension != null && extension.equals(MapFile.MAP_FILE_EXTENSION)); 
274
	 * file is a valid map file.
275
	 */
276
	private boolean isMapFile(IFile file) {
277
		// for now just validate based on file extension
278
		return MapFile.MAP_FILE_EXTENSION.equals(file.getFileExtension());
279
	}
280
281
	/* (non-Javadoc)
282
	 * @see java.lang.Object#toString()
283
	 */
284
	public String toString() {
285
		return "MapProject(" + project.getName() + ")";
253
	}
286
	}
254
}
287
}
(-)META-INF/MANIFEST.MF (-1 / +1 lines)
Lines 3-9 Link Here
3
Bundle-Name: RelEng Plug-in
3
Bundle-Name: RelEng Plug-in
4
Bundle-SymbolicName: org.eclipse.releng.tools; singleton:=true
4
Bundle-SymbolicName: org.eclipse.releng.tools; singleton:=true
5
Bundle-Version: 3.3.0.qualifier
5
Bundle-Version: 3.3.0.qualifier
6
Bundle-ClassPath: tools.jar
7
Bundle-Activator: org.eclipse.releng.tools.RelEngPlugin
6
Bundle-Activator: org.eclipse.releng.tools.RelEngPlugin
8
Bundle-Vendor: Eclipse.org
7
Bundle-Vendor: Eclipse.org
9
Bundle-Localization: plugin
8
Bundle-Localization: plugin
Lines 21-24 Link Here
21
 org.eclipse.team.core,
20
 org.eclipse.team.core,
22
 org.eclipse.team.ui,
21
 org.eclipse.team.ui,
23
 org.eclipse.compare
22
 org.eclipse.compare
23
Bundle-RequiredExecutionEnvironment: J2SE-1.4
24
Eclipse-LazyStart: true
24
Eclipse-LazyStart: true
(-).classpath (-1 / +1 lines)
Lines 1-7 Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
1
<?xml version="1.0" encoding="UTF-8"?>
2
<classpath>
2
<classpath>
3
	<classpathentry kind="src" path="src"/>
3
	<classpathentry kind="src" path="src"/>
4
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
4
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
5
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
5
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
6
	<classpathentry kind="output" path="bin"/>
6
	<classpathentry kind="output" path="bin"/>
7
</classpath>
7
</classpath>
(-)build.properties (-3 / +5 lines)
Lines 1-5 Link Here
1
###############################################################################
1
###############################################################################
2
# Copyright (c) 2000, 2005 IBM Corporation and others.
2
# Copyright (c) 2000, 2007 IBM Corporation and others.
3
# All rights reserved. This program and the accompanying materials
3
# All rights reserved. This program and the accompanying materials
4
# are made available under the terms of the Eclipse Public License v1.0
4
# are made available under the terms of the Eclipse Public License v1.0
5
# which accompanies this distribution, and is available at
5
# which accompanies this distribution, and is available at
Lines 8-17 Link Here
8
# Contributors:
8
# Contributors:
9
#     IBM Corporation - initial API and implementation
9
#     IBM Corporation - initial API and implementation
10
###############################################################################
10
###############################################################################
11
source.tools.jar = src/
11
source..=src/
12
bin.includes = plugin.xml,\
12
bin.includes = plugin.xml,\
13
               *.jar,\
13
               .,\
14
               about.html,\
14
               about.html,\
15
               icons/,\
15
               icons/,\
16
               plugin.properties,\
16
               plugin.properties,\
17
               META-INF/
17
               META-INF/
18
output.. = bin/
19
src.includes=about.html
(-).settings/org.eclipse.jdt.core.prefs (+58 lines)
Added Link Here
1
#Wed Feb 21 13:22:16 EST 2007
2
eclipse.preferences.version=1
3
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
4
org.eclipse.jdt.core.compiler.compliance=1.4
5
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
7
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
8
org.eclipse.jdt.core.compiler.problem.deprecation=warning
9
org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
10
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=enabled
11
org.eclipse.jdt.core.compiler.problem.discouragedReference=ignore
12
org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
13
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
14
org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
15
org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled
16
org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
17
org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
18
org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
19
org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
20
org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
21
org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
22
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
23
org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning
24
org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning
25
org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
26
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
27
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
28
org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
29
org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
30
org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
31
org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
32
org.eclipse.jdt.core.compiler.problem.nullReference=ignore
33
org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
34
org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
35
org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
36
org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
37
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
38
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
39
org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
40
org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=warning
41
org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
42
org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
43
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
44
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
45
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
46
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
47
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
48
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
49
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=enabled
50
org.eclipse.jdt.core.compiler.problem.unusedImport=warning
51
org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
52
org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
53
org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
54
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=enabled
55
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=enabled
56
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
57
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
58
org.eclipse.jdt.core.compiler.source=1.3

Return to bug 173314