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 84-90 Link Here
84
84
85
	private List<TracAttachment> attachments;
85
	private List<TracAttachment> attachments;
86
86
87
	private String[] actions;
87
	private TracAction[] actions;
88
88
89
	private String[] resolutions;
89
	private String[] resolutions;
90
90
Lines 206-216 Link Here
206
		return (attachments != null) ? attachments.toArray(new TracAttachment[0]) : null;
206
		return (attachments != null) ? attachments.toArray(new TracAttachment[0]) : null;
207
	}
207
	}
208
208
209
	public void setActions(String[] actions) {
209
	public void setActions(TracAction[] actions) {
210
		this.actions = actions;
210
		this.actions = actions;
211
	}
211
	}
212
212
213
	public String[] getActions() {
213
	public TracAction[] getActions() {
214
		return actions;
214
		return actions;
215
	}
215
	}
216
216
(-)src/org/eclipse/mylyn/internal/trac/core/TracTaskDataHandler.java (-26 / +21 lines)
Lines 12-18 Link Here
12
package org.eclipse.mylyn.internal.trac.core;
12
package org.eclipse.mylyn.internal.trac.core;
13
13
14
import java.util.ArrayList;
14
import java.util.ArrayList;
15
import java.util.Arrays;
16
import java.util.Collection;
15
import java.util.Collection;
17
import java.util.Date;
16
import java.util.Date;
18
import java.util.HashSet;
17
import java.util.HashSet;
Lines 28-33 Link Here
28
import org.eclipse.mylyn.commons.net.Policy;
27
import org.eclipse.mylyn.commons.net.Policy;
29
import org.eclipse.mylyn.internal.trac.core.client.ITracClient;
28
import org.eclipse.mylyn.internal.trac.core.client.ITracClient;
30
import org.eclipse.mylyn.internal.trac.core.client.InvalidTicketException;
29
import org.eclipse.mylyn.internal.trac.core.client.InvalidTicketException;
30
import org.eclipse.mylyn.internal.trac.core.model.TracAction;
31
import org.eclipse.mylyn.internal.trac.core.model.TracAttachment;
31
import org.eclipse.mylyn.internal.trac.core.model.TracAttachment;
32
import org.eclipse.mylyn.internal.trac.core.model.TracComment;
32
import org.eclipse.mylyn.internal.trac.core.model.TracComment;
33
import org.eclipse.mylyn.internal.trac.core.model.TracTicket;
33
import org.eclipse.mylyn.internal.trac.core.model.TracTicket;
Lines 208-248 Link Here
208
			}
208
			}
209
		}
209
		}
210
210
211
		String[] actions = ticket.getActions();
211
		TracAction[] actions = ticket.getActions();
212
		if (actions != null) {
212
		if (actions != null) {
213
			// add operations in a defined order
213
			for (TracAction action : actions) {
214
			List<String> actionList = new ArrayList<String>(Arrays.asList(actions));
214
				addOperation(repository, data, ticket, action);
215
			addOperation(repository, data, ticket, actionList, "leave"); //$NON-NLS-1$
215
			}
216
			addOperation(repository, data, ticket, actionList, "accept"); //$NON-NLS-1$
217
			addOperation(repository, data, ticket, actionList, "resolve"); //$NON-NLS-1$
218
			addOperation(repository, data, ticket, actionList, "reopen"); //$NON-NLS-1$
219
		}
216
		}
220
217
221
		return changedAttributes;
218
		return changedAttributes;
222
	}
219
	}
223
220
224
	private static void addOperation(TaskRepository repository, TaskData data, TracTicket ticket, List<String> actions,
221
	private static void addOperation(TaskRepository repository, TaskData data, TracTicket ticket, TracAction action) {
225
			String action) {
222
		String label = action.getName();
226
		if (!actions.remove(action)) {
223
		if (label == null) {
227
			return;
224
			if ("leave".equals(action.getId())) { //$NON-NLS-1$
228
		}
225
				// TODO provide better label for Leave action
229
226
				//label = "Leave as " + data.getStatus() + " " + data.getResolution();
230
		String label = null;
227
				label = "Leave";
231
		if ("leave".equals(action)) { //$NON-NLS-1$
228
			} else if ("accept".equals(action.getId())) { //$NON-NLS-1$
232
			// TODO provide better label for Leave action
229
				label = "Accept";
233
			//label = "Leave as " + data.getStatus() + " " + data.getResolution();
230
			} else if ("resolve".equals(action.getId())) { //$NON-NLS-1$
234
			label = "Leave"; //$NON-NLS-1$
231
				label = "Resolve as";
235
		} else if ("accept".equals(action)) { //$NON-NLS-1$
232
			} else if ("reopen".equals(action.getId())) { //$NON-NLS-1$
236
			label = "Accept"; //$NON-NLS-1$
233
				label = "Reopen";
237
		} else if ("resolve".equals(action)) { //$NON-NLS-1$
234
			}
238
			label = "Resolve as"; //$NON-NLS-1$
239
		} else if ("reopen".equals(action)) { //$NON-NLS-1$
240
			label = "Reopen"; //$NON-NLS-1$
241
		}
235
		}
242
236
243
		if (label != null) {
237
		if (label != null) {
244
			TaskAttribute attribute = data.getRoot().createAttribute(TaskAttribute.PREFIX_OPERATION + action);
238
			TaskAttribute attribute = data.getRoot().createAttribute(TaskAttribute.PREFIX_OPERATION + action);
245
			TaskOperation.applyTo(attribute, action, label);
239
			TaskOperation.applyTo(attribute, action.getId(), label);
246
			if ("resolve".equals(action)) { //$NON-NLS-1$
240
			if ("resolve".equals(action)) { //$NON-NLS-1$
247
				attribute.getMetaData().putValue(TaskAttribute.META_ASSOCIATED_ATTRIBUTE_ID,
241
				attribute.getMetaData().putValue(TaskAttribute.META_ASSOCIATED_ATTRIBUTE_ID,
248
						TracAttribute.RESOLUTION.getTracKey());
242
						TracAttribute.RESOLUTION.getTracKey());
Lines 551-556 Link Here
551
					ticket.putValue("status", TracRepositoryConnector.TaskStatus.NEW.toStatusString()); //$NON-NLS-1$
545
					ticket.putValue("status", TracRepositoryConnector.TaskStatus.NEW.toStatusString()); //$NON-NLS-1$
552
				}
546
				}
553
			}
547
			}
548
			ticket.putValue("action", action); //$NON-NLS-1$
554
		}
549
		}
