View | Details | Raw Unified | Return to bug 290860 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/mylyn/internal/jira/core/model/Project.java (+26 lines)
Lines 14-20 Link Here
14
14
15
import java.io.Serializable;
15
import java.io.Serializable;
16
import java.util.ArrayList;
16
import java.util.ArrayList;
17
import java.util.HashMap;
17
import java.util.List;
18
import java.util.List;
19
import java.util.Map;
18
20
19
/**
21
/**
20
 * TODO need mapping statuses -> actions -> fields TODO need mapping statuses -> fields
22
 * TODO need mapping statuses -> actions -> fields TODO need mapping statuses -> fields
Lines 48-53 Link Here
48
50
49
	private SecurityLevel[] securityLevels;
51
	private SecurityLevel[] securityLevels;
50
52
53
	private Map<String, IssueType> issueTypesById;
54
55
	private boolean details;
56
51
	public Project(String id) {
57
	public Project(String id) {
52
		this.id = id;
58
		this.id = id;
53
	}
59
	}
Lines 212-217 Link Here
212
218
213
	public void setIssueTypes(IssueType[] issueTypes) {
219
	public void setIssueTypes(IssueType[] issueTypes) {
214
		this.issueTypes = issueTypes;
220
		this.issueTypes = issueTypes;
221
		this.issueTypesById = new HashMap<String, IssueType>();
222
		if (issueTypes != null) {
223
			for (IssueType type : issueTypes) {
224
				issueTypesById.put(type.getId(), type);
225
			}
226
		}
215
	}
227
	}
216
228
217
	public SecurityLevel[] getSecurityLevels() {
229
	public SecurityLevel[] getSecurityLevels() {
Lines 222-225 Link Here
222
		this.securityLevels = securityLevels;
234
		this.securityLevels = securityLevels;
223
	}
235
	}
224
236
237
	public void setDetails(boolean details) {
238
		this.details = details;
239
	}
240
241
	public boolean hasDetails() {
242
		return details;
243
	}
244
245
	public IssueType getIssueTypeById(String typeId) {
246
		if (issueTypesById != null) {
247
			return issueTypesById.get(typeId);
248
		}
249
		return null;
250
	}
225
}
251
}
(-)src/org/eclipse/mylyn/internal/jira/core/model/JiraVersion.java (+4 lines)
Lines 113-116 Link Here
113
		return sb.toString();
113
		return sb.toString();
114
	}
114
	}
115
115
116
	public boolean supportsPerProjectIssueTypes() {
117
		return this.compareTo(JiraVersion.JIRA_3_12) >= 0;
118
	}
119
116
}
120
}
(-)src/org/eclipse/mylyn/internal/jira/core/service/JiraClientCache.java (-51 / +29 lines)
Lines 12-21 Link Here
12
12
13
package org.eclipse.mylyn.internal.jira.core.service;
13
package org.eclipse.mylyn.internal.jira.core.service;
14
14
15
import java.util.Arrays;
16
import java.util.HashMap;
15
import java.util.HashMap;
17
import java.util.HashSet;
18
import java.util.Set;
19
16
20
import org.eclipse.core.runtime.IProgressMonitor;
17
import org.eclipse.core.runtime.IProgressMonitor;
21
import org.eclipse.core.runtime.SubMonitor;
18
import org.eclipse.core.runtime.SubMonitor;
Lines 75-82 Link Here
75
72
76
		submonitor.setWorkRemaining(data.projects.length);
73
		submonitor.setWorkRemaining(data.projects.length);
77
		for (Project project : data.projects) {
74
		for (Project project : data.projects) {
78
			initializeProject(project, submonitor.newChild(1, SubMonitor.SUPPRESS_NONE));
79
80
			data.projectsById.put(project.getId(), project);
75
			data.projectsById.put(project.getId(), project);
81
			data.projectsByKey.put(project.getKey(), project);
76
			data.projectsByKey.put(project.getKey(), project);
82
		}
77
		}
Lines 87-98 Link Here
87
				project.getKey()), 5);
82
				project.getKey()), 5);
88
83
89
		synchronized (project) {
84
		synchronized (project) {
90
			final String version = data.serverInfo.getVersion();
85
			final JiraVersion version = new JiraVersion(data.serverInfo.getVersion());
91
86
92
			project.setComponents(jiraClient.getComponents(project.getKey(), subMonitor.newChild(1)));
87
			project.setComponents(jiraClient.getComponents(project.getKey(), subMonitor.newChild(1)));
93
			project.setVersions(jiraClient.getVersions(project.getKey(), subMonitor.newChild(1)));
88
			project.setVersions(jiraClient.getVersions(project.getKey(), subMonitor.newChild(1)));
94
89
95
			if (supportsPerProjectIssueTypes(version) >= 0) {
90
			if (version.supportsPerProjectIssueTypes()) {
96
				IssueType[] issueTypes = jiraClient.getIssueTypes(project.getId(), subMonitor.newChild(1));
91
				IssueType[] issueTypes = jiraClient.getIssueTypes(project.getId(), subMonitor.newChild(1));
97
				IssueType[] subTaskIssueTypes = jiraClient.getSubTaskIssueTypes(project.getId(), subMonitor.newChild(1));
92
				IssueType[] subTaskIssueTypes = jiraClient.getSubTaskIssueTypes(project.getId(), subMonitor.newChild(1));
98
				for (IssueType issueType : subTaskIssueTypes) {
93
				for (IssueType issueType : subTaskIssueTypes) {
Lines 105-111 Link Here
105
100
106
				project.setIssueTypes(projectIssueTypes);
101
				project.setIssueTypes(projectIssueTypes);
107
			}
102
			}
108
			if (new JiraVersion(version).compareTo(JiraVersion.JIRA_3_13) >= 0) {
103
			if (version.compareTo(JiraVersion.JIRA_3_13) >= 0) {
109
				try {
104
				try {
110
					SecurityLevel[] securityLevels = jiraClient.getAvailableSecurityLevels(project.getKey(),
105
					SecurityLevel[] securityLevels = jiraClient.getAvailableSecurityLevels(project.getKey(),
111
							subMonitor.newChild(1));
106
							subMonitor.newChild(1));
Lines 120-125 Link Here
120
					project.setSecurityLevels(null);
115
					project.setSecurityLevels(null);
121
				}
116
				}
122
			}
117
			}
118
119
			project.setDetails(true);
123
		}
120
		}
124
	}
121
	}
125
122
Lines 161-205 Link Here
161
		SubMonitor submonitor = SubMonitor.convert(monitor, Messages.JiraClientCache_getting_issue_types, 2);
158
		SubMonitor submonitor = SubMonitor.convert(monitor, Messages.JiraClientCache_getting_issue_types, 2);
162
159
163
		String version = data.serverInfo.getVersion();
160
		String version = data.serverInfo.getVersion();
164
		if (supportsPerProjectIssueTypes(version) >= 0) {
161
		IssueType[] issueTypes = jiraClient.getIssueTypes(submonitor.newChild(1));
165
			// collect issue types from all projects to avoid additional SOAP request
162
		IssueType[] subTaskIssueTypes;
166
			Set<IssueType> issueTypes = new HashSet<IssueType>();
163
		if (new JiraVersion(version).compareTo(JiraVersion.JIRA_3_3) >= 0) {
167
			for (Project project : data.projects) {
164
			subTaskIssueTypes = jiraClient.getSubTaskIssueTypes(submonitor.newChild(1));
168
				IssueType[] projectIssueTypes = project.getIssueTypes();
169
				if (projectIssueTypes != null) {
170
					issueTypes.addAll(Arrays.asList(projectIssueTypes));
171
				}
172
			}
173
174
			data.issueTypes = issueTypes.toArray(new IssueType[0]);
175
			data.issueTypesById = new HashMap<String, IssueType>(data.issueTypes.length);
176
			for (IssueType issueType : data.issueTypes) {
177
				data.issueTypesById.put(issueType.getId(), issueType);
178
			}
179
		} else {
165
		} else {
180
			IssueType[] issueTypes = jiraClient.getIssueTypes(submonitor.newChild(1));
166
			subTaskIssueTypes = new IssueType[0];
181
			IssueType[] subTaskIssueTypes;
167
		}
182
			if (new JiraVersion(version).compareTo(JiraVersion.JIRA_3_3) >= 0) {
183
				subTaskIssueTypes = jiraClient.getSubTaskIssueTypes(submonitor.newChild(1));
184
			} else {
185
				subTaskIssueTypes = new IssueType[0];
186
			}
187
188
			data.issueTypesById = new HashMap<String, IssueType>(issueTypes.length + subTaskIssueTypes.length);
189
168
190
			for (IssueType issueType : issueTypes) {
169
		data.issueTypesById = new HashMap<String, IssueType>(issueTypes.length + subTaskIssueTypes.length);
191
				data.issueTypesById.put(issueType.getId(), issueType);
192
			}
193
170
194
			for (IssueType issueType : subTaskIssueTypes) {
171
		for (IssueType issueType : issueTypes) {
195
				issueType.setSubTaskType(true);
172
			data.issueTypesById.put(issueType.getId(), issueType);
196
				data.issueTypesById.put(issueType.getId(), issueType);
173
		}
197
			}
198
174
199
			data.issueTypes = new IssueType[issueTypes.length + subTaskIssueTypes.length];
175
		for (IssueType issueType : subTaskIssueTypes) {
200
			System.arraycopy(issueTypes, 0, data.issueTypes, 0, issueTypes.length);
176
			issueType.setSubTaskType(true);
201
			System.arraycopy(subTaskIssueTypes, 0, data.issueTypes, issueTypes.length, subTaskIssueTypes.length);
177
			data.issueTypesById.put(issueType.getId(), issueType);
202
		}
178
		}
179
180
		data.issueTypes = new IssueType[issueTypes.length + subTaskIssueTypes.length];
181
		System.arraycopy(issueTypes, 0, data.issueTypes, 0, issueTypes.length);
182
		System.arraycopy(subTaskIssueTypes, 0, data.issueTypes, issueTypes.length, subTaskIssueTypes.length);
203
	}
183
	}
204
184
205
	private void initializeStatuses(JiraClientData data, IProgressMonitor monitor) throws JiraException {
185
	private void initializeStatuses(JiraClientData data, IProgressMonitor monitor) throws JiraException {
Lines 213-219 Link Here
213
	}
193
	}
214
194
215
	private void initializeProjectRoles(JiraClientData data, IProgressMonitor monitor) throws JiraException {
195
	private void initializeProjectRoles(JiraClientData data, IProgressMonitor monitor) throws JiraException {
216
		data.projectRoles = jiraClient.getProjectRoles(monitor);
196
		SubMonitor submonitor = SubMonitor.convert(monitor, Messages.JiraClientCache_getting_project_roles, 1);
197
198
		data.projectRoles = jiraClient.getProjectRoles(submonitor.newChild(1));
217
	}
199
	}
218
200
219
	private void initializeResolutions(JiraClientData data, IProgressMonitor monitor) throws JiraException {
201
	private void initializeResolutions(JiraClientData data, IProgressMonitor monitor) throws JiraException {
Lines 253-271 Link Here
253
235
254
	public synchronized void refreshDetails(IProgressMonitor monitor) throws JiraException {
236
	public synchronized void refreshDetails(IProgressMonitor monitor) throws JiraException {
255
		SubMonitor subMonitor = SubMonitor.convert(monitor, Messages.JiraClientCache_Updating_repository_configuration,
237
		SubMonitor subMonitor = SubMonitor.convert(monitor, Messages.JiraClientCache_Updating_repository_configuration,
256
				20);
238
				7);
257
239
258
		final JiraClientData newData = new JiraClientData();
240
		final JiraClientData newData = new JiraClientData();
259
241
260
		refreshServerInfo(newData, subMonitor.newChild(1, SubMonitor.SUPPRESS_NONE));
242
		refreshServerInfo(newData, subMonitor.newChild(1, SubMonitor.SUPPRESS_NONE));
261
		data.serverInfo = newData.serverInfo;
243
		data.serverInfo = newData.serverInfo;
262
244
263
		initializeProjects(newData, subMonitor.newChild(15, SubMonitor.SUPPRESS_NONE));
264
		initializePriorities(newData, subMonitor.newChild(1, SubMonitor.SUPPRESS_NONE));
245
		initializePriorities(newData, subMonitor.newChild(1, SubMonitor.SUPPRESS_NONE));
265
		initializeIssueTypes(newData, subMonitor.newChild(1, SubMonitor.SUPPRESS_NONE));
246
		initializeIssueTypes(newData, subMonitor.newChild(1, SubMonitor.SUPPRESS_NONE));
266
		initializeResolutions(newData, subMonitor.newChild(1, SubMonitor.SUPPRESS_NONE));
247
		initializeResolutions(newData, subMonitor.newChild(1, SubMonitor.SUPPRESS_NONE));
267
		initializeStatuses(newData, subMonitor.newChild(1, SubMonitor.SUPPRESS_NONE));
248
		initializeStatuses(newData, subMonitor.newChild(1, SubMonitor.SUPPRESS_NONE));
268
		initializeProjectRoles(newData, subMonitor.newChild(1, SubMonitor.SUPPRESS_NONE));
249
		initializeProjectRoles(newData, subMonitor.newChild(1, SubMonitor.SUPPRESS_NONE));
250
		initializeProjects(newData, subMonitor.newChild(1, SubMonitor.SUPPRESS_NONE));
269
251
270
		newData.lastUpdate = System.currentTimeMillis();
252
		newData.lastUpdate = System.currentTimeMillis();
271
		this.data = newData;
253
		this.data = newData;
Lines 276-283 Link Here
276
	 * to complete and should not be called from a UI thread.
258
	 * to complete and should not be called from a UI thread.
277
	 */
