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 223173 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/mylyn/internal/trac/core/model/TracTicket.java (-3 / +3 lines)
Lines 81-87 Link Here
81
81
82
	private List<TracAttachment> attachments;
82
	private List<TracAttachment> attachments;
83
83
84
	private String[] actions;
84
	private TracAction[] actions;
85
85
86
	private String[] resolutions;
86
	private String[] resolutions;
87
87
Lines 203-213 Link Here
203
		return (attachments != null) ? attachments.toArray(new TracAttachment[0]) : null;
203
		return (attachments != null) ? attachments.toArray(new TracAttachment[0]) : null;
204
	}
204
	}
205
205
206
	public void setActions(String[] actions) {
206
	public void setActions(TracAction[] actions) {
207
		this.actions = actions;
207
		this.actions = actions;
208
	}
208
	}
209
209
210
	public String[] getActions() {
210
	public TracAction[] getActions() {
211
		return actions;
211
		return actions;
212
	}
212
	}
213
213
(-)src/org/eclipse/mylyn/internal/trac/core/TracTaskDataHandler.java (-26 / +20 lines)
Lines 9-15 Link Here
9
package org.eclipse.mylyn.internal.trac.core;
9
package org.eclipse.mylyn.internal.trac.core;
10
10
11
import java.util.ArrayList;
11
import java.util.ArrayList;
12
import java.util.Arrays;
13
import java.util.Collection;
12
import java.util.Collection;
14
import java.util.Date;
13
import java.util.Date;
15
import java.util.HashSet;
14
import java.util.HashSet;
Lines 25-30 Link Here
25
import org.eclipse.mylyn.commons.net.Policy;
24
import org.eclipse.mylyn.commons.net.Policy;
26
import org.eclipse.mylyn.internal.trac.core.client.ITracClient;
25
import org.eclipse.mylyn.internal.trac.core.client.ITracClient;
27
import org.eclipse.mylyn.internal.trac.core.client.InvalidTicketException;
26
import org.eclipse.mylyn.internal.trac.core.client.InvalidTicketException;
27
import org.eclipse.mylyn.internal.trac.core.model.TracAction;
28
import org.eclipse.mylyn.internal.trac.core.model.TracAttachment;
28
import org.eclipse.mylyn.internal.trac.core.model.TracAttachment;
29
import org.eclipse.mylyn.internal.trac.core.model.TracComment;
29
import org.eclipse.mylyn.internal.trac.core.model.TracComment;
30
import org.eclipse.mylyn.internal.trac.core.model.TracTicket;
30
import org.eclipse.mylyn.internal.trac.core.model.TracTicket;
Lines 201-241 Link Here
201
			}
201
			}
202
		}
202
		}
203
203
204
		String[] actions = ticket.getActions();
204
		TracAction[] actions = ticket.getActions();
205
		if (actions != null) {
205
		if (actions != null) {
206
			// add operations in a defined order
206
			// add operations in a defined order
207
			List<String> actionList = new ArrayList<String>(Arrays.asList(actions));
207
			for (TracAction action : actions) {
208
			addOperation(repository, data, ticket, actionList, "leave");
208
				addOperation(repository, data, ticket, action);
209
			addOperation(repository, data, ticket, actionList, "accept");
209
			}
210
			addOperation(repository, data, ticket, actionList, "resolve");
211
			addOperation(repository, data, ticket, actionList, "reopen");
212
		}
210
		}
213
211
214
		return changedAttributes;
212
		return changedAttributes;
215
	}
213
	}