555
550
556
		return ticket;
551
		return ticket;
(-)src/org/eclipse/mylyn/internal/trac/core/client/TracXmlRpcClient.java (-7 / +29 lines)
Lines 55-60 Link Here
55
import org.eclipse.mylyn.commons.net.UnsupportedRequestException;
55
import org.eclipse.mylyn.commons.net.UnsupportedRequestException;
56
import org.eclipse.mylyn.commons.net.WebUtil;
56
import org.eclipse.mylyn.commons.net.WebUtil;
57
import org.eclipse.mylyn.internal.trac.core.TracCorePlugin;
57
import org.eclipse.mylyn.internal.trac.core.TracCorePlugin;
58
import org.eclipse.mylyn.internal.trac.core.model.TracAction;
58
import org.eclipse.mylyn.internal.trac.core.model.TracAttachment;
59
import org.eclipse.mylyn.internal.trac.core.model.TracAttachment;
59
import org.eclipse.mylyn.internal.trac.core.model.TracComment;
60
import org.eclipse.mylyn.internal.trac.core.model.TracComment;
60
import org.eclipse.mylyn.internal.trac.core.model.TracComponent;
61
import org.eclipse.mylyn.internal.trac.core.model.TracComponent;
Lines 461-467 Link Here
461
			ticket.addAttachment(parseAttachment((Object[]) item));
462
			ticket.addAttachment(parseAttachment((Object[]) item));
462
		}
463
		}
463
464
464
		String[] actions = getActions(id, monitor);
465
		TracAction[] actions = getActions(id, monitor);
465
		ticket.setActions(actions);
466
		ticket.setActions(actions);
466
467
467
		updateAttributes(new NullProgressMonitor(), false);
468
		updateAttributes(new NullProgressMonitor(), false);
Lines 860-872 Link Here
860
		return result;
861
		return result;
861
	}
862
	}
862
863
863
	public String[] getActions(int id, IProgressMonitor monitor) throws TracException {
864
	public TracAction[] getActions(int id, IProgressMonitor monitor) throws TracException {
864
		Object[] actions = (Object[]) call(monitor, "ticket.getAvailableActions", id); //$NON-NLS-1$
865
		if (supportsWorkFlow(monitor)) {
865
		String[] result = new String[actions.length];
866
			Object[] actions = (Object[]) call(monitor, "ticket.getActions", id); //$NON-NLS-1$
866
		for (int i = 0; i < result.length; i++) {
867
			TracAction[] result = new TracAction[actions.length];
867
			result[i] = (String) actions[i];
868
			for (int i = 0; i < result.length; i++) {
869
				Object[] entry = (Object[]) actions[i];
870
				TracAction action = new TracAction((String) entry[0]);
871
				action.setName((String) entry[0]); // FIXME pretty name
872
				//action.setHint((String) entry[3]);
873
				Object[] inputs = (Object[]) entry[1];
874
				for (Object input2 : inputs) {
875
					Object[] input = (Object[]) input2;
876
					//String defaultValue = input[1];
877
					Object[] options = (Object[]) input[2];
878
					for (Object option : options) {
879
					}
880
				}
881
				result[i] = action;
882
			}
883
			return result;
884
		} else {
885
			Object[] actions = (Object[]) call(monitor, "ticket.getAvailableActions", id); //$NON-NLS-1$
886
			TracAction[] result = new TracAction[actions.length];
887
			for (int i = 0; i < result.length; i++) {
888
				result[i] = new TracAction((String) actions[i]);
889
			}
890
			return result;
868
		}
891
		}
869
		return result;
870
	}
892
	}
871
893
872
	public Date getTicketLastChanged(Integer id, IProgressMonitor monitor) throws TracException {
894
	public Date getTicketLastChanged(Integer id, IProgressMonitor monitor) throws TracException {
(-)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