259
	 */
278
	public synchronized void refreshServerInfo(JiraClientData data, IProgressMonitor monitor) throws JiraException {
260
	public synchronized void refreshServerInfo(JiraClientData data, IProgressMonitor monitor) throws JiraException {
279
		monitor = SubMonitor.convert(monitor, Messages.JiraClientCache_Getting_server_information, 1);
261
		SubMonitor submonitor = SubMonitor.convert(monitor, Messages.JiraClientCache_Getting_server_information, 1);
280
		data.serverInfo = jiraClient.getServerInfo(monitor);
262
		data.serverInfo = jiraClient.getServerInfo(submonitor.newChild(1));
281
	}
263
	}
282
264
283
	public synchronized void refreshServerInfo(IProgressMonitor monitor) throws JiraException {
265
	public synchronized void refreshServerInfo(IProgressMonitor monitor) throws JiraException {
Lines 324-331 Link Here
324
		return user;
306
		return user;
325
	}
307
	}
326
308
327
	private int supportsPerProjectIssueTypes(String version) {
328
		return new JiraVersion(version).compareTo(JiraVersion.JIRA_3_12);
329
	}
330
331
}
309
}
(-)src/org/eclipse/mylyn/internal/jira/core/service/messages.properties (+1 lines)
Lines 17-19 Link Here
17
JiraClientCache_getting_server_info=Getting server info
17
JiraClientCache_getting_server_info=Getting server info
18
JiraClientCache_getting_statuses=Getting statuses
18
JiraClientCache_getting_statuses=Getting statuses
19
JiraClientCache_project_details_for=Getting project details for {0}
19
JiraClientCache_project_details_for=Getting project details for {0}
20
JiraClientCache_getting_project_roles=Getting project roles
(-)src/org/eclipse/mylyn/internal/jira/core/service/FilterDefinitionConverter.java (-1 / +18 lines)
Lines 187-192 Link Here
187
			Set<Version> versions = new LinkedHashSet<Version>();