216
214
217
	private static void addOperation(TaskRepository repository, TaskData data, TracTicket ticket, List<String> actions,
215
	private static void addOperation(TaskRepository repository, TaskData data, TracTicket ticket, TracAction action) {
218
			String action) {
216
		String label = action.getName();
219
		if (!actions.remove(action)) {
217
		if (label == null) {
220
			return;
218
			if ("leave".equals(action)) {
221
		}
219
				// TODO provide better label for Leave action
222
220
				//label = "Leave as " + data.getStatus() + " " + data.getResolution();
223
		String label = null;
221
				label = "Leave";
224
		if ("leave".equals(action)) {
222
			} else if ("accept".equals(action)) {
225
			// TODO provide better label for Leave action
223
				label = "Accept";
226
			//label = "Leave as " + data.getStatus() + " " + data.getResolution();
224
			} else if ("resolve".equals(action)) {
227
			label = "Leave";
225
				label = "Resolve as";
228
		} else if ("accept".equals(action)) {
226
			} else if ("reopen".equals(action)) {
229
			label = "Accept";
227
				label = "Reopen";
230
		} else if ("resolve".equals(action)) {
228
			}
231
			label = "Resolve as";
232
		} else if ("reopen".equals(action)) {
233
			label = "Reopen";
234
		}
229
		}
235
236
		if (label != null) {
230
		if (label != null) {
237
			TaskAttribute attribute = data.getRoot().createAttribute(TaskAttribute.PREFIX_OPERATION + action);
231
			TaskAttribute attribute = data.getRoot().createAttribute(TaskAttribute.PREFIX_OPERATION + action);
238
			TaskOperation.applyTo(attribute, action, label);
232
			TaskOperation.applyTo(attribute, action.getId(), label);
239
			if ("resolve".equals(action)) {
233
			if ("resolve".equals(action)) {
240
				attribute.getMetaData().putValue(TaskAttribute.META_ASSOCIATED_ATTRIBUTE_ID,
234
				attribute.getMetaData().putValue(TaskAttribute.META_ASSOCIATED_ATTRIBUTE_ID,
241
						TracAttribute.RESOLUTION.getTracKey());
235
						TracAttribute.RESOLUTION.getTracKey());
(-)src/org/eclipse/mylyn/internal/trac/core/client/TracXmlRpcClient.java (-15 / +29 lines)
Lines 43-48 Link Here
43
import org.eclipse.mylyn.commons.net.UnsupportedRequestException;
43
import org.eclipse.mylyn.commons.net.UnsupportedRequestException;
44
import org.eclipse.mylyn.commons.net.WebUtil;
44
import org.eclipse.mylyn.commons.net.WebUtil;
45
import org.eclipse.mylyn.internal.trac.core.TracCorePlugin;
45
import org.eclipse.mylyn.internal.trac.core.TracCorePlugin;
46
import org.eclipse.mylyn.internal.trac.core.model.TracAction;
46
import org.eclipse.mylyn.internal.trac.core.model.TracAttachment;
47
import org.eclipse.mylyn.internal.trac.core.model.TracAttachment;
47
import org.eclipse.mylyn.internal.trac.core.model.TracComment;
48
import org.eclipse.mylyn.internal.trac.core.model.TracComment;
48
import org.eclipse.mylyn.internal.trac.core.model.TracComponent;
49
import org.eclipse.mylyn.internal.trac.core.model.TracComponent;
Lines 362-368 Link Here
362
			ticket.addAttachment(parseAttachment((Object[]) item));
363
			ticket.addAttachment(parseAttachment((Object[]) item));
363
		}
364
		}
364
365
365
		String[] actions = getActions(id, monitor);
366
		TracAction[] actions = getActions(id, monitor);
366
		ticket.setActions(actions);
367
		ticket.setActions(actions);
367
368
368
		updateAttributes(new NullProgressMonitor(), false);
369
		updateAttributes(new NullProgressMonitor(), false);
Lines 738-750 Link Here
738
		return result;
739
		return result;
739
	}
740
	}
740
741
741
	public String[] getActions(int id, IProgressMonitor monitor) throws TracException {
742
	public TracAction[] getActions(int id, IProgressMonitor monitor) throws TracException {
742
		Object[] actions = (Object[]) call(monitor, "ticket.getAvailableActions", id);
743
		if (isAPIVersionOrHigher(1, 0, 1, monitor)) {
743
		String[] result = new String[actions.length];
744
			Object[] actions = (Object[]) call(monitor, "ticket.getAvailableActions2", id);
744
		for (int i = 0; i < result.length; i++) {
745
			TracAction[] result = new TracAction[actions.length];
745
			result[i] = (String) actions[i];
746
			for (int i = 0; i < result.length; i++) {
747
				Object[] entry = (Object[]) actions[i];
748
				TracAction action = new TracAction((String) entry[1]);
749
				action.setName((String) entry[2]);
750
				action.setHint((String) entry[3]);
751
				result[i] = action;
752
			}
753
			return result;
754
		} else {
755
			Object[] actions = (Object[]) call(monitor, "ticket.getAvailableActions", id);
756
			TracAction[] result = new TracAction[actions.length];
757
			for (int i = 0; i < result.length; i++) {
758
				result[i] = new TracAction((String) actions[i]);
759
			}
760
			return result;
746
		}
761
		}
747
		return result;
748
	}
762
	}
749
763
750
	public Date getTicketLastChanged(Integer id, IProgressMonitor monitor) throws TracException {
764
	public Date getTicketLastChanged(Integer id, IProgressMonitor monitor) throws TracException {
Lines 913-931 Link Here
913
	 * This implementation uses the wiki.putAttachmentEx() call, which provides a richer functionality specific to Trac.
927
	 * This implementation uses the wiki.putAttachmentEx() call, which provides a richer functionality specific to Trac.
914
	 * 
928
	 * 
915
	 * @param pageName
929
	 * @param pageName
916
	 * 		the name of the Wiki page
930
	 *            the name of the Wiki page
917
	 * @param fileName
931
	 * @param fileName
918
	 * 		the name of the file to be attached
932
	 *            the name of the file to be attached
919
	 * @param description
933
	 * @param description
920
	 * 		the description of the attachment
934
	 *            the description of the attachment
921
	 * @param in
935
	 * @param in
922
	 * 		An InputStream of the content of the attachment
936
	 *            An InputStream of the content of the attachment
923
	 * @param replace
937
	 * @param replace
924
	 * 		whether to overwrite an existing attachment with the same filename
938
	 *            whether to overwrite an existing attachment with the same filename
925
	 * @return The (possibly transformed) filename of the attachment. If <code>replace</code> is <code>true</code>, the
939
	 * @return The (possibly transformed) filename of the attachment. If <code>replace</code> is <code>true</code>, the
926
	 * 	returned name is always the same as the argument <code>fileName</code>; if <code>replace</code> is
940
	 *         returned name is always the same as the argument <code>fileName</code>; if <code>replace</code> is
927
	 * 	<code>false</code> and an attachment with name <code>fileName</code> already exists, a number is appended to the
941
	 *         <code>false</code> and an attachment with name <code>fileName</code> already exists, a number is appended
928
	 * 	file name (before suffix) and the generated filename of the attachment is returned.
942
	 *         to the file name (before suffix) and the generated filename of the attachment is returned.
929
	 * @throws TracException
943
	 * @throws TracException
930
	 */
944
	 */
931
	public String putWikiPageAttachmentData(String pageName, String fileName, String description, InputStream in,
945
	public String putWikiPageAttachmentData(String pageName, String fileName, String description, InputStream in,
(-)src/org/eclipse/mylyn/internal/trac/core/model/TracAction.java (+72 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2007 Mylyn project committers and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *******************************************************************************/
8
9
package org.eclipse.mylyn.internal.trac.core.model;
10
11
import java.util.Map;
12
13
/**
14
 * @author Steffen Pingel
15
 */
16
public class TracAction {
17
18
	private Map<String, String> fields;
19
20
	private String hint;
21
22
	private String id;
23
24
	private String name;
25
26
	private String value;
27
28
	public TracAction(String id) {
29
		this.id = id;
30
	}
31
32
	public Map<String, String> getFields() {
33
		return fields;
34
	}
35
36
	public String getHint() {
37
		return hint;
38
	}
39
40
	public String getId() {
41
		return id;
42
	}
43
44
	public String getName() {
45
		return name;
46
	}
47
48
	public String getValue() {
49
		return value;
50
	}
51
52
	public void setFields(Map<String, String> fields) {
53
		this.fields = fields;
54
	}
55
56
	public void setHint(String hint) {
57
		this.hint = hint;
58
	}
59
60
	public void setId(String id) {
61
		this.id = id;
62
	}
63
64
	public void setName(String name) {
65
		this.name = name;
66
	}
67
68
	public void setValue(String value) {
69
		this.value = value;
70
	}
71
72
}

Return to bug 223173