187
			Set<Version> versions = new LinkedHashSet<Version>();
188
188
189
			for (Project project : projects) {
189
			for (Project project : projects) {
190
				if (!project.hasDetails()) {
191
					continue;
192
				}
190
				for (String componentId : componentIds) {
193
				for (String componentId : componentIds) {
191
					Component[] projectComponents = project.getComponents();
194
					Component[] projectComponents = project.getComponents();
192
					for (Component component : projectComponents) {
195
					for (Component component : projectComponents) {
Lines 209-215 Link Here
209
		List<String> typeIds = getIds(params, TYPE_KEY);
212
		List<String> typeIds = getIds(params, TYPE_KEY);
210
		List<IssueType> issueTypes = new ArrayList<IssueType>();
213
		List<IssueType> issueTypes = new ArrayList<IssueType>();
211
		for (String typeId : typeIds) {
214
		for (String typeId : typeIds) {
212
			IssueType issueType = client.getCache().getIssueTypeById(typeId);
215
			IssueType issueType = null;
216
			if (projects.size() > 0) {
217
				for (Project project : projects) {
218
					issueType = project.getIssueTypeById(typeId);
219
					if (issueType != null) {
220
						break;
221
					}
222
				}
223
			}
224
225
			// fallback - if there are no projects or project issue types are not supported
226
			if (issueType == null) {
227
				issueType = client.getCache().getIssueTypeById(typeId);
228
			}
229
213
			if (issueType != null) {
230
			if (issueType != null) {
214
				issueTypes.add(issueType);
231
				issueTypes.add(issueType);
215
			} else if (validate) {
232
			} else if (validate) {
(-)src/org/eclipse/mylyn/internal/jira/core/service/Messages.java (+1 lines)
Lines 43-46 Link Here
43
43
44
	public static String JiraClientCache_project_details_for;
44
	public static String JiraClientCache_project_details_for;
45
45
46
	public static String JiraClientCache_getting_project_roles;
46
}
47
}
(-)src/org/eclipse/mylyn/internal/jira/core/JiraAttributeMapper.java (-1 / +1 lines)
Lines 128-134 Link Here
128
						JiraAttribute.PROJECT.id());
128
						JiraAttribute.PROJECT.id());
129
				if (projectAttribute != null) {
129
				if (projectAttribute != null) {
130
					Project project = client.getCache().getProjectById(projectAttribute.getValue());
130
					Project project = client.getCache().getProjectById(projectAttribute.getValue());
131
					if (project != null) {
131
					if (project != null && project.hasDetails()) {
132
						if (JiraAttribute.COMPONENTS.id().equals(attribute.getId())) {
132
						if (JiraAttribute.COMPONENTS.id().equals(attribute.getId())) {
133
							for (Component component : project.getComponents()) {
133
							for (Component component : project.getComponents()) {
134
								options.put(component.getId(), component.getName());
134
								options.put(component.getId(), component.getName());
(-)src/org/eclipse/mylyn/internal/jira/core/service/web/rss/JiraRssHandler.java (-40 / +70 lines)
Lines 23-28 Link Here
23
23
24
import org.apache.commons.lang.StringEscapeUtils;
24
import org.apache.commons.lang.StringEscapeUtils;
25
import org.eclipse.core.runtime.IStatus;
25
import org.eclipse.core.runtime.IStatus;
26
import org.eclipse.core.runtime.NullProgressMonitor;
26
import org.eclipse.core.runtime.OperationCanceledException;
27
import org.eclipse.core.runtime.OperationCanceledException;
27
import org.eclipse.core.runtime.Status;
28
import org.eclipse.core.runtime.Status;
28
import org.eclipse.mylyn.commons.core.StatusHandler;
29
import org.eclipse.mylyn.commons.core.StatusHandler;
Lines 40-45 Link Here
40
import org.eclipse.mylyn.internal.jira.core.model.Version;
41
import org.eclipse.mylyn.internal.jira.core.model.Version;
41
import org.eclipse.mylyn.internal.jira.core.model.filter.IssueCollector;
42
import org.eclipse.mylyn.internal.jira.core.model.filter.IssueCollector;
42
import org.eclipse.mylyn.internal.jira.core.service.JiraClient;
43
import org.eclipse.mylyn.internal.jira.core.service.JiraClient;
44
import org.eclipse.mylyn.internal.jira.core.service.JiraException;
43
import org.xml.sax.Attributes;
45
import org.xml.sax.Attributes;
44
import org.xml.sax.SAXException;
46
import org.xml.sax.SAXException;
45
import org.xml.sax.helpers.DefaultHandler;
47
import org.xml.sax.helpers.DefaultHandler;
Lines 267-277 Link Here
267
269
268
	private final ArrayList<Comment> currentComments = new ArrayList<Comment>();
270
	private final ArrayList<Comment> currentComments = new ArrayList<Comment>();
269
271
270
	private ArrayList<Version> currentFixVersions = null;
272
	private final ArrayList<Version> currentFixVersions = new ArrayList<Version>();
271
273
272
	private ArrayList<Version> currentReportedVersions = null;
274
	private final ArrayList<Version> currentReportedVersions = new ArrayList<Version>();
273
275
274
	private ArrayList<Component> currentComponents = null;
276
	private final ArrayList<Component> currentComponents = new ArrayList<Component>();
275
277
276
	private final ArrayList<Attachment> currentAttachments = new ArrayList<Attachment>();
278
	private final ArrayList<Attachment> currentAttachments = new ArrayList<Attachment>();
277
279
Lines 384-390 Link Here
384
				currentIssue.setParentId(attributes.getValue(ID_ATTR));
386
				currentIssue.setParentId(attributes.getValue(ID_ATTR));
385
			} else if (TYPE.equals(localName)) {
387
			} else if (TYPE.equals(localName)) {
386
				// FIXME bug 280834: handle case where cache is outdated
388
				// FIXME bug 280834: handle case where cache is outdated
387
				currentIssue.setType(client.getCache().getIssueTypeById(attributes.getValue(ID_ATTR)));
389
				if (currentIssue.getProject() != null
390
						&& currentIssue.getProject().getIssueTypeById(attributes.getValue(ID_ATTR)) != null) {
391
					currentIssue.setType(currentIssue.getProject().getIssueTypeById(attributes.getValue(ID_ATTR)));
392
				} else {
393
					currentIssue.setType(client.getCache().getIssueTypeById(attributes.getValue(ID_ATTR)));
394
				}
388
			} else if (PRIORITY.equals(localName)) {
395
			} else if (PRIORITY.equals(localName)) {
389
				currentIssue.setPriority(client.getCache().getPriorityById(attributes.getValue(ID_ATTR)));
396
				currentIssue.setPriority(client.getCache().getPriorityById(attributes.getValue(ID_ATTR)));
390
			} else if (STATUS.equals(localName)) {
397
			} else if (STATUS.equals(localName)) {
Lines 623-635 Link Here
623
			if (CHANNEL.equals(localName)) {
630
			if (CHANNEL.equals(localName)) {
624
				state = LOOKING_FOR_CHANNEL;
631
				state = LOOKING_FOR_CHANNEL;
625
			} else if (ITEM.equals(localName)) {
632
			} else if (ITEM.equals(localName)) {
626
				if (currentReportedVersions != null) {
633
				if (currentReportedVersions.size() > 0) {
627
					currentIssue.setReportedVersions(currentReportedVersions.toArray(new Version[currentReportedVersions.size()]));
634
					currentIssue.setReportedVersions(currentReportedVersions.toArray(new Version[currentReportedVersions.size()]));
628
				}
635
				}
629
				if (currentFixVersions != null) {
636
				if (currentFixVersions.size() > 0) {
630
					currentIssue.setFixVersions(currentFixVersions.toArray(new Version[currentFixVersions.size()]));
637
					currentIssue.setFixVersions(currentFixVersions.toArray(new Version[currentFixVersions.size()]));
631
				}
638
				}
632
				if (currentComponents != null) {
639
				if (currentComponents.size() > 0) {
633
					currentIssue.setComponents(currentComponents.toArray(new Component[currentComponents.size()]));
640
					currentIssue.setComponents(currentComponents.toArray(new Component[currentComponents.size()]));
634
				}
641
				}
635
				currentIssue.setComments(currentComments.toArray(new Comment[currentComments.size()]));
642
				currentIssue.setComments(currentComments.toArray(new Comment[currentComments.size()]));
Lines 645-653 Link Here
645
				currentCustomFields.clear();
652
				currentCustomFields.clear();
646
				currentAttachments.clear();
653
				currentAttachments.clear();
647
				currentComments.clear();
654
				currentComments.clear();
648
				currentFixVersions = null;
655
				currentFixVersions.clear();
649
				currentReportedVersions = null;
656
				currentReportedVersions.clear();
650
				currentComponents = null;
657
				currentComponents.clear();
651
				markupDetected = false;
658
				markupDetected = false;
652
				state = LOOKING_FOR_ITEM;
659
				state = LOOKING_FOR_ITEM;
653
			} else if (TITLE.equals(localName)) {
660
			} else if (TITLE.equals(localName)) {
Lines 674-679 Link Here
674
					//throw new SAXException("No project with key '" + projectKey + "' found");
681
					//throw new SAXException("No project with key '" + projectKey + "' found");
675
					break;
682
					break;
676
				}
683
				}
684
				if (!project.hasDetails()) {
685
					try {
686
						client.getCache().refreshProjectDetails(project.getId(), new NullProgressMonitor());
687
					} catch (JiraException e) {
688
						break;
689
					}
690
				}
677
				currentIssue.setProject(project);
691
				currentIssue.setProject(project);
678
			} else if (PARENT.equals(localName)) {
692
			} else if (PARENT.equals(localName)) {
679
				currentIssue.setParentKey(getCurrentElementText());
693
				currentIssue.setParentKey(getCurrentElementText());
Lines 684-730 Link Here
684
			} else if (UPDATED.equals(localName)) {
698
			} else if (UPDATED.equals(localName)) {
685
				currentIssue.setUpdated(convertToDate(getCurrentElementText()));
699
				currentIssue.setUpdated(convertToDate(getCurrentElementText()));
686
			} else if (VERSION.equals(localName)) {
700
			} else if (VERSION.equals(localName)) {
687
				if (currentIssue.getProject() == null) {
701
				if (currentIssue.getProject() == null
702
						|| !addVersionTo(currentReportedVersions, getCurrentElementText())) {
688
					//throw new SAXException("Issue " + currentIssue.getId() + " does not have a valid project");
703
					//throw new SAXException("Issue " + currentIssue.getId() + " does not have a valid project");
689
					break;
704
					break;
690
				}
705
				}
691
				Version version = currentIssue.getProject().getVersion(getCurrentElementText());
692
				// TODO add better handling of unknown versions
693
				if (version != null) {
694
					// throw new SAXException("No version with name '" + getCurrentElementText() + "' found");
695
					if (currentReportedVersions == null) {
696
						currentReportedVersions = new ArrayList<Version>();
697
					}
698
					currentReportedVersions.add(version);
699
				}
700
			} else if (FIX_VERSION.equals(localName)) {
706
			} else if (FIX_VERSION.equals(localName)) {
701
				if (currentIssue.getProject() == null) {
707
				if (currentIssue.getProject() == null || !addVersionTo(currentFixVersions, getCurrentElementText())) {
702
					//throw new SAXException("Issue " + currentIssue.getId() + " does not have a valid project");
708
					//throw new SAXException("Issue " + currentIssue.getId() + " does not have a valid project");
703
					break;
709
					break;
704
				}
710
				}
705
				Version version = currentIssue.getProject().getVersion(getCurrentElementText());
706
				// TODO add better handling of unknown versions
707
				if (version != null) {
708
					// throw new SAXException("No version with name '" + getCurrentElementText() + "' found");
709
					if (currentFixVersions == null) {
710
						currentFixVersions = new ArrayList<Version>();
711
					}
712
					currentFixVersions.add(version);
713
				}
714
			} else if (COMPONENT.equals(localName)) {
711
			} else if (COMPONENT.equals(localName)) {
715
				if (currentIssue.getProject() == null) {
712
				if (currentIssue.getProject() == null || !addComponentTo(currentComponents, getCurrentElementText())) {
716
					//throw new SAXException("Issue " + currentIssue.getId() + " does not have a valid project");
713
					//throw new SAXException("Issue " + currentIssue.getId() + " does not have a valid project");
717
					break;
714
					break;
718
				}
715
				}
719
				Component component = currentIssue.getProject().getComponent(getCurrentElementText());
720
				// TODO add better handling of unknown components
721
				if (component != null) {
722
					// throw new SAXException("No component with name '" + getCurrentElementText() + "' found");
723
					if (currentComponents == null) {
724
						currentComponents = new ArrayList<Component>();
725
					}
726
					currentComponents.add(component);
727
				}
728
			} else if (DUE.equals(localName)) {
716
			} else if (DUE.equals(localName)) {
729
				currentIssue.setDue(convertToSimpleDate(getCurrentElementText()));
717
				currentIssue.setDue(convertToSimpleDate(getCurrentElementText()));
730
			} else if (VOTES.equals(localName)) {
718
			} else if (VOTES.equals(localName)) {
Lines 778-783 Link Here
778
		}
766
		}
779
	}
767
	}
780
768
769
	private boolean addVersionTo(ArrayList<Version> versions, String currentElementText) {
770
		Version version = currentIssue.getProject().getVersion(currentElementText);
771
		if (version != null) {
772
			versions.add(version);
773
			return true;
774
		} else {
775
			try {
776
				client.getCache().refreshProjectDetails(currentIssue.getProject().getId(), new NullProgressMonitor());
777
			} catch (JiraException e) {
778
				return false;
779
			}
780
			currentIssue.setProject(client.getCache().getProjectById(currentIssue.getProject().getId()));
781
			version = currentIssue.getProject().getVersion(currentElementText);
782
			if (version != null) {
783
				versions.add(version);
784
				return true;
785
			}
786
		}
787
		return false;
788
	}
789
790
	private boolean addComponentTo(ArrayList<Component> versions, String currentElementText) {
791
		Component version = currentIssue.getProject().getComponent(currentElementText);
792
		if (version != null) {
793
			versions.add(version);
794
			return true;
795
		} else {
796
			try {
797
				client.getCache().refreshProjectDetails(currentIssue.getProject().getId(), new NullProgressMonitor());
798
			} catch (JiraException e) {
799
				return false;
800
			}
801
			currentIssue.setProject(client.getCache().getProjectById(currentIssue.getProject().getId()));
802
			version = currentIssue.getProject().getComponent(currentElementText);
803
			if (version != null) {
804
				versions.add(version);
805
				return true;
806
			}
807
		}
808
		return false;
809
	}
810
781
	@Override
811
	@Override
782
	public void characters(char[] ch, int start, int length) throws SAXException {
812
	public void characters(char[] ch, int start, int length) throws SAXException {
783
		currentElementText.append(ch, start, length);
813
		currentElementText.append(ch, start, length);
(-)src/org/eclipse/mylyn/internal/jira/ui/wizards/messages.properties (+1 lines)
Lines 67-72 Link Here
67
JiraProjectPage_Pick_a_project_to_open_the_new_bug_editor=Pick a project to open the new bug editor.\n\
67
JiraProjectPage_Pick_a_project_to_open_the_new_bug_editor=Pick a project to open the new bug editor.\n\
68
Press the Update button if the project is not in the list.
68
Press the Update button if the project is not in the list.
69
JiraProjectPage_Update_Projects_from_Repository=Update Projects from Repository
69
JiraProjectPage_Update_Projects_from_Repository=Update Projects from Repository
70
JiraProjectPage_This_project_has_details_missing=You need to be online to create a task for this project as it is missing required details which will be downloaded
70
71
71
JiraRepositorySettingsPage_Advanced_Configuration=Advanced &Configuration
72
JiraRepositorySettingsPage_Advanced_Configuration=Advanced &Configuration
72
JiraRepositorySettingsPage_Authentication_credentials_are_valid_character_encodeing=Authentication credentials are valid. Note: The character encoding could not be determined, verify 'Additional Settings'.
73
JiraRepositorySettingsPage_Authentication_credentials_are_valid_character_encodeing=Authentication credentials are valid. Note: The character encoding could not be determined, verify 'Additional Settings'.
(-)src/org/eclipse/mylyn/internal/jira/ui/wizards/NewJiraTaskWizard.java (-1 / +38 lines)
Lines 12-19 Link Here
12
12
13
package org.eclipse.mylyn.internal.jira.ui.wizards;
13
package org.eclipse.mylyn.internal.jira.ui.wizards;
14
14
15
import org.eclipse.core.runtime.CoreException;
16
import org.eclipse.core.runtime.IProgressMonitor;
17
import org.eclipse.core.runtime.OperationCanceledException;
15
import org.eclipse.jface.viewers.IStructuredSelection;
18
import org.eclipse.jface.viewers.IStructuredSelection;
19
import org.eclipse.mylyn.internal.jira.core.JiraClientFactory;
20
import org.eclipse.mylyn.internal.jira.core.JiraCorePlugin;
16
import org.eclipse.mylyn.internal.jira.core.model.Project;
21
import org.eclipse.mylyn.internal.jira.core.model.Project;
22
import org.eclipse.mylyn.internal.jira.core.service.JiraClient;
23
import org.eclipse.mylyn.internal.jira.core.service.JiraException;
24
import org.eclipse.mylyn.internal.provisional.commons.ui.CommonUiUtil;
25
import org.eclipse.mylyn.internal.provisional.commons.ui.ICoreRunnable;
17
import org.eclipse.mylyn.tasks.core.ITaskMapping;
26
import org.eclipse.mylyn.tasks.core.ITaskMapping;
18
import org.eclipse.mylyn.tasks.core.TaskMapping;
27
import org.eclipse.mylyn.tasks.core.TaskMapping;
19
import org.eclipse.mylyn.tasks.core.TaskRepository;
28
import org.eclipse.mylyn.tasks.core.TaskRepository;
Lines 47-56 Link Here
47
	@Override
56
	@Override
48
	protected ITaskMapping getInitializationData() {
57
	protected ITaskMapping getInitializationData() {
49
		final Project project = projectPage.getSelectedProject();
58
		final Project project = projectPage.getSelectedProject();
59
		if (project != null && !project.hasDetails()) {
60
			ICoreRunnable runner = new ICoreRunnable() {
61
				public void run(IProgressMonitor monitor) throws CoreException {
62
					try {
63
						JiraClient client = JiraClientFactory.getDefault().getJiraClient(getTaskRepository());
64
						client.getCache().refreshProjectDetails(project.getId(), monitor);
65
					} catch (JiraException e) {
66
						throw new CoreException(JiraCorePlugin.toStatus(getTaskRepository(), e));
67
					}
68
				}
69
			};
70
71
			try {
72
				if (getContainer().getShell().isVisible()) {
73
					CommonUiUtil.run(getContainer(), runner);
74
				} else {
75
					CommonUiUtil.busyCursorWhile(runner);
76
				}
77
			} catch (OperationCanceledException e) {
78
				return null;
79
			} catch (CoreException e) {
80
				return null;
81
			}
82
		}
50
		return new TaskMapping() {
83
		return new TaskMapping() {
51
			@Override
84
			@Override
52
			public String getProduct() {
85
			public String getProduct() {
53
				return project.getKey();
86
				if (project != null) {
87
					return project.getKey();
88
				} else {
89
					return null;
90
				}
54
			}
91
			}
55
		};
92
		};
56
	}
93
	}
(-)src/org/eclipse/mylyn/internal/jira/ui/wizards/Messages.java (+2 lines)
Lines 194-197 Link Here
194
	public static String JiraRepositorySettingsPage_working_hours_per_day;
194
	public static String JiraRepositorySettingsPage_working_hours_per_day;
195
195
196
	public static String JiraRepositorySettingsPage_Validate_server_settings;
196
	public static String JiraRepositorySettingsPage_Validate_server_settings;
197
198
	public static String JiraProjectPage_This_project_has_details_missing;
197
}
199
}
(-)src/org/eclipse/mylyn/internal/jira/ui/wizards/JiraFilterDefinitionPage.java (-71 / +115 lines)
Lines 189-194 Link Here
189
189
190
	private static final Project[] NO_PROJECTS = new Project[0];
190
	private static final Project[] NO_PROJECTS = new Project[0];
191
191
192
	private static final int HEIGHT_HINT = 50;
193
194
	private static final int WIDTH_HINT = 150;
195
192
	final Placeholder ALL_PROJECTS = new Placeholder(Messages.JiraFilterDefinitionPage_All_Projects);
196
	final Placeholder ALL_PROJECTS = new Placeholder(Messages.JiraFilterDefinitionPage_All_Projects);
193
197
194
	final Placeholder ANY_ASSIGNEE = new Placeholder(Messages.JiraFilterDefinitionPage_Any);
198
	final Placeholder ANY_ASSIGNEE = new Placeholder(Messages.JiraFilterDefinitionPage_Any);
Lines 626-633 Link Here
626
	private void createComponentsViewer(Composite c) {
630
	private void createComponentsViewer(Composite c) {
627
		components = new ListViewer(c, SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.H_SCROLL);
631
		components = new ListViewer(c, SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.H_SCROLL);
628
		GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
632
		GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
629
		gridData.heightHint = 50;
633
		gridData.heightHint = HEIGHT_HINT;
630
		gridData.widthHint = 90;
634
		gridData.widthHint = WIDTH_HINT;
631
		components.getControl().setLayoutData(gridData);
635
		components.getControl().setLayoutData(gridData);
632
636
633
		components.setContentProvider(new IStructuredContentProvider() {
637
		components.setContentProvider(new IStructuredContentProvider() {
Lines 642-655 Link Here
642
646
643
			public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
647
			public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
644
				Project[] projects = (Project[]) newInput;
648
				Project[] projects = (Project[]) newInput;
645
				if (projects == null || projects.length == 0) {
649
				if (projects == null || projects.length == 0 || projects.length > 1) {
646
					currentElements = new Object[] { ANY_COMPONENT };
650
					currentElements = new Object[] { ANY_COMPONENT };
647
				} else {
651
				} else {
648
					Set<Object> elements = new LinkedHashSet<Object>();
652
					Set<Object> elements = new LinkedHashSet<Object>();
649
					elements.add(ANY_COMPONENT);
653
					elements.add(ANY_COMPONENT);
650
					elements.add(NO_COMPONENT);
654
					elements.add(NO_COMPONENT);
651
					for (Project project : projects) {
655
					for (Project project : projects) {
652
						if (project != null) {
656
						if (project != null && project.hasDetails()) {
653
							elements.addAll(Arrays.asList(project.getComponents()));
657
							elements.addAll(Arrays.asList(project.getComponents()));
654
						}
658
						}
655
					}
659
					}
Lines 740-751 Link Here
740
		{
744
		{
741
			SashForm cc = new SashForm(sashForm, SWT.NONE);
745
			SashForm cc = new SashForm(sashForm, SWT.NONE);
742
746
743
			ISelectionChangedListener selectionChangeListener = new ISelectionChangedListener() {
744
				public void selectionChanged(SelectionChangedEvent event) {
745
					// validatePage();
746
				}
747
			};
748
749
			{
747
			{
750
				Composite comp = new Composite(cc, SWT.NONE);
748
				Composite comp = new Composite(cc, SWT.NONE);
751
				GridLayout gridLayout = new GridLayout();
749
				GridLayout gridLayout = new GridLayout();
Lines 757-782 Link Here
757
				typeLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false));
755
				typeLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false));
758
				typeLabel.setText(Messages.JiraFilterDefinitionPage_Type);
756
				typeLabel.setText(Messages.JiraFilterDefinitionPage_Type);
759
757
760
				issueType = new ListViewer(comp, SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.H_SCROLL);
758
				createIssueTypesViewer(comp);
761
				GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
762
				gridData.heightHint = 50;
763
				gridData.widthHint = 90;
764
				issueType.getList().setLayoutData(gridData);
765
766
				issueType.setLabelProvider(new LabelProvider() {
767
768
					@Override
769
					public String getText(Object element) {
770
						if (element instanceof Placeholder) {
771
							return ((Placeholder) element).getText();
772
						}
773
774
						return ((IssueType) element).getName();
775
					}
776
777
				});
778
779
				issueType.addSelectionChangedListener(selectionChangeListener);
780
			}
759
			}
781
760
782
			{
761
			{
Lines 792-799 Link Here
792
771
793
				status = new ListViewer(comp, SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.H_SCROLL);
772
				status = new ListViewer(comp, SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.H_SCROLL);
794
				GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
773
				GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
795
				gridData.heightHint = 50;
774
				gridData.heightHint = HEIGHT_HINT;
796
				gridData.widthHint = 90;
775
				gridData.widthHint = WIDTH_HINT;
797
				status.getList().setLayoutData(gridData);
776
				status.getList().setLayoutData(gridData);
798
777
799
				status.setLabelProvider(new LabelProvider() {
778
				status.setLabelProvider(new LabelProvider() {
Lines 808-815 Link Here
808
					}
787
					}
809
788
810
				});
789
				});
811
812
				status.addSelectionChangedListener(selectionChangeListener);
813
			}
790
			}
814
791
815
			{
792
			{
Lines 825-832 Link Here
825
802
826
				resolution = new ListViewer(comp, SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.H_SCROLL);
803
				resolution = new ListViewer(comp, SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.H_SCROLL);
827
				GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
804
				GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
828
				gridData.heightHint = 50;
805
				gridData.heightHint = HEIGHT_HINT;
829
				gridData.widthHint = 90;
806
				gridData.widthHint = WIDTH_HINT;
830
				resolution.getList().setLayoutData(gridData);
807
				resolution.getList().setLayoutData(gridData);
831
808
832
				resolution.setLabelProvider(new LabelProvider() {
809
				resolution.setLabelProvider(new LabelProvider() {
Lines 841-848 Link Here
841
					}
818
					}
842
819
843
				});
820
				});
844
845
				resolution.addSelectionChangedListener(selectionChangeListener);
846
			}
821
			}
847
822
848
			{
823
			{
Lines 858-865 Link Here
858
833
859
				priority = new ListViewer(comp, SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.H_SCROLL);
834
				priority = new ListViewer(comp, SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.H_SCROLL);
860
				GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
835
				GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
861
				gridData.heightHint = 50;
836
				gridData.heightHint = HEIGHT_HINT;
862
				gridData.widthHint = 90;
837
				gridData.widthHint = WIDTH_HINT;
863
				priority.getList().setLayoutData(gridData);
838
				priority.getList().setLayoutData(gridData);
864
839
865
				priority.setLabelProvider(new LabelProvider() {
840
				priority.setLabelProvider(new LabelProvider() {
Lines 874-880 Link Here
874
					}
849
					}
875
850
876
				});
851
				});
877
				priority.addSelectionChangedListener(selectionChangeListener);
878
			}
852
			}
879
853
880
			cc.setWeights(new int[] { 1, 1, 1, 1 });
854
			cc.setWeights(new int[] { 1, 1, 1, 1 });
Lines 1118-1123 Link Here
1118
		Dialog.applyDialogFont(parent);
1092
		Dialog.applyDialogFont(parent);
1119
	}
1093
	}
1120
1094
1095
	private void createIssueTypesViewer(Composite comp) {
1096
		issueType = new ListViewer(comp, SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.H_SCROLL);
1097
		GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
1098
		gridData.heightHint = HEIGHT_HINT;
1099
		gridData.widthHint = WIDTH_HINT;
1100
		issueType.getList().setLayoutData(gridData);
1101
1102
		issueType.setContentProvider(new IStructuredContentProvider() {
1103
			private Object[] currentElements;
1104
1105
			public Object[] getElements(Object inputElement) {
1106
				return currentElements;
1107
			}
1108
1109
			public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
1110
				final Project[] projects = (Project[]) newInput;
1111
				IssueType[] types = null;
1112
1113
				if (projects == null || projects.length == 0 || projects.length > 1) {
1114
					types = client.getCache().getIssueTypes();
1115
				} else if (projects[0].hasDetails()) {
1116
					types = projects[0].getIssueTypes();
1117
				}
1118
1119
				if (types != null) {
1120
					Object[] elements = new Object[types.length + 1];
1121
					System.arraycopy(types, 0, elements, 1, types.length);
1122
					elements[0] = ANY_ISSUE_TYPE;
1123
					currentElements = elements;
1124
				}
1125
			}
1126
1127
			public void dispose() {
1128
			}
1129
		});
1130
1131
		issueType.setLabelProvider(new LabelProvider() {
1132
1133
			@Override
1134
			public String getText(Object element) {
1135
				if (element instanceof Placeholder) {
1136
					return ((Placeholder) element).getText();
1137
				}
1138
1139
				return ((IssueType) element).getName();
1140
			}
1141
1142
		});
1143
1144
		issueType.setInput(NO_PROJECTS);
1145
	}
1146
1121
//	@Override
1147
//	@Override
1122
//	public boolean isPageComplete() {
1148
//	public boolean isPageComplete() {
1123
//		// XXX workaround for bad implementation of AbstractRepositoryQueryPage.isPageComplete()
1149
//		// XXX workaround for bad implementation of AbstractRepositoryQueryPage.isPageComplete()
Lines 1142-1149 Link Here
1142
	private void createFixForViewer(Composite c) {
1168
	private void createFixForViewer(Composite c) {
1143
		fixFor = new ListViewer(c, SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.H_SCROLL);
1169
		fixFor = new ListViewer(c, SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.H_SCROLL);
1144
		GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
1170
		GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
1145
		gridData.heightHint = 50;
1171
		gridData.heightHint = HEIGHT_HINT;
1146
		gridData.widthHint = 90;
1172
		gridData.widthHint = WIDTH_HINT;
1147
		fixFor.getControl().setLayoutData(gridData);
1173
		fixFor.getControl().setLayoutData(gridData);
1148
1174
1149
		fixFor.setContentProvider(new IStructuredContentProvider() {
1175
		fixFor.setContentProvider(new IStructuredContentProvider() {
Lines 1158-1164 Link Here
1158
1184
1159
			public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
1185
			public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
1160
				Project[] projects = (Project[]) newInput;
1186
				Project[] projects = (Project[]) newInput;
1161
				if (projects == null || projects.length == 0) {
1187
				if (projects == null || projects.length == 0 || projects.length > 1) {
1162
					currentElements = new Object[] { ANY_FIX_VERSION };
1188
					currentElements = new Object[] { ANY_FIX_VERSION };
1163
				} else {
1189
				} else {
1164
					List<Object> elements = new ArrayList<Object>();
1190
					List<Object> elements = new ArrayList<Object>();
Lines 1169-1175 Link Here
1169
					Set<Version> unreleasedVersions = new LinkedHashSet<Version>();
1195
					Set<Version> unreleasedVersions = new LinkedHashSet<Version>();
1170
1196
1171
					for (Project project : projects) {
1197
					for (Project project : projects) {
1172
						if (project != null) {
1198
						if (project != null && project.hasDetails()) {
1173
							releasedVersions.addAll(Arrays.asList(project.getReleasedVersions()));
1199
							releasedVersions.addAll(Arrays.asList(project.getReleasedVersions()));
1174
							unreleasedVersions.addAll(Arrays.asList(project.getUnreleasedVersions()));
1200
							unreleasedVersions.addAll(Arrays.asList(project.getUnreleasedVersions()));
1175
						}
1201
						}
Lines 1191-1198 Link Here
1191
	private void createProjectsViewer(Composite c) {
1217
	private void createProjectsViewer(Composite c) {
1192
		project = new ListViewer(c, SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.H_SCROLL);
1218
		project = new ListViewer(c, SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.H_SCROLL);
1193
		GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
1219
		GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
1194
		gridData.heightHint = 50;
1220
		gridData.heightHint = HEIGHT_HINT;
1195
		gridData.widthHint = 90;
1221
		gridData.widthHint = WIDTH_HINT;
1196
		project.getControl().setLayoutData(gridData);
1222
		project.getControl().setLayoutData(gridData);
1197
1223
1198
		project.setLabelProvider(new LabelProvider() {
1224
		project.setLabelProvider(new LabelProvider() {
Lines 1226-1233 Link Here
1226
	private void createReportedInViewer(Composite c) {
1252
	private void createReportedInViewer(Composite c) {
1227
		reportedIn = new ListViewer(c, SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.H_SCROLL);
1253
		reportedIn = new ListViewer(c, SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.H_SCROLL);
1228
		GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
1254
		GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
1229
		gridData.heightHint = 50;
1255
		gridData.heightHint = HEIGHT_HINT;
1230
		gridData.widthHint = 90;
1256
		gridData.widthHint = WIDTH_HINT;
1231
		reportedIn.getControl().setLayoutData(gridData);
1257
		reportedIn.getControl().setLayoutData(gridData);
1232
1258
1233
		reportedIn.setContentProvider(new IStructuredContentProvider() {
1259
		reportedIn.setContentProvider(new IStructuredContentProvider() {
Lines 1242-1248 Link Here
1242
1268
1243
			public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
1269
			public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
1244
				Project[] projects = (Project[]) newInput;
1270
				Project[] projects = (Project[]) newInput;
1245
				if (projects == null || projects.length == 0) {
1271
				if (projects == null || projects.length == 0 || projects.length > 1) {
1246
					currentElements = new Object[] { ANY_REPORTED_VERSION };
1272
					currentElements = new Object[] { ANY_REPORTED_VERSION };
1247
				} else {
1273
				} else {
1248
					List<Object> elements = new ArrayList<Object>();
1274
					List<Object> elements = new ArrayList<Object>();
Lines 1253-1259 Link Here
1253
					Set<Object> unreleasedVersions = new LinkedHashSet<Object>();
1279
					Set<Object> unreleasedVersions = new LinkedHashSet<Object>();
1254
1280
1255
					for (Project project : projects) {
1281
					for (Project project : projects) {
1256
						if (project != null) {
1282
						if (project != null && project.hasDetails()) {
1257
							releasedVersions.addAll(Arrays.asList(project.getReleasedVersions()));
1283
							releasedVersions.addAll(Arrays.asList(project.getReleasedVersions()));
1258
							unreleasedVersions.addAll(Arrays.asList(project.getUnreleasedVersions()));
1284
							unreleasedVersions.addAll(Arrays.asList(project.getUnreleasedVersions()));
1259
						}
1285
						}
Lines 1330-1355 Link Here
1330
		});
1356
		});
1331
		project.setInput(client);
1357
		project.setInput(client);
1332
1358
1333
		issueType.setContentProvider(new IStructuredContentProvider() {
1334
1335
			public void dispose() {
1336
			}
1337
1338
			public Object[] getElements(Object inputElement) {
1339
				JiraClient server = (JiraClient) inputElement;
1340
				Object[] elements = new Object[server.getCache().getIssueTypes().length + 1];
1341
				elements[0] = ANY_ISSUE_TYPE;
1342
				System.arraycopy(server.getCache().getIssueTypes(), 0, elements, 1,
1343
						server.getCache().getIssueTypes().length);
1344
1345
				return elements;
1346
			}
1347
1348
			public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
1349
			}
1350
		});
1351
		issueType.setInput(client);
1352
1353
		status.setContentProvider(new IStructuredContentProvider() {
1359
		status.setContentProvider(new IStructuredContentProvider() {
1354
1360
1355
			public void dispose() {
1361
			public void dispose() {
Lines 1699-1706 Link Here
1699
	}
1705
	}
1700
1706
1701
	void updateCurrentProjects(Project[] projects) {
1707
	void updateCurrentProjects(Project[] projects) {
1708
		if (projects != null) {
1709
			for (final Project project : projects) {
1710
				if (!project.hasDetails()) {
1711
					IRunnableWithProgress updateProjectDetails = new IRunnableWithProgress() {
1712
						public void run(IProgressMonitor monitor) throws InvocationTargetException,
1713
								InterruptedException {
1714
							try {
1715
								client.getCache().refreshProjectDetails(project.getId(), monitor);
1716
							} catch (final JiraException e) {
1717
								Display.getDefault().asyncExec(new Runnable() {
1718
									public void run() {
1719
										JiraFilterDefinitionPage.this.setErrorMessage(NLS.bind(
1720
												Messages.JiraFilterDefinitionPage_Error_updating_attributes_X,
1721
												e.getMessage()));
1722
									}
1723
								});
1724
							}
1725
						}
1726
					};
1727
1728
					try {
1729
						if (getContainer() != null) {
1730
							getContainer().run(true, true, updateProjectDetails);
1731
						} else if (getSearchContainer() != null) {
1732
							getSearchContainer().getRunnableContext().run(true, true, updateProjectDetails);
1733
						} else {
1734
							IProgressService service = PlatformUI.getWorkbench().getProgressService();
1735
							service.busyCursorWhile(updateProjectDetails);
1736
						}
1737
					} catch (Exception e) {
1738
						JiraFilterDefinitionPage.this.setErrorMessage(NLS.bind(
1739
								Messages.JiraFilterDefinitionPage_Error_updating_attributes_X, e.getMessage()));
1740
					}
1741
				}
1742
			}
1743
		}
1744
1702
		this.fixFor.setInput(projects);
1745
		this.fixFor.setInput(projects);
1703
		this.components.setInput(projects);
1746
		this.components.setInput(projects);
1704
		this.reportedIn.setInput(projects);
1747
		this.reportedIn.setInput(projects);
1748
		this.issueType.setInput(projects);
1705
	}
1749
	}
1706
}
1750
}
(-)src/org/eclipse/mylyn/internal/jira/ui/wizards/JiraProjectPage.java (+16 lines)
Lines 44-49 Link Here
44
import org.eclipse.mylyn.internal.jira.core.service.JiraException;
44
import org.eclipse.mylyn.internal.jira.core.service.JiraException;
45
import org.eclipse.mylyn.internal.jira.core.util.JiraUtil;
45
import org.eclipse.mylyn.internal.jira.core.util.JiraUtil;
46
import org.eclipse.mylyn.internal.jira.ui.JiraUiPlugin;
46
import org.eclipse.mylyn.internal.jira.ui.JiraUiPlugin;
47
import org.eclipse.mylyn.internal.provisional.commons.ui.CommonImages;
47
import org.eclipse.mylyn.internal.provisional.commons.ui.CommonUiUtil;
48
import org.eclipse.mylyn.internal.provisional.commons.ui.CommonUiUtil;
48
import org.eclipse.mylyn.internal.provisional.commons.ui.EnhancedFilteredTree;
49
import org.eclipse.mylyn.internal.provisional.commons.ui.EnhancedFilteredTree;
49
import org.eclipse.mylyn.internal.provisional.commons.ui.ICoreRunnable;
50
import org.eclipse.mylyn.internal.provisional.commons.ui.ICoreRunnable;
Lines 57-62 Link Here
57
import org.eclipse.swt.SWT;
58
import org.eclipse.swt.SWT;
58
import org.eclipse.swt.events.SelectionAdapter;
59
import org.eclipse.swt.events.SelectionAdapter;
59
import org.eclipse.swt.events.SelectionEvent;
60
import org.eclipse.swt.events.SelectionEvent;
61
import org.eclipse.swt.graphics.Image;
60
import org.eclipse.swt.layout.GridData;
62
import org.eclipse.swt.layout.GridData;
61
import org.eclipse.swt.layout.GridLayout;
63
import org.eclipse.swt.layout.GridLayout;
62
import org.eclipse.swt.widgets.Button;
64
import org.eclipse.swt.widgets.Button;
Lines 127-132 Link Here
127
				}
129
				}
128
				return ""; //$NON-NLS-1$
130
				return ""; //$NON-NLS-1$
129
			}
131
			}
132
133
			@Override
134
			public Image getImage(Object element) {
135
				if (element instanceof Project) {
136
					Project project = (Project) element;
137
					if (!project.hasDetails()) {
138
						return CommonImages.getImage(CommonImages.DISCOVERY);
139
					}
140
				}
141
				return super.getImage(element);
142
			}
130
		});
143
		});
131
144
132
		projectTreeViewer.setContentProvider(new ITreeContentProvider() {
145
		projectTreeViewer.setContentProvider(new ITreeContentProvider() {
Lines 181-188 Link Here
181
			public void selectionChanged(SelectionChangedEvent event) {
194
			public void selectionChanged(SelectionChangedEvent event) {
182
				if (getSelectedProject() == null) {
195
				if (getSelectedProject() == null) {
183
					setErrorMessage(Messages.JiraProjectPage_You_must_select_a_project);
196
					setErrorMessage(Messages.JiraProjectPage_You_must_select_a_project);
197
				} else if (!getSelectedProject().hasDetails()) {
198
					setMessage(Messages.JiraProjectPage_This_project_has_details_missing);
184
				} else {
199
				} else {
185
					setErrorMessage(null);
200
					setErrorMessage(null);
201
					setMessage(null);
186
				}
202
				}
187
				getWizard().getContainer().updateButtons();
203
				getWizard().getContainer().updateButtons();
188
			}
204
			}

Return to bug 290860