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

Collapse All | Expand All

(-)feature.xml (-15 / +8 lines)
Lines 1-10 Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
1
<?xml version="1.0" encoding="UTF-8"?>
2
<feature
2
<feature
3
      id="org.eclipse.mylar.xplanner_feature"
3
      id="org.eclipse.mylyn.xplanner_feature"
4
      label="%featureLabel"
4
      label="%featureLabel"
5
      version="2.0.0.qualifier"
5
      version="2.0.0.qualifier"
6
      provider-name="Eclipse.org"
6
      provider-name="Eclipse.org"
7
      plugin="org.eclipse.mylar.xplanner.ui">
7
      plugin="org.eclipse.mylyn.xplanner.ui">
8
8
9
   <description>
9
   <description>
10
      %featureDescription
10
      %featureDescription
Lines 214-244 Link Here
214
   </license>
214
   </license>
215
215
216
   <url>
216
   <url>
217
      <update label="Mylar for Eclipse 3.2" url="http://download.eclipse.org/technology/mylar/update-site/e3.2"/>
217
      <update label="Mylyn for Eclipse 3.3" url="http://download.eclipse.org/tools/mylyn/update/e3.3"/>
218
   </url>
218
   </url>
219
219
220
   <requires>
220
   <requires>
221
      <import plugin="org.eclipse.ui"/>
221
      <import feature="org.eclipse.mylyn_feature" version="2.0.0.v20070514" match="equivalent"/>
222
      <import plugin="org.eclipse.ui.forms"/>
222
      <import feature="org.eclipse.rcp" version="3.2.2.r322_v20070104-8pcviKVqd8J7C1U" match="compatible"/>
223
      <import plugin="org.eclipse.core.runtime"/>
223
      <import feature="org.eclipse.platform" version="3.2.2.r322_v20070119-RQghndJN8IM0MsK" match="compatible"/>
224
      <import plugin="org.eclipse.mylar.context.core"/>
225
      <import plugin="org.eclipse.mylar.tasks.ui"/>
226
      <import plugin="org.eclipse.mylar.tasks.core"/>
227
      <import plugin="org.eclipse.search"/>
228
      <import plugin="org.eclipse.mylar.monitor.core"/>
229
      <import plugin="org.eclipse.mylar" version="2.0.0.v20070216" match="greaterOrEqual"/>
230
      <import feature="org.eclipse.mylar_feature" version="2.0.0.v20070216" match="greaterOrEqual"/>
231
   </requires>
224
   </requires>
232
225
233
   <plugin
226
   <plugin
234
         id="org.eclipse.mylar.xplanner.ui"
227
         id="org.eclipse.mylyn.xplanner.core"
235
         download-size="0"
228
         download-size="0"
236
         install-size="0"
229
         install-size="0"
237
         version="0.0.0"
230
         version="0.0.0"
238
         unpack="false"/>
231
         unpack="false"/>
239
232
240
   <plugin
233
   <plugin
241
         id="org.eclipse.mylar.xplanner.core"
234
         id="org.eclipse.mylyn.xplanner.ui"
242
         download-size="0"
235
         download-size="0"
243
         install-size="0"
236
         install-size="0"
244
         version="0.0.0"
237
         version="0.0.0"
(-)feature.properties (-2 / +2 lines)
Lines 1-2 Link Here
1
featureLabel=Mylar Connector for XPlanner
1
featureLabel=Mylyn Connector: XPlanner
2
featureDescription=XPlanner client integrated with Eclipse and Mylar, can be used standalone.
2
featureDescription=XPlanner client integrated with Eclipse and Mylyn, can be used standalone.
(-)src/org/eclipse/mylyn/xplanner/core/service/exceptions/InsufficientPermissionException.java (-1 / +1 lines)
Lines 5-11 Link Here
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
package org.eclipse.mylar.xplanner.core.service.exceptions;
8
package org.eclipse.mylyn.xplanner.core.service.exceptions;
9
9
10
/**
10
/**
11
 * @author Ravi Kumar 
11
 * @author Ravi Kumar 
(-)src/org/eclipse/mylyn/xplanner/core/service/exceptions/AuthenticationException.java (-1 / +1 lines)
Lines 5-11 Link Here
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
package org.eclipse.mylar.xplanner.core.service.exceptions;
8
package org.eclipse.mylyn.xplanner.core.service.exceptions;
9
9
10
/**
10
/**
11
 * @author Ravi Kumar 
11
 * @author Ravi Kumar 
(-)src/org/eclipse/mylyn/xplanner/core/service/exceptions/ServiceUnavailableException.java (-1 / +1 lines)
Lines 5-11 Link Here
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
package org.eclipse.mylar.xplanner.core.service.exceptions;
8
package org.eclipse.mylyn.xplanner.core.service.exceptions;
9
9
10
/**
10
/**
11
 * @author Ravi Kumar 
11
 * @author Ravi Kumar 
(-)src/org/eclipse/mylyn/xplanner/core/service/soap/SoapXPlannerService.java (-20 / +20 lines)
Lines 5-31 Link Here
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
package org.eclipse.mylar.xplanner.core.service.soap;
8
package org.eclipse.mylyn.xplanner.core.service.soap;
9
9
10
import java.net.URL;
10
import java.net.URL;
11
import java.rmi.RemoteException;
11
import java.rmi.RemoteException;
12
import java.util.HashMap;
12
import java.util.HashMap;
13
13
14
import org.xplanner.soap.IterationData;
14
import org.apache.axis.client.Stub;
15
import org.xplanner.soap.NoteData;
15
import org.apache.axis.configuration.FileProvider;
16
import org.xplanner.soap.PersonData;
16
import org.eclipse.mylyn.xplanner.core.service.exceptions.AuthenticationException;
17
import org.xplanner.soap.ProjectData;
17
import org.eclipse.mylyn.xplanner.core.service.exceptions.ServiceUnavailableException;
18
import org.xplanner.soap.TaskData;
18
import org.eclipse.mylyn.xplanner.wsdl.db.QueryException;
19
import org.xplanner.soap.TimeEntryData;
19
import org.eclipse.mylyn.xplanner.core.service.XPlannerClient;
20
import org.xplanner.soap.UserStoryData;
20
import org.eclipse.mylyn.xplanner.core.service.XPlannerService;
21
import org.xplanner.soap.*;
21
import org.xplanner.soap.XPlanner.XPlanner;
22
import org.xplanner.soap.XPlanner.XPlanner;
22
import org.xplanner.soap.XPlanner.XPlannerServiceLocator;
23
import org.xplanner.soap.XPlanner.XPlannerServiceLocator;
23
import org.apache.axis.client.Stub;
24
import org.eclipse.mylar.xplanner.core.service.XPlannerServer;
25
import org.eclipse.mylar.xplanner.core.service.XPlannerService;
26
import org.eclipse.mylar.xplanner.core.service.exceptions.AuthenticationException;
27
import org.eclipse.mylar.xplanner.core.service.exceptions.ServiceUnavailableException;
28
import org.eclipse.mylar.xplanner.wsdl.db.QueryException;
29
24
30
25
31
// This class does not represent the data in a XPlanner installation.  It is merely
26
// This class does not represent the data in a XPlanner installation.  It is merely
Lines 43-59 Link Here
43
public class SoapXPlannerService extends XPlannerService {
38
public class SoapXPlannerService extends XPlannerService {
44
39
45
	private static final String SOAP_URL_PREFIX = "/soap/XPlanner"; //$NON-NLS-1$
40
	private static final String SOAP_URL_PREFIX = "/soap/XPlanner"; //$NON-NLS-1$
46
	private XPlannerServer server;
41
	private XPlannerClient client;
47
	private XPlanner service;
42
	private XPlanner service;
48
	boolean loginActive;
43
	boolean loginActive;
49
44
50
	public SoapXPlannerService(XPlannerServer aServer) {
45
	public SoapXPlannerService(XPlannerClient aClient) {
51
		this.server = aServer;
46
		this.client = aClient;
52
		
47
		
53
		try {
48
		try {
54
			XPlannerServiceLocator s = new XPlannerServiceLocator();
49
			XPlannerServiceLocator s = new XPlannerServiceLocator(new FileProvider(this
55
			service = s.getXPlanner(new URL(server.getBaseURL() + SOAP_URL_PREFIX));
50
					.getClass().getClassLoader().getResourceAsStream("client-config.wsdd"))); //$NON-NLS-1$
56
			login(server.getCurrentUserName(), server.getCurrentUserPassword());
51
			s.setHttpUser(client.getHttpUser());
52
			s.setHttpPassword(client.getHttpPassword());
53
			s.setProxy(client.getProxy());
54
			s.setCompression(client.useCompression());
55
			service = s.getXPlanner(new URL(client.getBaseURL() + SOAP_URL_PREFIX));
56
			login(client.getCurrentUserName(), client.getCurrentUserPassword());
57
		} 
57
		} 
58
		catch (Throwable e) {
58
		catch (Throwable e) {
59
			e.printStackTrace();
59
			e.printStackTrace();
(-)src/org/eclipse/mylyn/xplanner/core/service/soap/SoapXPlannerServiceFactory.java (-6 / +5 lines)
Lines 5-15 Link Here
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
package org.eclipse.mylar.xplanner.core.service.soap;
8
package org.eclipse.mylyn.xplanner.core.service.soap;
9
9
10
import org.eclipse.mylar.xplanner.core.service.XPlannerServer;
10
import org.eclipse.mylyn.xplanner.core.service.soap.SoapXPlannerService;
11
import org.eclipse.mylar.xplanner.core.service.XPlannerService;
11
import org.eclipse.mylyn.xplanner.core.service.*;
12
import org.eclipse.mylar.xplanner.core.service.XPlannerServiceFactory;
13
12
14
/**
13
/**
15
 * @author Ravi Kumar 
14
 * @author Ravi Kumar 
Lines 17-25 Link Here
17
 */
16
 */
18
public class SoapXPlannerServiceFactory implements XPlannerServiceFactory {
17
public class SoapXPlannerServiceFactory implements XPlannerServiceFactory {
19
18
20
	public XPlannerService createService(XPlannerServer server) {
19
	public XPlannerService createService(XPlannerClient client) {
21
		// TODO Auto-generated method stub
20
		// TODO Auto-generated method stub
22
		return new SoapXPlannerService(server);
21
		return new SoapXPlannerService(client);
23
	}
22
	}
24
23
25
}
24
}
(-)src/org/eclipse/mylyn/xplanner/core/XPlannerServerListener.java (-2 / +2 lines)
Lines 5-17 Link Here
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
package org.eclipse.mylar.xplanner.core;
8
package org.eclipse.mylyn.xplanner.core;
9
9
10
/**
10
/**
11
 * @author Ravi Kumar
11
 * @author Ravi Kumar
12
 * @author Helen Bershadskaya
12
 * @author Helen Bershadskaya
13
 */
13
 */
14
import org.eclipse.mylar.xplanner.core.service.XPlannerServer;
14
import org.eclipse.mylyn.xplanner.core.service.XPlannerServer;
15
15
16
16
17
public interface XPlannerServerListener {
17
public interface XPlannerServerListener {
(-)src/org/eclipse/mylyn/xplanner/core/IXPlannerCoreExtensionConstants.java (-1 / +1 lines)
Lines 5-11 Link Here
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
package org.eclipse.mylar.xplanner.core;
8
package org.eclipse.mylyn.xplanner.core;
9
9
10
/**
10
/**
11
 * @author Ravi Kumar
11
 * @author Ravi Kumar
(-)src/org/eclipse/mylyn/xplanner/core/XPlannerCorePlugin.java (-18 / +16 lines)
Lines 5-11 Link Here
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
package org.eclipse.mylar.xplanner.core;
8
package org.eclipse.mylyn.xplanner.core;
9
9
10
import java.io.File;
10
import java.io.File;
11
import java.text.MessageFormat;
11
import java.text.MessageFormat;
Lines 14-23 Link Here
14
import java.util.logging.Level;
14
import java.util.logging.Level;
15
import java.util.logging.Logger;
15
import java.util.logging.Logger;
16
16
17
import org.eclipse.core.runtime.IStatus;
17
import org.eclipse.core.runtime.*;
18
import org.eclipse.core.runtime.Plugin;
18
import org.eclipse.mylyn.xplanner.core.service.exceptions.AuthenticationException;
19
import org.eclipse.core.runtime.Status;
20
import org.eclipse.mylar.xplanner.core.service.exceptions.AuthenticationException;
21
import org.osgi.framework.BundleContext;
19
import org.osgi.framework.BundleContext;
22
20
23
/**
21
/**
Lines 27-39 Link Here
27
 * @author Ravi Kumar 
25
 * @author Ravi Kumar 
28
 */
26
 */
29
public class XPlannerCorePlugin extends Plugin {
27
public class XPlannerCorePlugin extends Plugin {
30
	public static final String ID = "org.eclipse.mylar.xplanner.core"; //$NON-NLS-1$
28
	public static final String ID = "org.eclipse.mylyn.xplanner.core"; //$NON-NLS-1$
31
	
29
	
32
	//The shared instance.
30
	//The shared instance.
33
	private static XPlannerCorePlugin plugin;
31
	private static XPlannerCorePlugin plugin;
34
	//Resource bundle.
32
	//Resource bundle.
35
	private ResourceBundle resourceBundle;
33
	private ResourceBundle resourceBundle;
36
	private ServerManager serverManager;
34
	private XPlannerClientManager clientManager;
37
	
35
	
38
	/**
36
	/**
39
	 * The constructor.
37
	 * The constructor.
Lines 48-61 Link Here
48
	 */
46
	 */
49
	public void start(BundleContext context) throws Exception {
47
	public void start(BundleContext context) throws Exception {
50
		super.start(context);
48
		super.start(context);
51
		File serverCache = getStateLocation().append("serverCache").toFile(); //$NON-NLS-1$
49
		File clientCache = getStateLocation().append("serverCache").toFile(); //$NON-NLS-1$
52
		
50
		
53
		// Turn off logging for the Attachment check.  We don't want or need soap with attachments
51
		// Turn off logging for the Attachment check.  We don't want or need soap with attachments
54
		Logger logger = Logger.getLogger("org.apache.axis.utils.JavaUtils"); //$NON-NLS-1$
52
		Logger logger = Logger.getLogger("org.apache.axis.utils.JavaUtils"); //$NON-NLS-1$
55
		logger.setLevel(Level.SEVERE);
53
		logger.setLevel(Level.SEVERE);
56
		
54
		
57
		serverManager = new ServerManager(serverCache);
55
		clientManager = new XPlannerClientManager(clientCache);
58
		serverManager.start();
56
		clientManager.start();
59
	}
57
	}
60
58
61
	/**
59
	/**
Lines 69-76 Link Here
69
		
67
		
70
			public String getPassword(URL baseURL, String username) {
68
			public String getPassword(URL baseURL, String username) {
71
				Map authenticationInfo = Platform.getAuthorizationInfo(baseURL, "XPlanner", ""); //$NON-NLS-1$ //$NON-NLS-2$
69
				Map authenticationInfo = Platform.getAuthorizationInfo(baseURL, "XPlanner", ""); //$NON-NLS-1$ //$NON-NLS-2$
72
//				String username = (String) authenticationInfo.get("org.eclipse.mylar.xplanner.core.username"); //$NON-NLS-1$
70
//				String username = (String) authenticationInfo.get("org.eclipse.mylyn.xplanner.core.username"); //$NON-NLS-1$
73
				String password = (String) authenticationInfo.get("org.eclipse.mylar.xplanner.core.password"); //$NON-NLS-1$
71
				String password = (String) authenticationInfo.get("org.eclipse.mylyn.xplanner.core.password"); //$NON-NLS-1$
74
				return password;
72
				return password;
75
			}
73
			}
76
		
74
		
Lines 83-94 Link Here
83
	public void stop(BundleContext context) throws Exception {
81
	public void stop(BundleContext context) throws Exception {
84
		super.stop(context);
82
		super.stop(context);
85
		
83
		
86
		if (serverManager != null) {
84
		if (clientManager != null) {
87
			serverManager.stop();
85
			clientManager.stop();
88
		}
86
		}
89
		plugin = null;
87
		plugin = null;
90
		resourceBundle = null;
88
		resourceBundle = null;
91
		serverManager = null;
89
		clientManager = null;
92
	}
90
	}
93
91
94
	/**
92
	/**
Lines 98-105 Link Here
98
		return plugin;
96
		return plugin;
99
	}
97
	}
100
98
101
	public ServerManager getServerManager() {
99
	public XPlannerClientManager getClientManager() {
102
		return serverManager;
100
		return clientManager;
103
	}
101
	}
104
	
102
	
105
	/**
103
	/**
Lines 121-127 Link Here
121
	public ResourceBundle getResourceBundle() {
119
	public ResourceBundle getResourceBundle() {
122
		try {
120
		try {
123
			if (resourceBundle == null)
121
			if (resourceBundle == null)
124
				resourceBundle = ResourceBundle.getBundle("org.eclipse.mylar.xplanner.core.XPlannerCorePluginResources"); //$NON-NLS-1$
122
				resourceBundle = ResourceBundle.getBundle("org.eclipse.mylyn.xplanner.core.XPlannerCorePluginResources"); //$NON-NLS-1$
125
		} catch (MissingResourceException x) {
123
		} catch (MissingResourceException x) {
126
			resourceBundle = null;
124
			resourceBundle = null;
127
		}
125
		}
(-)src/org/eclipse/mylyn/xplanner/core/Messages.java (-4 / +4 lines)
Lines 5-11 Link Here
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
package org.eclipse.mylar.xplanner.core;
8
package org.eclipse.mylyn.xplanner.core;
9
9
10
import org.eclipse.osgi.util.NLS;
10
import org.eclipse.osgi.util.NLS;
11
11
Lines 14-20 Link Here
14
 * @author Helen Bershadskaya
14
 * @author Helen Bershadskaya
15
 */
15
 */
16
public class Messages extends NLS {
16
public class Messages extends NLS {
17
	private static final String BUNDLE_NAME = "org.eclipse.mylar.xplanner.core.messages"; //$NON-NLS-1$
17
	private static final String BUNDLE_NAME = "org.eclipse.mylyn.xplanner.core.messages"; //$NON-NLS-1$
18
18
19
	public static String XPlannerCorePlugin_UNEXPECTED_ERROR;
19
	public static String XPlannerCorePlugin_UNEXPECTED_ERROR;
20
20
Lines 22-30 Link Here
22
22
23
	public static String XPlannerValidator_CONNECTION_ERROR;
23
	public static String XPlannerValidator_CONNECTION_ERROR;
24
24
25
	public static String ServerManager_SERVER_URL_CANNOT_BE_EMPTY;
25
	public static String ClientManager_CLIENT_URL_CANNOT_BE_EMPTY;
26
	
26
	
27
	public static String ServerManager_INVALID_USERNAME_PASSWORD;
27
	public static String ClientManager_INVALID_USERNAME_PASSWORD;
28
28
29
	static {
29
	static {
30
		// initialize resource bundle
30
		// initialize resource bundle
(-)src/org/eclipse/mylyn/xplanner/core/DebugManager.java (-1 / +1 lines)
Lines 6-12 Link Here
6
 * http://www.eclipse.org/legal/epl-v10.html
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *******************************************************************************/
7
 *******************************************************************************/
8
8
9
package org.eclipse.mylar.xplanner.core;
9
package org.eclipse.mylyn.xplanner.core;
10
10
11
import org.eclipse.core.runtime.IStatus;
11
import org.eclipse.core.runtime.IStatus;
12
import org.eclipse.core.runtime.Platform;
12
import org.eclipse.core.runtime.Platform;
(-)src/org/eclipse/mylyn/xplanner/core/messages.properties (-4 / +4 lines)
Lines 1-5 Link Here
1
ServerManager_SERVER_URL_CANNOT_BE_EMPTY=Server url cannot be empty
1
ClientManager_CLIENT_URL_CANNOT_BE_EMPTY=Server url cannot be empty
2
ServerManager_INVALID_USERNAME_PASSWORD=Invalid user name or password.
2
ClientManager_INVALID_USERNAME_PASSWORD=Invalid user name or password.
3
XPlannerValidator_INVALID_CREDENTIALS_ERROR=The supplied credentials are invalid.\n\n{0}
3
XPlannerValidator_INVALID_CREDENTIALS_ERROR=The supplied credentials are invalid:  {0}
4
XPlannerValidator_CONNECTION_ERROR=Connection error:\n\n{0}
4
XPlannerValidator_CONNECTION_ERROR=Connection error:  {0}
5
XPlannerCorePlugin_UNEXPECTED_ERROR=Unexpected error
5
XPlannerCorePlugin_UNEXPECTED_ERROR=Unexpected error
(-)src/org/eclipse/mylyn/xplanner/core/ServerManager.java (-260 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 - 2007 CodeGear 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
package org.eclipse.mylar.xplanner.core;
9
10
/**
11
 * @author Ravi Kumar
12
 * @author Helen Bershadskaya
13
 */
14
import java.io.BufferedInputStream;
15
import java.io.BufferedOutputStream;
16
import java.io.File;
17
import java.io.FileInputStream;
18
import java.io.FileOutputStream;
19
import java.io.IOException;
20
import java.io.ObjectInputStream;
21
import java.io.ObjectOutputStream;
22
import java.net.URL;
23
import java.rmi.RemoteException;
24
import java.util.ArrayList;
25
import java.util.HashMap;
26
import java.util.Iterator;
27
import java.util.List;
28
import java.util.Map;
29
30
import org.apache.axis.AxisFault;
31
import org.eclipse.mylar.xplanner.core.service.CachedXPlannerServer;
32
import org.eclipse.mylar.xplanner.core.service.XPlannerServer;
33
import org.eclipse.mylar.xplanner.core.service.exceptions.AuthenticationException;
34
import org.eclipse.mylar.xplanner.core.service.exceptions.ServiceUnavailableException;
35
import org.xml.sax.SAXException;
36
37
38
/**
39
 * @author Helen Bershadskaya 
40
 * @author Ravi Kumar 
41
 */
42
public class ServerManager {
43
44
	private final File cacheLocation;
45
46
	private Map<String, XPlannerServer> serverByName = new HashMap<String, XPlannerServer>();
47
48
	// TODO Use a decent listener list
49
	private List<XPlannerServerListener> listeners = new ArrayList<XPlannerServerListener>();
50
	
51
	public ServerManager(File cacheLocation) {
52
		this.cacheLocation = cacheLocation;
53
	}
54
	
55
	protected void start() {
56
		// On first load the cache may not exist
57
		cacheLocation.mkdirs();
58
		
59
		File[] servers = this.cacheLocation.listFiles();
60
		for (int i = 0; i < servers.length; i++) {
61
			File serverCache = servers[i];
62
			File serverFile = new File(serverCache, "server.ser"); //$NON-NLS-1$
63
			
64
			ObjectInputStream ois = null;
65
			try {
66
				ois = new ObjectInputStream(new BufferedInputStream(new FileInputStream(serverFile)));
67
				XPlannerServer server = (XPlannerServer) ois.readObject();
68
				// TODO reconnect the services depending on user preferences
69
				
70
				serverByName.put(serverCache.getName(), server);
71
				ois.close();
72
			} catch (IOException e) {
73
				e.printStackTrace();
74
			} catch (ClassNotFoundException e) {
75
				e.printStackTrace();
76
			} finally {
77
				if (ois != null) {
78
					try {
79
						ois.close();
80
					} catch (IOException e) {
81
					}
82
				}
83
			}
84
		}
85
	}
86
	
87
	protected void stop() {
88
		for (Iterator<XPlannerServer> iServers = serverByName.values().iterator(); iServers.hasNext();) {
89
			XPlannerServer server = iServers.next();
90
			
91
			ObjectOutputStream oos = null;
92
			try {
93
				File cacheDir = new File(cacheLocation, server.getName());
94
				cacheDir.mkdirs();
95
				
96
				oos = new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream(new File(cacheDir, "server.ser")))); //$NON-NLS-1$
97
				oos.writeObject(server);
98
			} catch (IOException e) {
99
				e.printStackTrace();
100
			} finally {
101
				if (oos != null) {
102
					try {
103
						oos.close();
104
					} catch (IOException e) {
105
					}
106
				}
107
			}
108
		}
109
	}
110
	
111
	/**
112
	 * Tests the connection to a server.  If the URL is invalid ot the username
113
	 * and password are invalid this method will return with a exceptions carrying
114
	 * the failure reason. 
115
	 * @param baseUrl Base URL of the XPlanner installation
116
	 * @param username username to connect with
117
	 * @param password Password to connect with
118
	 * @return Short string describing the server information
119
	 * @throws AuthenticationException URL was valid but username and password were incorrect
120
	 * @throws ServiceUnavailableException URL was not valid
121
	 */
122
	public String testConnection(String baseUrl, String username, String password) throws AuthenticationException, ServiceUnavailableException {
123
		if (baseUrl == null || baseUrl.length() == 0) {
124
			throw new AuthenticationException(Messages.ServerManager_SERVER_URL_CANNOT_BE_EMPTY);
125
		}
126
		
127
		XPlannerServer server = null;
128
		
129
		try {
130
			new URL(baseUrl).openConnection(); // tests url validity
131
132
			server = createServer("Connection Test", baseUrl, false, username, password); //$NON-NLS-1$
133
			
134
			server.getTask(-1);
135
		}
136
		catch (RemoteException re) {
137
			if (re instanceof AxisFault) {
138
				String message = re.getMessage().trim();
139
				if (message.startsWith("(401)")) { //$NON-NLS-1$
140
					message = Messages.ServerManager_INVALID_USERNAME_PASSWORD;
141
				}
142
				else if (re.getCause() instanceof SAXException) {
143
					message = ""; //$NON-NLS-1$
144
				}
145
				else {
146
					message = message.startsWith(";") ? message.substring(1).trim() : message; //$NON-NLS-1$
147
				}
148
				throw new AuthenticationException(message);
149
			}
150
			else {
151
				throw new ServiceUnavailableException(re.getMessage());
152
			}
153
		}
154
		catch (Exception e) {
155
			throw new ServiceUnavailableException(e.getMessage());
156
		}
157
		finally {
158
			if (server != null) {
159
				removeServer(server);
160
			}
161
		}
162
		
163
		return "XPlanner"; //$NON-NLS-1$
164
	}
165
	
166
	public XPlannerServer getServer(String name) {
167
		return (XPlannerServer) serverByName.get(name);
168
	}
169
	
170
	public XPlannerServer[] getAllServers() {
171
		return (XPlannerServer[]) serverByName.values().toArray(new XPlannerServer[serverByName.size()]);
172
	}
173
	
174
	public XPlannerServer createServer(String name, String baseUrl, boolean hasSlowConnection, String username, String password) {
175
		if (baseUrl.charAt(baseUrl.length() - 1) == '/') {
176
			baseUrl = baseUrl.substring(0, baseUrl.length() - 1);
177
		}
178
		
179
		XPlannerServer server = new CachedXPlannerServer(name, baseUrl, hasSlowConnection, username, password);
180
		return server;
181
	}
182
	
183
	public void addServer(XPlannerServer server) {
184
		if (serverByName.containsKey(server.getName())) {
185
//			TODO: add this check back once the listeners for server property change are hooked up
186
//			 Also handle the case when serviceDelegate in the cachedServer is null
187
//			throw new RuntimeException("A server with that name already exists");
188
			removeServer(server);
189
		}
190
		serverByName.put(server.getName(), server);
191
		fireServerAddded(server);
192
	}
193
	
194
	public void removeServer(XPlannerServer server) {
195
		serverByName.remove(server.getName());
196
		
197
		File serverCache = new File(this.cacheLocation, server.getName());
198
		if (serverCache.exists()) {
199
			recursiveDelete(serverCache);
200
		}
201
		fireServerRemoved(server);
202
	}
203
204
	/**
205
	 * TODO need to make this a bit smarter.  Perhaps have an object to hold connectino info
206
	 * @param name
207
	 * @param baseURL
208
	 * @param username
209
	 * @param password
210
	 */
211
	public void updateServerDetails(String name, String baseURL, boolean hasSlowConnection, String username, String password) {
212
		CachedXPlannerServer server = (CachedXPlannerServer) serverByName.get(name);
213
		// TODO we should really have a modify event
214
215
		fireServerRemoved(server);
216
		
217
		// TODO need to flush the server cache since we are possibly a different person
218
		server.setBaseURL(baseURL);
219
		server.setSlowConnection(hasSlowConnection);
220
		server.setCurrentUserName(username);
221
		server.setCurrentPassword(password);
222
		
223
		fireServerAddded(server);
224
	}
225
	
226
	public void addServerListener(XPlannerServerListener listener) {
227
		listeners.add(listener);
228
	}
229
	
230
	public void removeServerListener(XPlannerServerListener listener) {
231
		listeners.remove(listener);
232
	}
233
	
234
	private void fireServerRemoved(XPlannerServer server) {
235
		for (Iterator<XPlannerServerListener> iListeners = listeners.iterator(); iListeners.hasNext();) {
236
			XPlannerServerListener listener = (XPlannerServerListener)iListeners.next();
237
			listener.serverRemoved(server);
238
		}
239
	}
240
	
241
	private void fireServerAddded(XPlannerServer server) {
242
		for (Iterator<XPlannerServerListener> iListeners = listeners.iterator(); iListeners.hasNext();) {
243
			XPlannerServerListener listener = (XPlannerServerListener)iListeners.next();
244
			listener.serverAdded(server);
245
		}
246
	}
247
	
248
	private void recursiveDelete(File baseFile) {
249
		if (baseFile.isFile()) {
250
			baseFile.delete();
251
		} else {
252
			File[] children = baseFile.listFiles();
253
			for (int i = 0; i < children.length; i++) {
254
				File file = children[i];
255
				recursiveDelete(file);
256
			}
257
			baseFile.delete();
258
		}
259
	}
260
}
(-).settings/org.eclipse.core.resources.prefs (-1 / +1 lines)
Lines 1-3 Link Here
1
#Fri Mar 09 11:38:32 PST 2007
1
#Fri Mar 09 11:38:32 PST 2007
2
eclipse.preferences.version=1
2
eclipse.preferences.version=1
3
encoding//src/org/eclipse/mylar/xplanner/core/messages.properties=8859_1
3
encoding//src/org/eclipse/mylyn/xplanner/core/messages.properties=8859_1
(-)src/org/xplanner/soap/NoteData.java (-1 / +1 lines)
Lines 8-14 Link Here
8
package org.xplanner.soap;
8
package org.xplanner.soap;
9
9
10
@SuppressWarnings("unchecked")
10
@SuppressWarnings("unchecked")
11
public class NoteData  extends org.eclipse.mylar.xplanner.wsdl.soap.domain.DomainData  implements java.io.Serializable {
11
public class NoteData  extends org.eclipse.mylyn.xplanner.wsdl.soap.domain.DomainData  implements java.io.Serializable {
12
    private int attachedToId;
12
    private int attachedToId;
13
13
14
    private int attachmentId;
14
    private int attachmentId;
(-)src/org/xplanner/soap/ProjectData.java (-1 / +1 lines)
Lines 8-14 Link Here
8
package org.xplanner.soap;
8
package org.xplanner.soap;
9
9
10
@SuppressWarnings("unchecked")
10
@SuppressWarnings("unchecked")
11
public class ProjectData  extends org.eclipse.mylar.xplanner.wsdl.soap.domain.DomainData  implements java.io.Serializable {
11
public class ProjectData  extends org.eclipse.mylyn.xplanner.wsdl.soap.domain.DomainData  implements java.io.Serializable {
12
    private java.lang.String description;
12
    private java.lang.String description;
13
13
14
    private java.lang.String name;
14
    private java.lang.String name;
(-)src/org/xplanner/soap/UserStoryData.java (-1 / +1 lines)
Lines 8-14 Link Here
8
package org.xplanner.soap;
8
package org.xplanner.soap;
9
9
10
@SuppressWarnings("unchecked")
10
@SuppressWarnings("unchecked")
11
public class UserStoryData  extends org.eclipse.mylar.xplanner.wsdl.soap.domain.DomainData  implements java.io.Serializable {
11
public class UserStoryData  extends org.eclipse.mylyn.xplanner.wsdl.soap.domain.DomainData  implements java.io.Serializable {
12
    private double actualHours;
12
    private double actualHours;
13
13
14
    private double adjustedEstimatedHours;
14
    private double adjustedEstimatedHours;
(-)src/org/xplanner/soap/PersonData.java (-1 / +1 lines)
Lines 8-14 Link Here
8
package org.xplanner.soap;
8
package org.xplanner.soap;
9
9
10
@SuppressWarnings("unchecked")
10
@SuppressWarnings("unchecked")
11
public class PersonData  extends org.eclipse.mylar.xplanner.wsdl.soap.domain.DomainData  implements java.io.Serializable {
11
public class PersonData  extends org.eclipse.mylyn.xplanner.wsdl.soap.domain.DomainData  implements java.io.Serializable {
12
    private java.lang.String email;
12
    private java.lang.String email;
13
13
14
    private java.lang.String initials;
14
    private java.lang.String initials;
(-)src/org/xplanner/soap/TimeEntryData.java (-1 / +1 lines)
Lines 8-14 Link Here
8
package org.xplanner.soap;
8
package org.xplanner.soap;
9
9
10
@SuppressWarnings("unchecked")
10
@SuppressWarnings("unchecked")
11
public class TimeEntryData  extends org.eclipse.mylar.xplanner.wsdl.soap.domain.DomainData  implements java.io.Serializable {
11
public class TimeEntryData  extends org.eclipse.mylyn.xplanner.wsdl.soap.domain.DomainData  implements java.io.Serializable {
12
    private java.lang.String description;
12
    private java.lang.String description;
13
13
14
    private double duration;
14
    private double duration;
(-)src/org/xplanner/soap/TaskData.java (-1 / +1 lines)
Lines 8-14 Link Here
8
package org.xplanner.soap;
8
package org.xplanner.soap;
9
9
10
@SuppressWarnings("unchecked")
10
@SuppressWarnings("unchecked")
11
public class TaskData  extends org.eclipse.mylar.xplanner.wsdl.soap.domain.DomainData  implements java.io.Serializable {
11
public class TaskData  extends org.eclipse.mylyn.xplanner.wsdl.soap.domain.DomainData  implements java.io.Serializable {
12
    private int acceptorId;
12
    private int acceptorId;
13
13
14
    private double actualHours;
14
    private double actualHours;
(-)src/org/xplanner/soap/IterationData.java (-1 / +1 lines)
Lines 8-14 Link Here
8
package org.xplanner.soap;
8
package org.xplanner.soap;
9
9
10
@SuppressWarnings("unchecked")
10
@SuppressWarnings("unchecked")
11
public class IterationData  extends org.eclipse.mylar.xplanner.wsdl.soap.domain.DomainData  implements java.io.Serializable {
11
public class IterationData  extends org.eclipse.mylyn.xplanner.wsdl.soap.domain.DomainData  implements java.io.Serializable {
12
    private double actualHours;
12
    private double actualHours;
13
13
14
    private double addedHours;
14
    private double addedHours;
(-)src-gen/org/eclipse/mylyn/xplanner/wsdl/soap/domain/DomainData.java (-1 / +1 lines)
Lines 5-11 Link Here
5
 * by the Apache Axis 1.3 Oct 05, 2005 (05:23:37 EDT) WSDL2Java emitter.
5
 * by the Apache Axis 1.3 Oct 05, 2005 (05:23:37 EDT) WSDL2Java emitter.
6
 */
6
 */
7
7
8
package org.eclipse.mylar.xplanner.wsdl.soap.domain;
8
package org.eclipse.mylyn.xplanner.wsdl.soap.domain;
9
9
10
@SuppressWarnings("unchecked")
10
@SuppressWarnings("unchecked")
11
public abstract class DomainData  implements java.io.Serializable {
11
public abstract class DomainData  implements java.io.Serializable {
(-)src/org/eclipse/mylyn/xplanner/core/service/ServiceManager.java (-14 / +11 lines)
Lines 5-24 Link Here
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
package org.eclipse.mylar.xplanner.core.service;
8
package org.eclipse.mylyn.xplanner.core.service;
9
9
10
import org.eclipse.core.runtime.CoreException;
10
import org.eclipse.core.runtime.*;
11
import org.eclipse.core.runtime.IConfigurationElement;
11
import org.eclipse.mylyn.xplanner.core.IXPlannerCoreExtensionConstants;
12
import org.eclipse.core.runtime.IExtension;
12
import org.eclipse.mylyn.xplanner.core.XPlannerCorePlugin;
13
import org.eclipse.core.runtime.IExtensionPoint;
14
import org.eclipse.core.runtime.IStatus;
15
import org.eclipse.core.runtime.Platform;
16
import org.eclipse.mylar.xplanner.core.IXPlannerCoreExtensionConstants;
17
import org.eclipse.mylar.xplanner.core.XPlannerCorePlugin;
18
13
19
14
20
/**
15
/**
21
 * TODO This is eclispe specific at the moment.  Need to find a way to load a
16
 * TODO This is eclipse specific at the moment.  Need to find a way to load a
22
 * XPlannerService instance based off some use preference.
17
 * XPlannerService instance based off some use preference.
23
 * TODO mention that this should really only be used by internal classes and tests
18
 * TODO mention that this should really only be used by internal classes and tests
24
 *
19
 *
Lines 29-39 Link Here
29
	
24
	
30
	private static XPlannerServiceFactory factory;
25
	private static XPlannerServiceFactory factory;
31
	
26
	
32
	public static synchronized XPlannerService getXPlannerService(XPlannerServer server) {
27
	public static synchronized XPlannerService getXPlannerService(XPlannerClient client) {
33
		if (factory == null) {
28
		if (factory == null) {
34
			factory = loadServiceProviderFactories();
29
			factory = loadServiceProviderFactories();
35
		}
30
		}
36
		return factory.createService(server);
31
		return factory.createService(client);
37
	}
32
	}
38
	
33
	
39
	public static XPlannerServiceFactory loadServiceProviderFactories() {
34
	public static XPlannerServiceFactory loadServiceProviderFactories() {
Lines 47-55 Link Here
47
					for (int j = 0; j < configElements.length; j++) {
42
					for (int j = 0; j < configElements.length; j++) {
48
						try {
43
						try {
49
							return (XPlannerServiceFactory) configElements[j].createExecutableExtension("class"); //$NON-NLS-1$
44
							return (XPlannerServiceFactory) configElements[j].createExecutableExtension("class"); //$NON-NLS-1$
50
						} catch (CoreException e) {
45
						} 
46
						catch (CoreException e) {
51
							plugin.getLog().log(e.getStatus());
47
							plugin.getLog().log(e.getStatus());
52
						} catch (ClassCastException e) {
48
						} 
49
						catch (ClassCastException e) {
53
							XPlannerCorePlugin.log(IStatus.ERROR, "Must implement the correct class", e); //$NON-NLS-1$
50
							XPlannerCorePlugin.log(IStatus.ERROR, "Must implement the correct class", e); //$NON-NLS-1$
54
							XPlannerCorePlugin.log(IStatus.ERROR, "Must implement the correct class", e); //$NON-NLS-1$
51
							XPlannerCorePlugin.log(IStatus.ERROR, "Must implement the correct class", e); //$NON-NLS-1$
55
						}
52
						}
(-)src/org/eclipse/mylyn/xplanner/core/service/CachedXPlannerServer.java (-492 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 - 2007 CodeGear 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
package org.eclipse.mylar.xplanner.core.service;
9
10
import java.io.Serializable;
11
import java.rmi.RemoteException;
12
import java.util.ArrayList;
13
import java.util.Arrays;
14
import java.util.HashMap;
15
import java.util.List;
16
17
import org.eclipse.mylar.xplanner.wsdl.db.QueryException;
18
import org.xplanner.soap.IterationData;
19
import org.xplanner.soap.NoteData;
20
import org.xplanner.soap.PersonData;
21
import org.xplanner.soap.ProjectData;
22
import org.xplanner.soap.TaskData;
23
import org.xplanner.soap.TimeEntryData;
24
import org.xplanner.soap.UserStoryData;
25
26
27
/**
28
 * XPlanner server implementation that caches information that is unlikey to change
29
 * during the session.  This server could be persisted to disk and re-loaded.
30
 * It has lifecycle methods to allow data in the cache to be reloaded.
31
 * 
32
 * TODO it is assumed that it will be backed by a standad XPlanner service layer 
33
 * 
34
 * @author Ravi Kumar
35
 * @author Helen Bershadskaya
36
 */
37
public class CachedXPlannerServer extends XPlannerServer implements Serializable {
38
  public static final int INVALID_ID = -1;
39
  
40
	/**
41
	 * 
42
	 */
43
	private static final long serialVersionUID = 1L;
44
	private String name;
45
	private String baseURL;
46
	private boolean hasSlowConnection;
47
	private String userName;
48
	private String password;
49
	private transient XPlannerService serviceDelegate;
50
51
	public CachedXPlannerServer(String name, String baseURL, boolean hasSlowConnection, String userName, String password) {
52
		this.name = name;
53
		this.baseURL = baseURL;
54
		this.hasSlowConnection = hasSlowConnection;
55
		this.userName = userName;
56
		this.password = password;
57
		
58
		this.serviceDelegate = ServiceManager.getXPlannerService(this);
59
		serviceDelegate.login(userName, password);
60
	}
61
62
	public String getBaseURL() {
63
		return baseURL;
64
	}
65
66
	public String getCurrentUserName() {
67
		return userName;
68
	}
69
70
	public String getCurrentUserPassword() {
71
		return password;
72
	}
73
74
	public int getMaximumNumberOfMatches() {
75
		return 0;
76
	}
77
78
	public String getName() {
79
		return name;
80
	}
81
82
	public boolean hasSlowConnection() {
83
		return hasSlowConnection;
84
	}
85
86
87
	public void setSlowConnection(boolean hasSlowConnection) {
88
		this.hasSlowConnection = hasSlowConnection;
89
	}
90
91
	public void setBaseURL(String baseURL) {
92
		this.baseURL = baseURL;
93
	}
94
95
	public void setCurrentPassword(String password) {
96
		this.password = password;
97
	}
98
99
	public void setCurrentUserName(String userName) {
100
		this.userName = userName;
101
	}
102
	
103
	public String login(String username, String password) {
104
		return serviceDelegate.login(username, password);		
105
	}
106
107
	public boolean logout() {
108
		boolean ok = true;
109
	
110
		//TODO -- shouldn't have a null service delegate, but definitely get into this condition if "finish"
111
		// repository definition with an invalid server
112
	
113
		if (serviceDelegate != null) {
114
			ok = serviceDelegate.logout();
115
		}
116
		
117
		return ok;
118
	}
119
120
	public IterationData addIteration(IterationData iteration) throws RemoteException {
121
		return serviceDelegate.addIteration(iteration);
122
	}
123
124
	public NoteData addNote(NoteData note) throws RemoteException {
125
		return serviceDelegate.addNote(note);
126
	}
127
128
	public PersonData addPerson(PersonData object) throws RemoteException {
129
		return serviceDelegate.addPerson(object);
130
	}
131
132
	public ProjectData addProject(ProjectData project) throws RemoteException {
133
		return serviceDelegate.addProject(project);
134
	}
135
136
	public TaskData addTask(TaskData task) throws RemoteException {
137
		return serviceDelegate.addTask(task);
138
	}
139
140
	public TimeEntryData addTimeEntry(TimeEntryData timeEntry) throws RemoteException {
141
		return serviceDelegate.addTimeEntry(timeEntry);
142
	}
143
144
	public UserStoryData addUserStory(UserStoryData story) throws RemoteException {
145
		return serviceDelegate.addUserStory(story);
146
	}
147
148
	public void deleteAttribute(int objectId, String key) throws RemoteException {
149
		serviceDelegate.deleteAttribute(objectId, key);
150
	}
151
152
	public boolean equals(Object obj) {
153
		return this == obj || serviceDelegate.equals(obj) || 
154
		 (obj instanceof CachedXPlannerServer && ((CachedXPlannerServer)obj).serviceDelegate.equals(serviceDelegate));
155
	}
156
157
	public String getAttribute(int objectId, String key) throws RemoteException {
158
		return serviceDelegate.getAttribute(objectId, key);
159
	}
160
161
	@SuppressWarnings("unchecked")
162
	public HashMap getAttributes(int objectId) throws RemoteException {
163
		return serviceDelegate.getAttributes(objectId);
164
	}
165
166
	@SuppressWarnings("unchecked")
167
	public HashMap getAttributesWithPrefix(int objectId, String prefix) throws RemoteException {
168
		return serviceDelegate.getAttributesWithPrefix(objectId, prefix);
169
	}
170
171
	public IterationData getCurrentIteration(int projectId) throws RemoteException {
172
		return serviceDelegate.getCurrentIteration(projectId);
173
	}
174
175
	public TaskData[] getCurrentTasksForPerson(int personId) throws RemoteException, QueryException {
176
		return serviceDelegate.getCurrentTasksForPerson(personId);
177
	}
178
179
	public IterationData getIteration(int id) throws RemoteException {
180
		return serviceDelegate.getIteration(id);
181
	}
182
183
	public IterationData[] getIterations(int projectId) throws RemoteException {
184
		return serviceDelegate.getIterations(projectId);
185
	}
186
187
	public NoteData getNote(int id) throws RemoteException {
188
		return serviceDelegate.getNote(id);
189
	}
190
191
	public NoteData[] getNotesForObject(int attachedToId) throws RemoteException {
192
		return serviceDelegate.getNotesForObject(attachedToId);
193
	}
194
195
	public PersonData[] getPeople() throws RemoteException {
196
		return serviceDelegate.getPeople();
197
	}
198
199
	public PersonData getPerson(int id) throws RemoteException {
200
		return serviceDelegate.getPerson(id);
201
	}
202
203
	public TaskData[] getPlannedTasksForPerson(int personId) throws RemoteException, QueryException {
204
		return serviceDelegate.getPlannedTasksForPerson(personId);
205
	}
206
207
	public ProjectData getProject(int id) throws RemoteException {
208
		return serviceDelegate.getProject(id);
209
	}
210
211
	public ProjectData[] getProjects() throws RemoteException {
212
		return serviceDelegate.getProjects();
213
	}
214
215
	public TaskData getTask(int id) throws RemoteException {
216
		if (serviceDelegate == null) {
217
			System.out.println(" why is serivce Delegate null???"); //$NON-NLS-1$
218
		}
219
		return serviceDelegate.getTask(id);
220
	}
221
222
	public TaskData[] getTasks(int containerId) throws RemoteException {
223
		return serviceDelegate.getTasks(containerId);
224
	}
225
226
	public TimeEntryData[] getTimeEntries(int containerId) throws RemoteException {
227
		return serviceDelegate.getTimeEntries(containerId);
228
	}
229
230
	public TimeEntryData getTimeEntry(int id) throws RemoteException {
231
		return serviceDelegate.getTimeEntry(id);
232
	}
233
234
	public UserStoryData[] getUserStories(int containerId) throws RemoteException {
235
		return serviceDelegate.getUserStories(containerId);
236
	}
237
238
	public UserStoryData getUserStory(int id) throws RemoteException {
239
		return serviceDelegate.getUserStory(id);
240
	}
241
242
	public int hashCode() {
243
		return serviceDelegate.hashCode();
244
	}
245
246
	public void removeIteration(int id) throws RemoteException {
247
		serviceDelegate.removeIteration(id);
248
	}
249
250
	public void removeNote(int id) throws RemoteException {
251
		serviceDelegate.removeNote(id);
252
	}
253
254
	public void removePerson(int id) throws RemoteException {
255
		serviceDelegate.removePerson(id);
256
	}
257
258
	public void removeProject(int id) throws RemoteException {
259
		serviceDelegate.removeProject(id);
260
	}
261
262
	public void removeTask(int id) throws RemoteException {
263
		serviceDelegate.removeTask(id);
264
	}
265
266
	public void removeTimeEntry(int id) throws RemoteException {
267
		serviceDelegate.removeTimeEntry(id);
268
	}
269
270
	public void removeUserStory(int id) throws RemoteException {
271
		serviceDelegate.removeUserStory(id);
272
	}
273
274
	public void setAttribute(int objectId, String key, String value) throws RemoteException {
275
		serviceDelegate.setAttribute(objectId, key, value);
276
	}
277
278
	public void update(IterationData object) throws RemoteException {
279
		serviceDelegate.update(object);
280
	}
281
282
	public void update(NoteData note) throws RemoteException {
283
		serviceDelegate.update(note);
284
	}
285
286
	public void update(PersonData object) throws RemoteException {
287
		serviceDelegate.update(object);
288
	}
289
290
	public void update(ProjectData object) throws RemoteException {
291
		serviceDelegate.update(object);
292
	}
293
294
	public void update(TaskData object) throws RemoteException {
295
		serviceDelegate.update(object);
296
	}
297
298
	public void update(TimeEntryData object) throws RemoteException {
299
		serviceDelegate.update(object);
300
	}
301
302
	public void update(UserStoryData object) throws RemoteException {
303
		serviceDelegate.update(object);
304
	}
305
306
	public TaskData[] getUserStoryTasksForPerson(int personId, int userStoryId) {
307
		if (personId < 0 || userStoryId < 0) {
308
			return new TaskData[0];
309
		}
310
		
311
		List<TaskData> userStoryTasksForPerson = new ArrayList<TaskData>();
312
		try {
313
			TaskData[] iterationTasks = getTasks(userStoryId);
314
			// get all tasks for specified user storyserv
315
			for (int i = 0; i < iterationTasks.length; i++) {
316
				TaskData taskData = iterationTasks[i];
317
				if (taskData.getAcceptorId() == personId) {
318
					userStoryTasksForPerson.add(taskData);
319
				}
320
			}
321
			
322
		}
323
		catch (RemoteException e) {
324
			e.printStackTrace();
325
		}
326
		
327
		return userStoryTasksForPerson.toArray(new TaskData[userStoryTasksForPerson.size()]);
328
	}
329
	
330
	public UserStoryData[] getIterationUserStoriesForTracker(int trackerId, int iterationId) {
331
		if (trackerId < 0 || iterationId < 0) {
332
			return new UserStoryData[0];
333
		}
334
335
		List<UserStoryData> userStoriesForTracker = new ArrayList<UserStoryData>();
336
		UserStoryData[] userStories;
337
		try {
338
			userStories = getUserStories(iterationId);
339
			// get all tasks for specified user story
340
			for (int i = 0; i < userStories.length; i++) {
341
				UserStoryData userStory = userStories[i];
342
				if (userStory.getTrackerId() == trackerId) {
343
					userStoriesForTracker.add(userStory);
344
				}
345
			}
346
		}
347
		catch (RemoteException e) {
348
			e.printStackTrace();
349
		}
350
		
351
		return userStoriesForTracker.toArray(new UserStoryData[userStoriesForTracker.size()]);
352
	}
353
354
	public int getCurrentPersonId() {
355
		int currentPersonId = INVALID_ID;
356
		
357
	  String userName = getCurrentUserName();
358
	  if (userName != null) {
359
	  	try {
360
				PersonData[] people = getPeople();
361
				if (people != null) {
362
					for (int i = 0; i < people.length && currentPersonId == INVALID_ID; i++) {
363
						PersonData person = people[i];
364
						if (person.getUserId().equals(userName)) {
365
							currentPersonId = person.getId();
366
						}
367
					}
368
				}
369
			}
370
			catch (RemoteException e) {
371
				e.printStackTrace();
372
			}
373
	  }
374
	  
375
	  return currentPersonId;
376
	}
377
	
378
	public UserStoryData[] getUserStoriesForProject(int projectId) {
379
		if (projectId == INVALID_ID) {
380
			return new UserStoryData[0];
381
		}
382
		
383
		ArrayList<UserStoryData> projectUserStories = new ArrayList<UserStoryData>();
384
		try {
385
			IterationData[] projectIterations = getIterations(projectId);
386
			for (IterationData iteration : projectIterations) {
387
				UserStoryData[] iterationUserStories = getUserStories(iteration.getId());
388
				if (iterationUserStories.length > 0) {
389
					projectUserStories.addAll(Arrays.asList(iterationUserStories));
390
				}
391
			}
392
		}
393
		catch (RemoteException e) {
394
			e.printStackTrace();
395
		}
396
		
397
		return (UserStoryData[]) projectUserStories.toArray(new UserStoryData[projectUserStories.size()]);
398
	}
399
	
400
	public UserStoryData[] getUserStoriesForProject(int projectId, int trackerId) {
401
		if (projectId == INVALID_ID) {
402
			return new UserStoryData[0];
403
		}
404
		
405
		ArrayList<UserStoryData> projectTrackerUserStories = new ArrayList<UserStoryData>();
406
		UserStoryData[] projectUserStories = getUserStoriesForProject(projectId);
407
		for (UserStoryData userStory : projectUserStories) {
408
			if (userStory.getTrackerId() == trackerId) {
409
				projectTrackerUserStories.add(userStory);
410
			}
411
		}
412
		
413
		return (UserStoryData[]) projectTrackerUserStories.toArray(new UserStoryData[projectTrackerUserStories.size()]);
414
415
	}
416
	
417
	public TaskData[] getTasksForProject(int projectId) {
418
		if (projectId == -1) {
419
			return new TaskData[0];
420
		}
421
		
422
		ArrayList<TaskData> projectTasks = new ArrayList<TaskData>();
423
		try {
424
			UserStoryData[] userStories = getUserStoriesForProject(projectId);
425
			for (UserStoryData userStory : userStories) {
426
				TaskData[] userStoryTasks = getTasks(userStory.getId());
427
				if (userStoryTasks.length > 0) {
428
					projectTasks.addAll(Arrays.asList(userStoryTasks));
429
				}
430
			}
431
		}
432
		catch (RemoteException e) {
433
			e.printStackTrace();
434
		}
435
		
436
		return (TaskData[]) projectTasks.toArray(new TaskData[projectTasks.size()]);
437
	}
438
	
439
	public TaskData[] getTasksForProject(int projectId, int personId) {
440
		if (projectId == INVALID_ID || personId == INVALID_ID) {
441
			return new TaskData[0];
442
		}
443
		
444
		ArrayList<TaskData> projectPersonTasks = new ArrayList<TaskData>();
445
		TaskData[] allProjectTasks = getTasksForProject(projectId);
446
		for (TaskData task : allProjectTasks) {
447
			if (task.getAcceptorId() == personId) {
448
				projectPersonTasks.add(task);
449
			}
450
		}
451
		
452
		return (TaskData[]) projectPersonTasks.toArray(new TaskData[projectPersonTasks.size()]);
453
	}
454
	
455
	public TaskData[] getTasksForIteration(int iterationId) {
456
		if (iterationId == INVALID_ID) {
457
			return new TaskData[0];
458
		}
459
		
460
		ArrayList<TaskData> iterationTasks = new ArrayList<TaskData>();
461
		try {
462
			UserStoryData[] userStories = getUserStories(iterationId);
463
			for (UserStoryData userStory : userStories) {
464
				TaskData[] userStoryTasks = getTasks(userStory.getId());
465
				if (userStoryTasks.length > 0) {
466
					iterationTasks.addAll(Arrays.asList(userStoryTasks));
467
				}
468
			}
469
		}
470
		catch (RemoteException e) {
471
			e.printStackTrace();
472
		}
473
		
474
		return (TaskData[]) iterationTasks.toArray(new TaskData[iterationTasks.size()]);
475
	}
476
	
477
	public TaskData[] getTasksForIteration(int iterationId, int personId) {
478
		if (iterationId == INVALID_ID || personId == INVALID_ID) {
479
			return new TaskData[0];
480
		}
481
		
482
		ArrayList<TaskData> iterationPersonTasks = new ArrayList<TaskData>();
483
		TaskData[] allIterationTasks = getTasksForIteration(iterationId);
484
		for (TaskData task : allIterationTasks) {
485
			if (task.getAcceptorId() == personId) {
486
				iterationPersonTasks.add(task);
487
			}
488
		}
489
		
490
		return (TaskData[]) iterationPersonTasks.toArray(new TaskData[iterationPersonTasks.size()]);
491
	}
492
}
(-)src/org/eclipse/mylyn/xplanner/core/service/PasswordPrompter.java (-1 / +1 lines)
Lines 5-11 Link Here
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
package org.eclipse.mylar.xplanner.core.service;
8
package org.eclipse.mylyn.xplanner.core.service;
9
9
10
import java.net.URL;
10
import java.net.URL;
11
11
(-)src/org/eclipse/mylyn/xplanner/core/service/XPlannerServiceFactory.java (-5 / +5 lines)
Lines 5-11 Link Here
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
package org.eclipse.mylar.xplanner.core.service;
8
package org.eclipse.mylyn.xplanner.core.service;
9
9
10
/**
10
/**
11
 * Factory class for creating ta XPlanner Service imlementation.
11
 * Factory class for creating ta XPlanner Service imlementation.
Lines 16-25 Link Here
16
 */
16
 */
17
public interface XPlannerServiceFactory {
17
public interface XPlannerServiceFactory {
18
	/**
18
	/**
19
	 * Create a new service that will communicate to the supplied <code>server</code>.
19
	 * Create a new service that will communicate to the supplied <code>client</code>.
20
	 * How the service talks to the server is up to the implementation.
20
	 * How the service talks to the client is up to the implementation.
21
	 * @param server XPlanner Server instance to communicate with
21
	 * @param client XPlannerClient instance to communicate with
22
	 * @return Configured XPlanner Service
22
	 * @return Configured XPlanner Service
23
	 */
23
	 */
24
	public abstract XPlannerService createService(XPlannerServer server);
24
	public abstract XPlannerService createService(XPlannerClient client);
25
}
25
}
(-)src/org/eclipse/mylyn/xplanner/core/service/XPlannerService.java (-4 / +4 lines)
Lines 5-14 Link Here
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
package org.eclipse.mylar.xplanner.core.service;
8
package org.eclipse.mylyn.xplanner.core.service;
9
9
10
import org.eclipse.mylar.xplanner.core.service.exceptions.AuthenticationException;
10
import org.eclipse.mylyn.xplanner.core.service.exceptions.AuthenticationException;
11
import org.eclipse.mylar.xplanner.core.service.exceptions.ServiceUnavailableException;
11
import org.eclipse.mylyn.xplanner.core.service.exceptions.ServiceUnavailableException;
12
import org.xplanner.soap.XPlanner.XPlanner;
12
import org.xplanner.soap.XPlanner.XPlanner;
13
13
14
14
Lines 27-33 Link Here
27
    }
27
    }
28
    
28
    
29
	/**
29
	/**
30
	 * Refresh any cached information with the latest values from the remote server.
30
	 * Refresh any cached information with the latest values from the remote client.
31
	 * This operation may take a long time to complete and should not be called
31
	 * This operation may take a long time to complete and should not be called
32
	 * from a UI thread.
32
	 * from a UI thread.
33
	 */
33
	 */
(-)src/org/eclipse/mylyn/xplanner/core/service/XPlannerServer.java (-2 / +8 lines)
Lines 5-11 Link Here
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
package org.eclipse.mylar.xplanner.core.service;
8
package org.eclipse.mylyn.xplanner.core.service;
9
10
import java.net.Proxy;
9
11
10
import org.xplanner.soap.TaskData;
12
import org.xplanner.soap.TaskData;
11
import org.xplanner.soap.UserStoryData;
13
import org.xplanner.soap.UserStoryData;
Lines 68-79 Link Here
68
	public abstract TaskData[] getTasksForProject(int projectId, int personId);
70
	public abstract TaskData[] getTasksForProject(int projectId, int personId);
69
	public abstract TaskData[] getTasksForIteration(int iterationId);
71
	public abstract TaskData[] getTasksForIteration(int iterationId);
70
	public abstract TaskData[] getTasksForIteration(int iterationId, int personId);
72
	public abstract TaskData[] getTasksForIteration(int iterationId, int personId);
73
	public abstract boolean useCompression();
74
	public abstract Proxy getProxy();
75
	public abstract String getHttpUser();
76
	public abstract String getHttpPassword();
71
	
77
	
72
//	/**
78
//	/**
73
//	 * Force a login to the remote repository.
79
//	 * Force a login to the remote repository.
74
//	 * @deprecated There is no need to call this method as all services should automatically
80
//	 * @deprecated There is no need to call this method as all services should automatically
75
//	 * login when the session is about to expire.  If you need to check if the credentials
81
//	 * login when the session is about to expire.  If you need to check if the credentials
76
//	 * are valid, call {@link org.eclipse.mylar.xplanner.core.ServerManager#testConnection(String, String, String)}
82
//	 * are valid, call {@link org.eclipse.mylyn.xplanner.core.ServerManager#testConnection(String, String, String)}
77
//	 */
83
//	 */
78
//	public abstract void login();
84
//	public abstract void login();
79
//	
85
//	
(-).project (+1 lines)
Lines 22-27 Link Here
22
		</buildCommand>
22
		</buildCommand>
23
	</buildSpec>
23
	</buildSpec>
24
	<natures>
24
	<natures>
25
		<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
25
		<nature>org.eclipse.pde.PluginNature</nature>
26
		<nature>org.eclipse.pde.PluginNature</nature>
26
		<nature>org.eclipse.jdt.core.javanature</nature>
27
		<nature>org.eclipse.jdt.core.javanature</nature>
27
	</natures>
28
	</natures>
(-)XPlanner WSDL2Java.launch (-3 / +3 lines)
Lines 4-13 Link Here
4
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
4
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
5
<listEntry value="4"/>
5
<listEntry value="4"/>
6
</listAttribute>
6
</listAttribute>
7
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-o &quot;${project_loc:org.eclipse.mylar.core.soap}/src&quot; ./wsdl/XPlanner.wsdl"/>
7
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-o &quot;${project_loc:org.eclipse.mylyn.core.soap}/src&quot; ./wsdl/XPlanner.wsdl"/>
8
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.mylar.core.soap"/>
8
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.mylyn.core.soap"/>
9
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
9
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
10
<listEntry value="/org.eclipse.mylar.core.soap"/>
10
<listEntry value="/org.eclipse.mylyn.core.soap"/>
11
</listAttribute>
11
</listAttribute>
12
<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
12
<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
13
</launchConfiguration>
13
</launchConfiguration>
(-)plugin.xml (-2 / +2 lines)
Lines 7-15 Link Here
7
         schema="schema/serviceProviderFactory.exsd"/>
7
         schema="schema/serviceProviderFactory.exsd"/>
8
8
9
   <extension
9
   <extension
10
         point="org.eclipse.mylar.xplanner.core.serviceProviderFactory">
10
         point="org.eclipse.mylyn.xplanner.core.serviceProviderFactory">
11
      <serviceProviderFactory
11
      <serviceProviderFactory
12
            class="org.eclipse.mylar.xplanner.core.service.soap.SoapXPlannerServiceFactory"
12
            class="org.eclipse.mylyn.xplanner.core.service.soap.SoapXPlannerServiceFactory"
13
            name="%serviceProviderFactoryNameSoap"/>
13
            name="%serviceProviderFactoryNameSoap"/>
14
   </extension>
14
   </extension>
15
</plugin>
15
</plugin>
(-)plugin.properties (-2 / +2 lines)
Lines 1-4 Link Here
1
bundleName=Mylar Connector for XPlanner: Core
1
bundleName=Mylyn XPlanner Core Plug-in
2
bundleVendor=Eclipse.org
2
bundleVendor=Eclipse.org
3
extensionPointNameServiceProviderFactory=Mylar XPlanner Service Provider Factory
3
extensionPointNameServiceProviderFactory=Mylyn XPlanner Service Provider Factory
4
serviceProviderFactoryNameSoap=SOAP Service Provider
4
serviceProviderFactoryNameSoap=SOAP Service Provider
(-)build.properties (-6 / +1 lines)
Lines 1-13 Link Here
1
source.. = src/, src-gen/
1
source.. = src/, src-gen/
2
output.. = bin/
2
output.. = bin/
3
source.plugin.jar = src/,\
4
                    src-gen/
5
output.plugin.jar = bin/
6
bin.includes = .,\
3
bin.includes = .,\
7
				lib/,\
4
               lib/,\
8
               META-INF/,\
5
               META-INF/,\
9
               schema/,\
6
               schema/,\
10
               plugin.jar,\
11
               plugin.properties,\
7
               plugin.properties,\
12
               plugin.xml,\
8
               plugin.xml,\
13
               about.html
9
               about.html
Lines 15-21 Link Here
15
               lib/,\
11
               lib/,\
16
               META-INF/,\
12
               META-INF/,\
17
               schema/,\
13
               schema/,\
18
               plugin.jar,\
19
               plugin.properties,\
14
               plugin.properties,\
20
               plugin.xml,\
15
               plugin.xml,\
21
               about.html,\
16
               about.html,\
(-)src-gen/org/eclipse/mylyn/xplanner/wsdl/db/QueryException.java (-1 / +1 lines)
Lines 5-11 Link Here
5
 * by the Apache Axis 1.3 Oct 05, 2005 (05:23:37 EDT) WSDL2Java emitter.
5
 * by the Apache Axis 1.3 Oct 05, 2005 (05:23:37 EDT) WSDL2Java emitter.
6
 */
6
 */
7
7
8
package org.eclipse.mylar.xplanner.wsdl.db;
8
package org.eclipse.mylyn.xplanner.wsdl.db;
9
9
10
@SuppressWarnings("unchecked")
10
@SuppressWarnings("unchecked")
11
public class QueryException  extends org.apache.axis.AxisFault  implements java.io.Serializable {
11
public class QueryException  extends org.apache.axis.AxisFault  implements java.io.Serializable {
(-)schema/serviceProviderFactory.exsd (-3 / +3 lines)
Lines 1-9 Link Here
1
<?xml version='1.0' encoding='UTF-8'?>
1
<?xml version='1.0' encoding='UTF-8'?>
2
<!-- Schema file written by PDE -->
2
<!-- Schema file written by PDE -->
3
<schema targetNamespace="org.eclipse.mylar.xplanner.core">
3
<schema targetNamespace="org.eclipse.mylyn.xplanner.core">
4
<annotation>
4
<annotation>
5
      <appInfo>
5
      <appInfo>
6
         <meta.schema plugin="org.eclipse.mylar.xplanner.core" id="serviceProviderFactory" name="Service provider factory"/>
6
         <meta.schema plugin="org.eclipse.mylyn.xplanner.core" id="serviceProviderFactory" name="Service provider factory"/>
7
      </appInfo>
7
      </appInfo>
8
      <documentation>
8
      <documentation>
9
         [Enter description of this extension point.]
9
         [Enter description of this extension point.]
Lines 65-71 Link Here
65
                  Class that implements the XPlanner Core service interface
65
                  Class that implements the XPlanner Core service interface
66
               </documentation>
66
               </documentation>
67
               <appInfo>
67
               <appInfo>
68
                  <meta.attribute kind="java" basedOn=":org.eclipse.mylar.xplanner.core.service.XPlannerServiceFactory"/>
68
                  <meta.attribute kind="java" basedOn=":org.eclipse.mylyn.xplanner.core.service.XPlannerServiceFactory"/>
69
               </appInfo>
69
               </appInfo>
70
            </annotation>
70
            </annotation>
71
         </attribute>
71
         </attribute>
(-)src/org/xplanner/soap/XPlanner/XPlannerProxy.java (-2 / +2 lines)
Lines 226-238 Link Here
226
    xPlanner.removeUserStory(id);
226
    xPlanner.removeUserStory(id);
227
  }
227
  }
228
  
228
  
229
  public org.xplanner.soap.TaskData[] getCurrentTasksForPerson(int personId) throws java.rmi.RemoteException, org.eclipse.mylar.xplanner.wsdl.db.QueryException{
229
  public org.xplanner.soap.TaskData[] getCurrentTasksForPerson(int personId) throws java.rmi.RemoteException, org.eclipse.mylyn.xplanner.wsdl.db.QueryException{
230
    if (xPlanner == null)
230
    if (xPlanner == null)
231
      _initXPlannerProxy();
231
      _initXPlannerProxy();
232
    return xPlanner.getCurrentTasksForPerson(personId);
232
    return xPlanner.getCurrentTasksForPerson(personId);
233
  }
233
  }
234
  
234
  
235
  public org.xplanner.soap.TaskData[] getPlannedTasksForPerson(int personId) throws java.rmi.RemoteException, org.eclipse.mylar.xplanner.wsdl.db.QueryException{
235
  public org.xplanner.soap.TaskData[] getPlannedTasksForPerson(int personId) throws java.rmi.RemoteException, org.eclipse.mylyn.xplanner.wsdl.db.QueryException{
236
    if (xPlanner == null)
236
    if (xPlanner == null)
237
      _initXPlannerProxy();
237
      _initXPlannerProxy();
238
    return xPlanner.getPlannedTasksForPerson(personId);
238
    return xPlanner.getPlannedTasksForPerson(personId);
(-)src/org/xplanner/soap/XPlanner/XPlanner.java (-2 / +2 lines)
Lines 40-47 Link Here
40
    public void removeIteration(int id) throws java.rmi.RemoteException;
40
    public void removeIteration(int id) throws java.rmi.RemoteException;
41
    public org.xplanner.soap.UserStoryData addUserStory(org.xplanner.soap.UserStoryData story) throws java.rmi.RemoteException;
41
    public org.xplanner.soap.UserStoryData addUserStory(org.xplanner.soap.UserStoryData story) throws java.rmi.RemoteException;
42
    public void removeUserStory(int id) throws java.rmi.RemoteException;
42
    public void removeUserStory(int id) throws java.rmi.RemoteException;
43
    public org.xplanner.soap.TaskData[] getCurrentTasksForPerson(int personId) throws java.rmi.RemoteException, org.eclipse.mylar.xplanner.wsdl.db.QueryException;
43
    public org.xplanner.soap.TaskData[] getCurrentTasksForPerson(int personId) throws java.rmi.RemoteException, org.eclipse.mylyn.xplanner.wsdl.db.QueryException;
44
    public org.xplanner.soap.TaskData[] getPlannedTasksForPerson(int personId) throws java.rmi.RemoteException, org.eclipse.mylar.xplanner.wsdl.db.QueryException;
44
    public org.xplanner.soap.TaskData[] getPlannedTasksForPerson(int personId) throws java.rmi.RemoteException, org.eclipse.mylyn.xplanner.wsdl.db.QueryException;
45
    public void removeTask(int id) throws java.rmi.RemoteException;
45
    public void removeTask(int id) throws java.rmi.RemoteException;
46
    public org.xplanner.soap.TimeEntryData getTimeEntry(int id) throws java.rmi.RemoteException;
46
    public org.xplanner.soap.TimeEntryData getTimeEntry(int id) throws java.rmi.RemoteException;
47
    public org.xplanner.soap.TimeEntryData addTimeEntry(org.xplanner.soap.TimeEntryData timeEntry) throws java.rmi.RemoteException;
47
    public org.xplanner.soap.TimeEntryData addTimeEntry(org.xplanner.soap.TimeEntryData timeEntry) throws java.rmi.RemoteException;
(-)src/org/xplanner/soap/XPlanner/XPlannerSoapBindingStub.java (-11 / +12 lines)
Lines 373-379 Link Here
373
        oper.setUse(org.apache.axis.constants.Use.ENCODED);
373
        oper.setUse(org.apache.axis.constants.Use.ENCODED);
374
        oper.addFault(new org.apache.axis.description.FaultDesc(
374
        oper.addFault(new org.apache.axis.description.FaultDesc(
375
                      new javax.xml.namespace.QName("http://xplanner.org:8080/soap/XPlanner", "fault"), //$NON-NLS-1$ //$NON-NLS-2$
375
                      new javax.xml.namespace.QName("http://xplanner.org:8080/soap/XPlanner", "fault"), //$NON-NLS-1$ //$NON-NLS-2$
376
                      "org.eclipse.mylar.xplanner.wsdl.db.QueryException", //$NON-NLS-1$
376
                      "org.eclipse.mylyn.xplanner.wsdl.db.QueryException", //$NON-NLS-1$
377
                      new javax.xml.namespace.QName("http://db.xplanner.technoetic.com", "QueryException"),  //$NON-NLS-1$ //$NON-NLS-2$
377
                      new javax.xml.namespace.QName("http://db.xplanner.technoetic.com", "QueryException"),  //$NON-NLS-1$ //$NON-NLS-2$
378
                      true
378
                      true
379
                     ));
379
                     ));
Lines 390-396 Link Here
390
        oper.setUse(org.apache.axis.constants.Use.ENCODED);
390
        oper.setUse(org.apache.axis.constants.Use.ENCODED);
391
        oper.addFault(new org.apache.axis.description.FaultDesc(
391
        oper.addFault(new org.apache.axis.description.FaultDesc(
392
                      new javax.xml.namespace.QName("http://xplanner.org:8080/soap/XPlanner", "fault"), //$NON-NLS-1$ //$NON-NLS-2$
392
                      new javax.xml.namespace.QName("http://xplanner.org:8080/soap/XPlanner", "fault"), //$NON-NLS-1$ //$NON-NLS-2$
393
                      "org.eclipse.mylar.xplanner.wsdl.db.QueryException", //$NON-NLS-1$
393
                      "org.eclipse.mylyn.xplanner.wsdl.db.QueryException", //$NON-NLS-1$
394
                      new javax.xml.namespace.QName("http://db.xplanner.technoetic.com", "QueryException"),  //$NON-NLS-1$ //$NON-NLS-2$
394
                      new javax.xml.namespace.QName("http://db.xplanner.technoetic.com", "QueryException"),  //$NON-NLS-1$ //$NON-NLS-2$
395
                      true
395
                      true
396
                     ));
396
                     ));
Lines 540-553 Link Here
540
            java.lang.Class simplelistdf = org.apache.axis.encoding.ser.SimpleListDeserializerFactory.class;
540
            java.lang.Class simplelistdf = org.apache.axis.encoding.ser.SimpleListDeserializerFactory.class;
541
            qName = new javax.xml.namespace.QName("http://db.xplanner.technoetic.com", "QueryException"); //$NON-NLS-1$ //$NON-NLS-2$
541
            qName = new javax.xml.namespace.QName("http://db.xplanner.technoetic.com", "QueryException"); //$NON-NLS-1$ //$NON-NLS-2$
542
            cachedSerQNames.add(qName);
542
            cachedSerQNames.add(qName);
543
            cls = org.eclipse.mylar.xplanner.wsdl.db.QueryException.class;
543
            cls = org.eclipse.mylyn.xplanner.wsdl.db.QueryException.class;
544
            cachedSerClasses.add(cls);
544
            cachedSerClasses.add(cls);
545
            cachedSerFactories.add(beansf);
545
            cachedSerFactories.add(beansf);
546
            cachedDeserFactories.add(beandf);
546
            cachedDeserFactories.add(beandf);
547
547
548
            qName = new javax.xml.namespace.QName("http://domain.soap.xplanner.technoetic.com", "DomainData"); //$NON-NLS-1$ //$NON-NLS-2$
548
            qName = new javax.xml.namespace.QName("http://domain.soap.xplanner.technoetic.com", "DomainData"); //$NON-NLS-1$ //$NON-NLS-2$
549
            cachedSerQNames.add(qName);
549
            cachedSerQNames.add(qName);
550
            cls = org.eclipse.mylar.xplanner.wsdl.soap.domain.DomainData.class;
550
            cls = org.eclipse.mylyn.xplanner.wsdl.soap.domain.DomainData.class;
551
            cachedSerClasses.add(cls);
551
            cachedSerClasses.add(cls);
552
            cachedSerFactories.add(beansf);
552
            cachedSerFactories.add(beansf);
553
            cachedDeserFactories.add(beandf);
553
            cachedDeserFactories.add(beandf);
Lines 1391-1397 Link Here
1391
        _call.setSOAPActionURI(""); //$NON-NLS-1$
1391
        _call.setSOAPActionURI(""); //$NON-NLS-1$
1392
        _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS);
1392
        _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS);
1393
        _call.setOperationName(new javax.xml.namespace.QName("http://soap.xplanner.technoetic.com", "getTask")); //$NON-NLS-1$ //$NON-NLS-2$
1393
        _call.setOperationName(new javax.xml.namespace.QName("http://soap.xplanner.technoetic.com", "getTask")); //$NON-NLS-1$ //$NON-NLS-2$
1394
1394
        _call.setTimeout(new Integer(30000));
1395
        
1395
        setRequestHeaders(_call);
1396
        setRequestHeaders(_call);
1396
        setAttachments(_call);
1397
        setAttachments(_call);
1397
 try {        java.lang.Object _resp = _call.invoke(new java.lang.Object[] {new java.lang.Integer(id)});
1398
 try {        java.lang.Object _resp = _call.invoke(new java.lang.Object[] {new java.lang.Integer(id)});
Lines 1608-1614 Link Here
1608
}
1609
}
1609
    }
1610
    }
1610
1611
1611
    public org.xplanner.soap.TaskData[] getCurrentTasksForPerson(int personId) throws java.rmi.RemoteException, org.eclipse.mylar.xplanner.wsdl.db.QueryException {
1612
    public org.xplanner.soap.TaskData[] getCurrentTasksForPerson(int personId) throws java.rmi.RemoteException, org.eclipse.mylyn.xplanner.wsdl.db.QueryException {
1612
        if (super.cachedEndpoint == null) {
1613
        if (super.cachedEndpoint == null) {
1613
            throw new org.apache.axis.NoEndPointException();
1614
            throw new org.apache.axis.NoEndPointException();
1614
        }
1615
        }
Lines 1639-1653 Link Here
1639
        if (axisFaultException.detail instanceof java.rmi.RemoteException) {
1640
        if (axisFaultException.detail instanceof java.rmi.RemoteException) {
1640
              throw (java.rmi.RemoteException) axisFaultException.detail;
1641
              throw (java.rmi.RemoteException) axisFaultException.detail;
1641
         }
1642
         }
1642
        if (axisFaultException.detail instanceof org.eclipse.mylar.xplanner.wsdl.db.QueryException) {
1643
        if (axisFaultException.detail instanceof org.eclipse.mylyn.xplanner.wsdl.db.QueryException) {
1643
              throw (org.eclipse.mylar.xplanner.wsdl.db.QueryException) axisFaultException.detail;
1644
              throw (org.eclipse.mylyn.xplanner.wsdl.db.QueryException) axisFaultException.detail;
1644
         }
1645
         }
1645
   }
1646
   }
1646
  throw axisFaultException;
1647
  throw axisFaultException;
1647
}
1648
}
1648
    }
1649
    }
1649
1650
1650
    public org.xplanner.soap.TaskData[] getPlannedTasksForPerson(int personId) throws java.rmi.RemoteException, org.eclipse.mylar.xplanner.wsdl.db.QueryException {
1651
    public org.xplanner.soap.TaskData[] getPlannedTasksForPerson(int personId) throws java.rmi.RemoteException, org.eclipse.mylyn.xplanner.wsdl.db.QueryException {
1651
        if (super.cachedEndpoint == null) {
1652
        if (super.cachedEndpoint == null) {
1652
            throw new org.apache.axis.NoEndPointException();
1653
            throw new org.apache.axis.NoEndPointException();
1653
        }
1654
        }
Lines 1678-1685 Link Here
1678
        if (axisFaultException.detail instanceof java.rmi.RemoteException) {
1679
        if (axisFaultException.detail instanceof java.rmi.RemoteException) {
1679
              throw (java.rmi.RemoteException) axisFaultException.detail;
1680
              throw (java.rmi.RemoteException) axisFaultException.detail;
1680
         }
1681
         }
1681
        if (axisFaultException.detail instanceof org.eclipse.mylar.xplanner.wsdl.db.QueryException) {
1682
        if (axisFaultException.detail instanceof org.eclipse.mylyn.xplanner.wsdl.db.QueryException) {
1682
              throw (org.eclipse.mylar.xplanner.wsdl.db.QueryException) axisFaultException.detail;
1683
              throw (org.eclipse.mylyn.xplanner.wsdl.db.QueryException) axisFaultException.detail;
1683
         }
1684
         }
1684
   }
1685
   }
1685
  throw axisFaultException;
1686
  throw axisFaultException;
(-)src/org/xplanner/soap/XPlanner/XPlannerServiceLocator.java (+74 lines)
Lines 7-15 Link Here
7
7
8
package org.xplanner.soap.XPlanner;
8
package org.xplanner.soap.XPlanner;
9
9
10
import java.net.Proxy;
11
import java.util.Hashtable;
12
import java.util.Map;
13
14
import javax.xml.rpc.Call;
15
import javax.xml.rpc.ServiceException;
16
17
import org.apache.axis.transport.http.HTTPConstants;
18
10
@SuppressWarnings("unchecked")
19
@SuppressWarnings("unchecked")
11
public class XPlannerServiceLocator extends org.apache.axis.client.Service implements org.xplanner.soap.XPlanner.XPlannerService {
20
public class XPlannerServiceLocator extends org.apache.axis.client.Service implements org.xplanner.soap.XPlanner.XPlannerService {
12
21
22
		private Proxy proxy;
23
		private String httpUser;
24
		private String httpPassword;
25
		private boolean compression;
26
		
13
    public XPlannerServiceLocator() {
27
    public XPlannerServiceLocator() {
14
    }
28
    }
15
29
Lines 140-143 Link Here
140
        setEndpointAddress(portName.getLocalPart(), address);
154
        setEndpointAddress(portName.getLocalPart(), address);
141
    }
155
    }
142
156
157
  	/*
158
  	 * (non-Javadoc)
159
  	 * 
160
  	 * @see org.apache.axis.client.Service#createCall()
161
  	 */
162
  	public Call createCall() throws ServiceException {
163
  		Call call = super.createCall();
164
  		// JIRA does not accept compressed SOAP messages: see bug 175915
165
  		//call.setProperty(HTTPConstants.MC_GZIP_REQUEST, Boolean.TRUE);
166
  		if (compression) {
167
  			call.setProperty(HTTPConstants.MC_ACCEPT_GZIP, Boolean.TRUE);
168
  		}
169
  		if (httpUser != null && httpPassword != null) {
170
  			call.setProperty(XPlannerHttpSender.HTTP_USER, httpUser);
171
  			call.setProperty(XPlannerHttpSender.HTTP_PASSWORD, httpPassword);
172
  		}
173
  		if (proxy != null) {
174
  			call.setProperty(XPlannerHttpSender.PROXY, proxy);
175
  		}
176
  		
177
  		// Some clients break with a 411 Length Required when chunked encoding
178
  		// is used
179
  		Map<String, Boolean> headers = new Hashtable<String, Boolean>();
180
  		headers.put(HTTPConstants.HEADER_TRANSFER_ENCODING_CHUNKED, Boolean.FALSE);
181
  		call.setProperty(HTTPConstants.REQUEST_HEADERS, headers);
182
  		return call;
183
  	}
184
185
  	public Proxy getProxy() {
186
  		return proxy;
187
  	}
188
189
  	public void setProxy(Proxy proxy) {
190
  		this.proxy = proxy;
191
  	}
192
193
  	public String getHttpUser() {
194
  		return httpUser;
195
  	}
196
197
  	public void setHttpUser(String httpUser) {
198
  		this.httpUser = httpUser;
199
  	}
200
201
  	public String getHttpPassword() {
202
  		return httpPassword;
203
  	}
204
205
  	public void setHttpPassword(String httpPassword) {
206
  		this.httpPassword = httpPassword;
207
  	}
208
209
  	public boolean isCompression() {
210
  		return compression;
211
  	}
212
  	
213
  	public void setCompression(boolean compression) {
214
  		this.compression = compression;
215
  	}
216
  	
143
}
217
}
(-)META-INF/MANIFEST.MF (-9 / +12 lines)
Lines 1-18 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
Bundle-ManifestVersion: 2
2
Bundle-ManifestVersion: 2
3
Bundle-Name: %bundleName
3
Bundle-Name: %bundleName
4
Bundle-SymbolicName: org.eclipse.mylar.xplanner.core;singleton:=true
4
Bundle-SymbolicName: org.eclipse.mylyn.xplanner.core;singleton:=true
5
Bundle-Version: 2.0.0.qualifier
5
Bundle-Version: 2.0.0.qualifier
6
Bundle-Activator: org.eclipse.mylar.xplanner.core.XPlannerCorePlugin
6
Bundle-Activator: org.eclipse.mylyn.xplanner.core.XPlannerCorePlugin
7
Bundle-Vendor: %bundleVendor
7
Bundle-Vendor: %bundleVendor
8
Bundle-Localization: plugin
8
Bundle-Localization: plugin
9
Require-Bundle: org.eclipse.core.runtime
9
Require-Bundle: org.eclipse.core.runtime,
10
 org.eclipse.mylyn,
11
 org.eclipse.mylyn.web.core
10
Eclipse-LazyStart: true
12
Eclipse-LazyStart: true
11
Export-Package: org.eclipse.mylar.xplanner.core,
13
Export-Package: org.apache.axis,
12
 org.eclipse.mylar.xplanner.core.service,
13
 org.eclipse.mylar.xplanner.core.service.exceptions,org.eclipse.mylar.xplanner.wsdl.db,
14
 org.eclipse.mylar.xplanner.wsdl.soap.domain,
15
 org.apache.axis,
16
 org.apache.axis.attachments,
14
 org.apache.axis.attachments,
17
 org.apache.axis.client,
15
 org.apache.axis.client,
18
 org.apache.axis.client.async,
16
 org.apache.axis.client.async,
Lines 67-75 Link Here
67
 org.apache.axis.wsdl.gen,
65
 org.apache.axis.wsdl.gen,
68
 org.apache.axis.wsdl.symbolTable,
66
 org.apache.axis.wsdl.symbolTable,
69
 org.apache.axis.wsdl.toJava,
67
 org.apache.axis.wsdl.toJava,
68
 org.eclipse.mylyn.xplanner.wsdl.db,
69
 org.eclipse.mylyn.xplanner.wsdl.soap.domain,
70
 org.eclipse.mylyn.xplanner.core,
71
 org.eclipse.mylyn.xplanner.core.service,
72
 org.eclipse.mylyn.xplanner.core.service.exceptions,
70
 org.xplanner.soap,
73
 org.xplanner.soap,
71
 org.xplanner.soap.XPlanner
74
 org.xplanner.soap.XPlanner
72
Bundle-ClassPath: plugin.jar,
75
Bundle-ClassPath: .,
73
 lib/axis.jar,
76
 lib/axis.jar,
74
 lib/commons-codec-1.3.jar,
77
 lib/commons-codec-1.3.jar,
75
 lib/commons-discovery-0.2.jar,
78
 lib/commons-discovery-0.2.jar,
(-)src/org/eclipse/mylyn/xplanner/core/XPlannerClientListener.java (+22 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 - 2007 CodeGear 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
package org.eclipse.mylyn.xplanner.core;
9
10
/**
11
 * @author Ravi Kumar
12
 * @author Helen Bershadskaya
13
 */
14
import org.eclipse.mylyn.xplanner.core.service.XPlannerClient;
15
16
17
public interface XPlannerClientListener {
18
19
	public abstract void clientAdded(XPlannerClient client);
20
	
21
	public abstract void clientRemoved(XPlannerClient client);
22
}
(-)src/org/eclipse/mylyn/xplanner/core/service/XPlannerClient.java (+93 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 - 2007 CodeGear 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
package org.eclipse.mylyn.xplanner.core.service;
9
10
import java.net.Proxy;
11
12
import org.xplanner.soap.TaskData;
13
import org.xplanner.soap.UserStoryData;
14
15
/**
16
 * TODO this class needs to be populated using the SOAP or JAX-RPC interfaces.
17
 * Once this is done it should be cached on disk somewhere so we don't have to
18
 * query the server each time a client loads.  It should be possible to reload
19
 * and restore the cache information.  We also need to store the images in a
20
 * cache somewhere since we will use them a lot.
21
 * 
22
 * TODO explain this is an attempt to enrich the XPlanner service layer
23
 * 
24
 * TODO move all of the assignee stuff somewhere else.
25
 * 
26
 * @author Ravi Kumar 
27
 * @author Helen Bershadskaya 
28
 */
29
30
public abstract class XPlannerClient extends XPlannerService {
31
	public static final int NO_LIMIT = -1;
32
	
33
	
34
	/**
35
	 * Assign to the default user
36
	 */
37
	public static final int ASSIGNEE_DEFAULT = 1;
38
	
39
	/**
40
	 * Leave the assignee field as is (this does not apply when performing an assign to action)
41
	 */
42
	public static final int ASSIGNEE_CURRENT = 2;
43
	
44
	/**
45
	 * Assign to nobody
46
	 */
47
	public static final int ASSIGNEE_NONE = 3;
48
	
49
	/**
50
	 * Assign to a specific user.  To get the name of the assignee call {@link #getAssignee()}
51
	 */
52
	public static final int ASSIGNEE_USER = 4;
53
	
54
	/**
55
	 * Assign to the current user
56
	 */
57
	public static final int ASSIGNEE_SELF = 5;
58
	
59
	public abstract boolean hasSlowConnection();
60
	public abstract String getName();
61
	public abstract String getBaseURL();
62
	public abstract String getCurrentUserName();
63
	public abstract String getCurrentUserPassword();
64
	public abstract int getCurrentPersonId();
65
	public abstract TaskData[] getUserStoryTasksForPerson(int personId, int userStoryId);
66
	public abstract UserStoryData[] getIterationUserStoriesForTracker(int trackerId, int iterationId);
67
	public abstract UserStoryData[] getUserStoriesForProject(int projectId);
68
	public abstract UserStoryData[] getUserStoriesForProject(int projectId, int trackerId);
69
	public abstract TaskData[] getTasksForProject(int projectId);
70
	public abstract TaskData[] getTasksForProject(int projectId, int personId);
71
	public abstract TaskData[] getTasksForIteration(int iterationId);
72
	public abstract TaskData[] getTasksForIteration(int iterationId, int personId);
73
	public abstract boolean useCompression();
74
	public abstract Proxy getProxy();
75
	public abstract String getHttpUser();
76
	public abstract String getHttpPassword();
77
	
78
//	/**
79
//	 * Force a login to the remote repository.
80
//	 * @deprecated There is no need to call this method as all services should automatically
81
//	 * login when the session is about to expire.  If you need to check if the credentials
82
//	 * are valid, call {@link org.eclipse.mylyn.xplanner.core.ClientManager#testConnection(String, String, String)}
83
//	 */
84
//	public abstract void login();
85
//	
86
//	/**
87
//	 * Force the current session to be closed.  This method should only be called during
88
//	 * application shutdown and then only out of courtesy to the server.  XPlanner will
89
//	 * automatically expire sessions after a set amount of time.
90
//	 */
91
//	public abstract void logout();
92
//	
93
}
(-)src/org/xplanner/soap/XPlanner/XPlannerHttpSender.java (+26 lines)
Added Link Here
1
package org.xplanner.soap.XPlanner;
2
3
import java.net.Proxy;
4
import java.net.URL;
5
6
import org.apache.axis.MessageContext;
7
import org.apache.axis.transport.http.CommonsHTTPSender;
8
import org.apache.commons.httpclient.HostConfiguration;
9
import org.apache.commons.httpclient.HttpClient;
10
import org.eclipse.mylyn.web.core.WebClientUtil;
11
12
public class XPlannerHttpSender extends CommonsHTTPSender {
13
	
14
	public static final String PROXY = "org.eclipse.mylyn.xplanner.proxy"; //$NON-NLS-1$
15
	public static final String HTTP_USER = "org.eclipse.mylyn.xplanner.httpUser"; //$NON-NLS-1$
16
	public static final String HTTP_PASSWORD = "org.eclipse.mylyn.xplanner.httpPassword"; //$NON-NLS-1$
17
	
18
	@Override
19
	protected HostConfiguration getHostConfiguration(HttpClient client, MessageContext context, URL url) {
20
		Proxy proxy = (Proxy) context.getProperty(PROXY);
21
		String httpUser = (String) context.getProperty(HTTP_USER);
22
		String httpPassword = (String) context.getProperty(HTTP_PASSWORD);
23
		WebClientUtil.setupHttpClient(client, proxy, url.toString(), httpUser, httpPassword);
24
		return client.getHostConfiguration();
25
	}
26
}
(-)src/org/eclipse/mylyn/xplanner/core/service/soap/client-config.wsdd (+14 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<deployment name="defaultClientConfig"
3
            xmlns="http://xml.apache.org/axis/wsdd/"
4
            xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
5
<!--
6
  <transport name="http" pivot="java:org.apache.axis.transport.http.CommonsHTTPSender" />
7
  <transport name="https" pivot="java:org.apache.axis.transport.http.CommonsHTTPSender"/>
8
-->
9
  <transport name="http" pivot="java:org.xplanner.soap.XPlannerHttpSender" />
10
  <transport name="https" pivot="java:org.xplanner.soap.XPlannerHttpSender"/>
11
12
  <transport name="local" pivot="java:org.apache.axis.transport.local.LocalSender"/>
13
14
</deployment>
(-)src/org/eclipse/mylyn/xplanner/core/XPlannerClientManager.java (+257 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 - 2007 CodeGear 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
package org.eclipse.mylyn.xplanner.core;
9
10
/**
11
 * @author Ravi Kumar
12
 * @author Helen Bershadskaya
13
 */
14
import java.io.*;
15
import java.net.Proxy;
16
import java.net.URL;
17
import java.rmi.RemoteException;
18
import java.util.*;
19
20
import org.apache.axis.AxisFault;
21
import org.eclipse.mylyn.xplanner.core.service.CachedXPlannerClient;
22
import org.eclipse.mylyn.xplanner.core.service.XPlannerClient;
23
import org.eclipse.mylyn.xplanner.core.service.exceptions.AuthenticationException;
24
import org.eclipse.mylyn.xplanner.core.service.exceptions.ServiceUnavailableException;
25
import org.xml.sax.SAXException;
26
27
28
/**
29
 * @author Helen Bershadskaya 
30
 * @author Ravi Kumar 
31
 */
32
public class XPlannerClientManager {
33
34
	private final File cacheLocation;
35
36
	private Map<String, XPlannerClient> clientByName = new HashMap<String, XPlannerClient>();
37
38
	// TODO Use a decent listener list
39
	private List<XPlannerClientListener> listeners = new ArrayList<XPlannerClientListener>();
40
	
41
	public XPlannerClientManager(File cacheLocation) {
42
		this.cacheLocation = cacheLocation;
43
	}
44
	
45
	protected void start() {
46
		// On first load the cache may not exist
47
		cacheLocation.mkdirs();
48
		
49
		File[] clients = this.cacheLocation.listFiles();
50
		for (int i = 0; i < clients.length; i++) {
51
			File clientCache = clients[i];
52
			File clientFile = new File(clientCache, "server.ser"); //$NON-NLS-1$
53
			
54
			ObjectInputStream ois = null;
55
			try {
56
				ois = new ObjectInputStream(new BufferedInputStream(new FileInputStream(clientFile)));
57
				XPlannerClient client = (XPlannerClient) ois.readObject();
58
				// TODO reconnect the services depending on user preferences
59
				
60
				clientByName.put(clientCache.getName(), client);
61
				ois.close();
62
			} catch (IOException e) {
63
				e.printStackTrace();
64
			} catch (ClassNotFoundException e) {
65
				e.printStackTrace();
66
			} finally {
67
				if (ois != null) {
68
					try {
69
						ois.close();
70
					} catch (IOException e) {
71
					}
72
				}
73
			}
74
		}
75
	}
76
	
77
	protected void stop() {
78
		for (Iterator<XPlannerClient> iClients = clientByName.values().iterator(); iClients.hasNext();) {
79
			XPlannerClient client = iClients.next();
80
			
81
			ObjectOutputStream oos = null;
82
			try {
83
				File cacheDir = new File(cacheLocation, client.getName());
84
				cacheDir.mkdirs();
85
				
86
				oos = new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream(new File(cacheDir, "server.ser")))); //$NON-NLS-1$
87
				oos.writeObject(client);
88
			} catch (IOException e) {
89
				e.printStackTrace();
90
			} finally {
91
				if (oos != null) {
92
					try {
93
						oos.close();
94
					} catch (IOException e) {
95
					}
96
				}
97
			}
98
		}
99
	}
100
	
101
	/**
102
	 * Tests the connection to a client.  If the URL is invalid ot the username
103
	 * and password are invalid this method will return with a exceptions carrying
104
	 * the failure reason. 
105
	 * @param baseUrl Base URL of the XPlanner installation
106
	 * @param username username to connect with
107
	 * @param password Password to connect with
108
	 * @return Short string describing the client information
109
	 * @throws AuthenticationException URL was valid but username and password were incorrect
110
	 * @throws ServiceUnavailableException URL was not valid
111
	 */
112
	public String testConnection(String baseUrl, String username, String password,
113
			Proxy proxy, String httpUser, String httpPassword) throws AuthenticationException, ServiceUnavailableException {
114
		if (baseUrl == null || baseUrl.length() == 0) {
115
			throw new AuthenticationException(Messages.ClientManager_CLIENT_URL_CANNOT_BE_EMPTY);
116
		}
117
		
118
		XPlannerClient client = null;
119
		
120
		try {
121
			new URL(baseUrl).openConnection(); // tests url validity
122
123
			client = createClient("Connection Test", baseUrl, false, username, password, //$NON-NLS-1$
124
				false, proxy, httpUser, httpPassword);
125
			
126
			client.getTask(-1);
127
		}
128
		catch (RemoteException re) {
129
			if (re instanceof AxisFault) {
130
				String message = re.getMessage().trim();
131
				if (message.startsWith("(401)")) { //$NON-NLS-1$
132
					message = Messages.ClientManager_INVALID_USERNAME_PASSWORD;
133
				}
134
				else if (re.getCause() instanceof SAXException) {
135
					message = ""; //$NON-NLS-1$
136
				}
137
				else {
138
					if (re.getCause() != null) {
139
						message = re.getCause().getMessage();
140
					}
141
					message = message.startsWith(";") ? message.substring(1).trim() : message; //$NON-NLS-1$
142
				}
143
				throw new AuthenticationException(message);
144
			}
145
			else {
146
				throw new ServiceUnavailableException(re.getMessage());
147
			}
148
		}
149
		catch (Exception e) {
150
			throw new ServiceUnavailableException(e.getMessage());
151
		}
152
		finally {
153
			if (client != null) {
154
				removeClient(client);
155
			}
156
		}
157
		
158
		return "XPlanner"; //$NON-NLS-1$
159
	}
160
	
161
	public XPlannerClient getClient(String name) {
162
		return (XPlannerClient) clientByName.get(name);
163
	}
164
	
165
	public XPlannerClient[] getAllClients() {
166
		return (XPlannerClient[]) clientByName.values().toArray(new XPlannerClient[clientByName.size()]);
167
	}
168
	
169
	public XPlannerClient createClient(String name, String baseUrl, boolean hasSlowConnection, 
170
			String username, String password, boolean useCompression, Proxy proxy, String httpUser, String httpPassword) {
171
		if (baseUrl.charAt(baseUrl.length() - 1) == '/') {
172
			baseUrl = baseUrl.substring(0, baseUrl.length() - 1);
173
		}
174
		
175
		XPlannerClient client = new CachedXPlannerClient(name, baseUrl, hasSlowConnection, username, password, useCompression,
176
				proxy, httpUser, httpPassword);
177
		return client;
178
	}
179
	
180
	public void addClient(XPlannerClient client) {
181
		if (clientByName.containsKey(client.getName())) {
182
//			TODO: add this check back once the listeners for client property change are hooked up
183
//			 Also handle the case when serviceDelegate in the cachedServer is null
184
//			throw new RuntimeException("A server with that name already exists");
185
			removeClient(client);
186
		}
187
		clientByName.put(client.getName(), client);
188
		fireClientAddded(client);
189
	}
190
	
191
	public void removeClient(XPlannerClient client) {
192
		clientByName.remove(client.getName());
193
		
194
		File clientCache = new File(this.cacheLocation, client.getName());
195
		if (clientCache.exists()) {
196
			recursiveDelete(clientCache);
197
		}
198
		fireClientRemoved(client);
199
	}
200
201
	/**
202
	 * TODO need to make this a bit smarter.  Perhaps have an object to hold connectino info
203
	 * @param name
204
	 * @param baseURL
205
	 * @param username
206
	 * @param password
207
	 */
208
	public void updateClientDetails(String name, String baseURL, boolean hasSlowConnection, String username, String password) {
209
		CachedXPlannerClient client = (CachedXPlannerClient) clientByName.get(name);
210
		// TODO we should really have a modify event
211
212
		fireClientRemoved(client);
213
		
214
		// TODO need to flush the client cache since we are possibly a different person
215
		client.setBaseURL(baseURL);
216
		client.setSlowConnection(hasSlowConnection);
217
		client.setCurrentUserName(username);
218
		client.setCurrentPassword(password);
219
		
220
		fireClientAddded(client);
221
	}
222
	
223
	public void addClientListener(XPlannerClientListener listener) {
224
		listeners.add(listener);
225
	}
226
	
227
	public void removeClientListener(XPlannerClientListener listener) {
228
		listeners.remove(listener);
229
	}
230
	
231
	private void fireClientRemoved(XPlannerClient client) {
232
		for (Iterator<XPlannerClientListener> iListeners = listeners.iterator(); iListeners.hasNext();) {
233
			XPlannerClientListener listener = (XPlannerClientListener)iListeners.next();
234
			listener.clientRemoved(client);
235
		}
236
	}
237
	
238
	private void fireClientAddded(XPlannerClient client) {
239
		for (Iterator<XPlannerClientListener> iListeners = listeners.iterator(); iListeners.hasNext();) {
240
			XPlannerClientListener listener = (XPlannerClientListener)iListeners.next();
241
			listener.clientAdded(client);
242
		}
243
	}
244
	
245
	private void recursiveDelete(File baseFile) {
246
		if (baseFile.isFile()) {
247
			baseFile.delete();
248
		} else {
249
			File[] children = baseFile.listFiles();
250
			for (int i = 0; i < children.length; i++) {
251
				File file = children[i];
252
				recursiveDelete(file);
253
			}
254
			baseFile.delete();
255
		}
256
	}
257
}
(-)src/org/eclipse/mylyn/xplanner/core/service/CachedXPlannerClient.java (+514 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 - 2007 CodeGear 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
package org.eclipse.mylyn.xplanner.core.service;
9
10
import java.io.Serializable;
11
import java.net.Proxy;
12
import java.rmi.RemoteException;
13
import java.util.*;
14
15
import org.eclipse.mylyn.xplanner.wsdl.db.QueryException;
16
import org.xplanner.soap.*;
17
18
19
/**
20
 * XPlanner client implementation that caches information that is unlikely to change
21
 * during the session.  This client could be persisted to disk and re-loaded.
22
 * It has lifecycle methods to allow data in the cache to be reloaded.
23
 * 
24
 * TODO it is assumed that it will be backed by a standard XPlanner service layer 
25
 * 
26
 * @author Ravi Kumar
27
 * @author Helen Bershadskaya
28
 */
29
public class CachedXPlannerClient extends XPlannerClient 
30
	implements Serializable {
31
	
32
  public static final int INVALID_ID = -1;
33
  
34
	/**
35
	 * 
36
	 */
37
	private static final long serialVersionUID = 1L;
38
	private String name;
39
	private String baseURL;
40
	private boolean hasSlowConnection;
41
	private String userName;
42
	private String password;
43
	private final boolean useCompression;
44
	private final transient Proxy proxy;
45
	private final String httpUser;
46
	private final String httpPassword;
47
	private transient XPlannerService serviceDelegate;
48
49
	public CachedXPlannerClient(String name, String baseURL, boolean hasSlowConnection, String userName, String password,
50
			boolean useCompression, Proxy proxy, String httpUser, String httpPassword) {
51
		this.name = name;
52
		this.baseURL = baseURL;
53
		this.hasSlowConnection = hasSlowConnection;
54
		this.userName = userName;
55
		this.password = password;
56
		this.useCompression = useCompression;
57
		this.proxy = proxy;
58
		this.httpUser = httpUser;
59
		this.httpPassword = httpPassword;
60
61
		
62
		this.serviceDelegate = ServiceManager.getXPlannerService(this);
63
		serviceDelegate.login(userName, password);
64
	}
65
66
	public String getBaseURL() {
67
		return baseURL;
68
	}
69
70
	public String getCurrentUserName() {
71
		return userName;
72
	}
73
74
	public String getCurrentUserPassword() {
75
		return password;
76
	}
77
78
	public int getMaximumNumberOfMatches() {
79
		return 0;
80
	}
81
82
	public String getName() {
83
		return name;
84
	}
85
86
	public boolean hasSlowConnection() {
87
		return hasSlowConnection;
88
	}
89
90
91
	public void setSlowConnection(boolean hasSlowConnection) {
92
		this.hasSlowConnection = hasSlowConnection;
93
	}
94
95
	public void setBaseURL(String baseURL) {
96
		this.baseURL = baseURL;
97
	}
98
99
	public void setCurrentPassword(String password) {
100
		this.password = password;
101
	}
102
103
	public void setCurrentUserName(String userName) {
104
		this.userName = userName;
105
	}
106
	
107
	public String login(String username, String password) {
108
		return serviceDelegate.login(username, password);		
109
	}
110
111
	public boolean logout() {
112
		boolean ok = true;
113
	
114
		//TODO -- shouldn't have a null service delegate, but definitely get into this condition if "finish"
115
		// repository definition with an invalid client
116
	
117
		if (serviceDelegate != null) {
118
			ok = serviceDelegate.logout();
119
		}
120
		
121
		return ok;
122
	}
123
124
	public IterationData addIteration(IterationData iteration) throws RemoteException {
125
		return serviceDelegate.addIteration(iteration);
126
	}
127
128
	public NoteData addNote(NoteData note) throws RemoteException {
129
		return serviceDelegate.addNote(note);
130
	}
131
132
	public PersonData addPerson(PersonData object) throws RemoteException {
133
		return serviceDelegate.addPerson(object);
134
	}
135
136
	public ProjectData addProject(ProjectData project) throws RemoteException {
137
		return serviceDelegate.addProject(project);
138
	}
139
140
	public TaskData addTask(TaskData task) throws RemoteException {
141
		return serviceDelegate.addTask(task);
142
	}
143
144
	public TimeEntryData addTimeEntry(TimeEntryData timeEntry) throws RemoteException {
145
		return serviceDelegate.addTimeEntry(timeEntry);
146
	}
147
148
	public UserStoryData addUserStory(UserStoryData story) throws RemoteException {
149
		return serviceDelegate.addUserStory(story);
150
	}
151
152
	public void deleteAttribute(int objectId, String key) throws RemoteException {
153
		serviceDelegate.deleteAttribute(objectId, key);
154
	}
155
156
	public boolean equals(Object obj) {
157
		return this == obj || serviceDelegate.equals(obj) || 
158
		 (obj instanceof CachedXPlannerClient && ((CachedXPlannerClient)obj).serviceDelegate.equals(serviceDelegate));
159
	}
160
161
	public String getAttribute(int objectId, String key) throws RemoteException {
162
		return serviceDelegate.getAttribute(objectId, key);
163
	}
164
165
	@SuppressWarnings("unchecked")
166
	public HashMap getAttributes(int objectId) throws RemoteException {
167
		return serviceDelegate.getAttributes(objectId);
168
	}
169
170
	@SuppressWarnings("unchecked")
171
	public HashMap getAttributesWithPrefix(int objectId, String prefix) throws RemoteException {
172
		return serviceDelegate.getAttributesWithPrefix(objectId, prefix);
173
	}
174
175
	public IterationData getCurrentIteration(int projectId) throws RemoteException {
176
		return serviceDelegate.getCurrentIteration(projectId);
177
	}
178
179
	public TaskData[] getCurrentTasksForPerson(int personId) throws RemoteException, QueryException {
180
		return serviceDelegate.getCurrentTasksForPerson(personId);
181
	}
182
183
	public IterationData getIteration(int id) throws RemoteException {
184
		return serviceDelegate.getIteration(id);
185
	}
186
187
	public IterationData[] getIterations(int projectId) throws RemoteException {
188
		return serviceDelegate.getIterations(projectId);
189
	}
190
191
	public NoteData getNote(int id) throws RemoteException {
192
		return serviceDelegate.getNote(id);
193
	}
194
195
	public NoteData[] getNotesForObject(int attachedToId) throws RemoteException {
196
		return serviceDelegate.getNotesForObject(attachedToId);
197
	}
198
199
	public PersonData[] getPeople() throws RemoteException {
200
		return serviceDelegate.getPeople();
201
	}
202
203
	public PersonData getPerson(int id) throws RemoteException {
204
		return serviceDelegate.getPerson(id);
205
	}
206
207
	public TaskData[] getPlannedTasksForPerson(int personId) throws RemoteException, QueryException {
208
		return serviceDelegate.getPlannedTasksForPerson(personId);
209
	}
210
211
	public ProjectData getProject(int id) throws RemoteException {
212
		return serviceDelegate.getProject(id);
213
	}
214
215
	public ProjectData[] getProjects() throws RemoteException {
216
		return serviceDelegate.getProjects();
217
	}
218
219
	public TaskData getTask(int id) throws RemoteException {
220
		if (serviceDelegate == null) {
221
			System.out.println(" why is serivce Delegate null???"); //$NON-NLS-1$
222
		}
223
		return serviceDelegate.getTask(id);
224
	}
225
226
	public TaskData[] getTasks(int containerId) throws RemoteException {
227
		return serviceDelegate.getTasks(containerId);
228
	}
229
230
	public TimeEntryData[] getTimeEntries(int containerId) throws RemoteException {
231
		return serviceDelegate.getTimeEntries(containerId);
232
	}
233
234
	public TimeEntryData getTimeEntry(int id) throws RemoteException {
235
		return serviceDelegate.getTimeEntry(id);
236
	}
237
238
	public UserStoryData[] getUserStories(int containerId) throws RemoteException {
239
		return serviceDelegate.getUserStories(containerId);
240
	}
241
242
	public UserStoryData getUserStory(int id) throws RemoteException {
243
		return serviceDelegate.getUserStory(id);
244
	}
245
246
	public int hashCode() {
247
		return serviceDelegate.hashCode();
248
	}
249
250
	public void removeIteration(int id) throws RemoteException {
251
		serviceDelegate.removeIteration(id);
252
	}
253
254
	public void removeNote(int id) throws RemoteException {
255
		serviceDelegate.removeNote(id);
256
	}
257
258
	public void removePerson(int id) throws RemoteException {
259
		serviceDelegate.removePerson(id);
260
	}
261
262
	public void removeProject(int id) throws RemoteException {
263
		serviceDelegate.removeProject(id);
264
	}
265
266
	public void removeTask(int id) throws RemoteException {
267
		serviceDelegate.removeTask(id);
268
	}
269
270
	public void removeTimeEntry(int id) throws RemoteException {
271
		serviceDelegate.removeTimeEntry(id);
272
	}
273
274
	public void removeUserStory(int id) throws RemoteException {
275
		serviceDelegate.removeUserStory(id);
276
	}
277
278
	public void setAttribute(int objectId, String key, String value) throws RemoteException {
279
		serviceDelegate.setAttribute(objectId, key, value);
280
	}
281
282
	public void update(IterationData object) throws RemoteException {
283
		serviceDelegate.update(object);
284
	}
285
286
	public void update(NoteData note) throws RemoteException {
287
		serviceDelegate.update(note);
288
	}
289
290
	public void update(PersonData object) throws RemoteException {
291
		serviceDelegate.update(object);
292
	}
293
294
	public void update(ProjectData object) throws RemoteException {
295
		serviceDelegate.update(object);
296
	}
297
298
	public void update(TaskData object) throws RemoteException {
299
		serviceDelegate.update(object);
300
	}
301
302
	public void update(TimeEntryData object) throws RemoteException {
303
		serviceDelegate.update(object);
304
	}
305
306
	public void update(UserStoryData object) throws RemoteException {
307
		serviceDelegate.update(object);
308
	}
309
310
	public TaskData[] getUserStoryTasksForPerson(int personId, int userStoryId) {
311
		if (personId < 0 || userStoryId < 0) {
312
			return new TaskData[0];
313
		}
314
		
315
		List<TaskData> userStoryTasksForPerson = new ArrayList<TaskData>();
316
		try {
317
			TaskData[] iterationTasks = getTasks(userStoryId);
318
			// get all tasks for specified user storyserv
319
			for (int i = 0; i < iterationTasks.length; i++) {
320
				TaskData taskData = iterationTasks[i];
321
				if (taskData.getAcceptorId() == personId) {
322
					userStoryTasksForPerson.add(taskData);
323
				}
324
			}
325
			
326
		}
327
		catch (RemoteException e) {
328
			e.printStackTrace();
329
		}
330
		
331
		return userStoryTasksForPerson.toArray(new TaskData[userStoryTasksForPerson.size()]);
332
	}
333
	
334
	public UserStoryData[] getIterationUserStoriesForTracker(int trackerId, int iterationId) {
335
		if (trackerId < 0 || iterationId < 0) {
336
			return new UserStoryData[0];
337
		}
338
339
		List<UserStoryData> userStoriesForTracker = new ArrayList<UserStoryData>();
340
		UserStoryData[] userStories;
341
		try {
342
			userStories = getUserStories(iterationId);
343
			// get all tasks for specified user story
344
			for (int i = 0; i < userStories.length; i++) {
345
				UserStoryData userStory = userStories[i];
346
				if (userStory.getTrackerId() == trackerId) {
347
					userStoriesForTracker.add(userStory);
348
				}
349
			}
350
		}
351
		catch (RemoteException e) {
352
			e.printStackTrace();
353
		}
354
		
355
		return userStoriesForTracker.toArray(new UserStoryData[userStoriesForTracker.size()]);
356
	}
357
358
	public int getCurrentPersonId() {
359
		int currentPersonId = INVALID_ID;
360
		
361
	  String userName = getCurrentUserName();
362
	  if (userName != null) {
363
	  	try {
364
				PersonData[] people = getPeople();
365
				if (people != null) {
366
					for (int i = 0; i < people.length && currentPersonId == INVALID_ID; i++) {
367
						PersonData person = people[i];
368
						if (person.getUserId().equals(userName)) {
369
							currentPersonId = person.getId();
370
						}
371
					}
372
				}
373
			}
374
			catch (RemoteException e) {
375
				e.printStackTrace();
376
			}
377
	  }
378
	  
379
	  return currentPersonId;
380
	}
381
	
382
	public UserStoryData[] getUserStoriesForProject(int projectId) {
383
		if (projectId == INVALID_ID) {
384
			return new UserStoryData[0];
385
		}
386
		
387
		ArrayList<UserStoryData> projectUserStories = new ArrayList<UserStoryData>();
388
		try {
389
			IterationData[] projectIterations = getIterations(projectId);
390
			for (IterationData iteration : projectIterations) {
391
				UserStoryData[] iterationUserStories = getUserStories(iteration.getId());
392
				if (iterationUserStories.length > 0) {
393
					projectUserStories.addAll(Arrays.asList(iterationUserStories));
394
				}
395
			}
396
		}
397
		catch (RemoteException e) {
398
			e.printStackTrace();
399
		}
400
		
401
		return (UserStoryData[]) projectUserStories.toArray(new UserStoryData[projectUserStories.size()]);
402
	}
403
	
404
	public UserStoryData[] getUserStoriesForProject(int projectId, int trackerId) {
405
		if (projectId == INVALID_ID) {
406
			return new UserStoryData[0];
407
		}
408
		
409
		ArrayList<UserStoryData> projectTrackerUserStories = new ArrayList<UserStoryData>();
410
		UserStoryData[] projectUserStories = getUserStoriesForProject(projectId);
411
		for (UserStoryData userStory : projectUserStories) {
412
			if (userStory.getTrackerId() == trackerId) {
413
				projectTrackerUserStories.add(userStory);
414
			}
415
		}
416
		
417
		return (UserStoryData[]) projectTrackerUserStories.toArray(new UserStoryData[projectTrackerUserStories.size()]);
418
419
	}
420
	
421
	public TaskData[] getTasksForProject(int projectId) {
422
		if (projectId == -1) {
423
			return new TaskData[0];
424
		}
425
		
426
		ArrayList<TaskData> projectTasks = new ArrayList<TaskData>();
427
		try {
428
			UserStoryData[] userStories = getUserStoriesForProject(projectId);
429
			for (UserStoryData userStory : userStories) {
430
				TaskData[] userStoryTasks = getTasks(userStory.getId());
431
				if (userStoryTasks.length > 0) {
432
					projectTasks.addAll(Arrays.asList(userStoryTasks));
433
				}
434
			}
435
		}
436
		catch (RemoteException e) {
437
			e.printStackTrace();
438
		}
439
		
440
		return (TaskData[]) projectTasks.toArray(new TaskData[projectTasks.size()]);
441
	}
442
	
443
	public TaskData[] getTasksForProject(int projectId, int personId) {
444
		if (projectId == INVALID_ID || personId == INVALID_ID) {
445
			return new TaskData[0];
446
		}
447
		
448
		ArrayList<TaskData> projectPersonTasks = new ArrayList<TaskData>();
449
		TaskData[] allProjectTasks = getTasksForProject(projectId);
450
		for (TaskData task : allProjectTasks) {
451
			if (task.getAcceptorId() == personId) {
452
				projectPersonTasks.add(task);
453
			}
454
		}
455
		
456
		return (TaskData[]) projectPersonTasks.toArray(new TaskData[projectPersonTasks.size()]);
457
	}
458
	
459
	public TaskData[] getTasksForIteration(int iterationId) {
460
		if (iterationId == INVALID_ID) {
461
			return new TaskData[0];
462
		}
463
		
464
		ArrayList<TaskData> iterationTasks = new ArrayList<TaskData>();
465
		try {
466
			UserStoryData[] userStories = getUserStories(iterationId);
467
			for (UserStoryData userStory : userStories) {
468
				TaskData[] userStoryTasks = getTasks(userStory.getId());
469
				if (userStoryTasks.length > 0) {
470
					iterationTasks.addAll(Arrays.asList(userStoryTasks));
471
				}
472
			}
473
		}
474
		catch (RemoteException e) {
475
			e.printStackTrace();
476
		}
477
		
478
		return (TaskData[]) iterationTasks.toArray(new TaskData[iterationTasks.size()]);
479
	}
480
	
481
	public TaskData[] getTasksForIteration(int iterationId, int personId) {
482
		if (iterationId == INVALID_ID || personId == INVALID_ID) {
483
			return new TaskData[0];
484
		}
485
		
486
		ArrayList<TaskData> iterationPersonTasks = new ArrayList<TaskData>();
487
		TaskData[] allIterationTasks = getTasksForIteration(iterationId);
488
		for (TaskData task : allIterationTasks) {
489
			if (task.getAcceptorId() == personId) {
490
				iterationPersonTasks.add(task);
491
			}
492
		}
493
		
494
		return (TaskData[]) iterationPersonTasks.toArray(new TaskData[iterationPersonTasks.size()]);
495
	}
496
	
497
498
	public String getHttpPassword() {
499
		return httpPassword;
500
	}
501
502
	public String getHttpUser() {
503
		return httpUser;
504
	}
505
506
	public Proxy getProxy() {
507
		return proxy;
508
	}
509
510
	public boolean useCompression() {
511
		return useCompression;
512
	}
513
514
}
(-)src/org/eclipse/mylyn/xplanner/ui/XPlannerAttributeFactory.java (-9 / +67 lines)
Lines 5-18 Link Here
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
package org.eclipse.mylar.xplanner.ui;
8
package org.eclipse.mylyn.xplanner.ui;
9
9
10
import java.text.DateFormat;
10
import java.text.DateFormat;
11
import java.text.SimpleDateFormat;
11
import java.text.SimpleDateFormat;
12
import java.util.Date;
12
import java.util.*;
13
13
14
import org.eclipse.mylar.tasks.core.AbstractAttributeFactory;
14
import org.eclipse.mylyn.tasks.core.AbstractAttributeFactory;
15
import org.eclipse.mylar.tasks.core.RepositoryTaskAttribute;
15
import org.eclipse.mylyn.tasks.core.RepositoryTaskAttribute;
16
16
17
17
18
/**
18
/**
Lines 37-50 Link Here
37
	public static final String ATTRIBUTE_USER_STORY_NAME = "userStoryName"; //$NON-NLS-1$
37
	public static final String ATTRIBUTE_USER_STORY_NAME = "userStoryName"; //$NON-NLS-1$
38
	public static final String ATTRIBUTE_TASK_COMPLETED = "completed"; //$NON-NLS-1$
38
	public static final String ATTRIBUTE_TASK_COMPLETED = "completed"; //$NON-NLS-1$
39
39
40
	@Override
40
	public static final String ATTRIBUTE_SUBTASK_IDS = "attribute.xplanner.subtask_ids";
41
	public boolean getIsHidden(String key) {
41
	public static final String ATTRIBUTE_SUBTASK_KEYS = "attribute.xplanner.subtask_keys";
42
		return false;
42
	
43
	private static Map<String, Attribute> commonKeyToAttributesMap = new HashMap<String, Attribute>();
44
45
	public enum Attribute {
46
		DESCRIPTION("Description:", RepositoryTaskAttribute.DESCRIPTION, false), //$NON-NLS-1$
47
		OWNER("Acceptor:", RepositoryTaskAttribute.USER_ASSIGNED, true), //$NON-NLS-1$
48
		PRIORITY("Priority:", RepositoryTaskAttribute.PRIORITY, true), //$NON-NLS-1$
49
		STATUS("Status:", RepositoryTaskAttribute.STATUS, true), //$NON-NLS-1$
50
		NAME("Name:", RepositoryTaskAttribute.SUMMARY, false), //$NON-NLS-1$
51
		CREATED_ON("Created:", RepositoryTaskAttribute.DATE_CREATION, true),  //$NON-NLS-1$
52
		MODIFIED_TIME("Last Update:", RepositoryTaskAttribute.DATE_MODIFIED, true),  //$NON-NLS-1$
53
		SUBTASK_IDS("Subtask ids:", XPlannerAttributeFactory.ATTRIBUTE_SUBTASK_IDS, true),
54
		SUBTASK_KEYS("Sub-Tasks:", XPlannerAttributeFactory.ATTRIBUTE_SUBTASK_KEYS, true),
55
56
		; 
57
		
58
		private final boolean isReadOnly;
59
		
60
		private final String displayName;
61
62
		private final String commonAttributeKey;
63
64
		Attribute(String displayName, String commonAttributeKey, boolean readonly) {
65
			this.displayName = displayName;
66
			this.commonAttributeKey = commonAttributeKey;
67
			this.isReadOnly = readonly;
68
			
69
			commonKeyToAttributesMap.put(commonAttributeKey, this);
70
		}
71
72
		public String getCommonAttributeKey() {
73
			return commonAttributeKey;
74
		}
75
76
		public String getDisplayName() {
77
			return displayName;
78
		}
79
80
		public boolean isReadOnly() {
81
			return isReadOnly;
82
		}
83
		
84
		@Override
85
		public String toString() {
86
			return getDisplayName();
87
		}
88
	}
89
90
91
	static {
92
		// make sure hash maps get initialized when class is loaded
93
		Attribute.values();
43
	}
94
	}
44
95
45
	@Override
96
	@Override
46
	public String getName(String key) {
97
	public String getName(String key) {
47
		return key;
98
		Attribute attribute = commonKeyToAttributesMap.get(key);
99
		return (attribute != null) ? attribute.getDisplayName() : key;
48
	}
100
	}
49
101
50
	@Override
102
	@Override
Lines 53-61 Link Here
53
	}
105
	}
54
106
55
	@Override
107
	@Override
56
	public boolean isReadOnly(String key) {				
108
	public boolean isHidden(String key) {
57
		return false;
109
		return false;
58
	}
110
	}
111
112
	@Override
113
	public boolean isReadOnly(String key) {				
114
		Attribute attribute = commonKeyToAttributesMap.get(key);
115
		return (attribute != null) ? attribute.isReadOnly() : false;
116
	}
59
	
117
	
60
	public Date getDateForAttributeType(String attributeKey, String dateString) {
118
	public Date getDateForAttributeType(String attributeKey, String dateString) {
61
		if(dateString == null || dateString.equals("")) { //$NON-NLS-1$
119
		if(dateString == null || dateString.equals("")) { //$NON-NLS-1$
(-)src/org/eclipse/mylyn/xplanner/ui/XPlannerServerFacade.java (-187 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 - 2007 CodeGear 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
package org.eclipse.mylar.xplanner.ui;
9
10
import java.net.MalformedURLException;
11
import java.net.URL;
12
13
import org.eclipse.core.runtime.CoreException;
14
import org.eclipse.mylar.core.MylarStatusHandler;
15
import org.eclipse.mylar.tasks.core.ITaskRepositoryListener;
16
import org.eclipse.mylar.tasks.core.TaskRepository;
17
import org.eclipse.mylar.tasks.ui.TasksUiPlugin;
18
import org.eclipse.mylar.xplanner.core.ServerManager;
19
import org.eclipse.mylar.xplanner.core.XPlannerCorePlugin;
20
import org.eclipse.mylar.xplanner.core.service.XPlannerServer;
21
import org.eclipse.mylar.xplanner.core.service.exceptions.AuthenticationException;
22
import org.eclipse.mylar.xplanner.core.service.exceptions.ServiceUnavailableException;
23
24
/**
25
 * This class acts as a layer of indirection between clients in this project and
26
 * the server API implemented by the XPlanner Dashboard, and also abstracts some
27
 * Mylar implementation details. It initializes a xPlannerServer object and serves
28
 * as the central location to get a reference to it.
29
 * 
30
 * @author Ravi Kumar 
31
 * @author Helen Bershadskaya 
32
 * 
33
 */
34
public class XPlannerServerFacade implements ITaskRepositoryListener {
35
36
	private ServerManager serverManager = null;
37
38
	private static XPlannerServerFacade instance = null;
39
40
	public XPlannerServerFacade() {
41
		TasksUiPlugin.getRepositoryManager().addListener(this);
42
		serverManager = XPlannerCorePlugin.getDefault().getServerManager();
43
	}
44
45
	/**
46
	 * Lazily creates server.
47
	 */
48
	public XPlannerServer getXPlannerServer(TaskRepository repository) throws CoreException {
49
		try {
50
			XPlannerRepositoryUtils.checkRepositoryValidated(repository.getUrl());
51
			String serverHostname = getServerHost(repository);
52
		XPlannerServer server = serverManager.getServer(serverHostname);
53
//TODO: add this check back once the listeners for server property change are hooked up
54
// Also handle the case when serviceDelegate in the cachedServer is null
55
56
//			if (server == null) {
57
				server = serverManager.createServer(serverHostname, repository.getUrl(), false,
58
						repository.getUserName(), repository.getPassword());
59
				serverManager.addServer(server);
60
//			}
61
			if (server == null) {
62
				throw new ServiceUnavailableException(serverHostname + " " + repository.getUrl()); //$NON-NLS-1$
63
			}
64
			return server;
65
		} 
66
		catch (CoreException ce) {
67
			MylarStatusHandler.log(Messages.XPlannerServerFacade_SERVER_CONNECTION_ERROR, this);
68
			throw ce;
69
		}
70
		catch (ServiceUnavailableException sue) {
71
			throw sue;
72
		} 
73
		catch (RuntimeException e) {
74
			MylarStatusHandler.log(Messages.XPlannerServerFacade_SERVER_CONNECTION_ERROR, this);
75
			throw e;
76
		}
77
	}
78
79
	public static XPlannerServerFacade getDefault() {
80
		if (instance == null) {
81
			instance = new XPlannerServerFacade();
82
		}
83
		return instance;
84
	}
85
86
	public void logOutFromAll() {
87
		try {
88
			XPlannerServer[] allServers = serverManager.getAllServers();
89
			for (int i = 0; i < allServers.length; i++) {
90
				allServers[i].logout();
91
			}
92
		} catch (Exception e) {
93
			// ignore
94
		}
95
	}
96
97
	public void repositoriesRead() {
98
		// ignore
99
	}
100
101
	public void repositoryAdded(TaskRepository repository) {
102
		if (repository.getKind().equals(XPlannerMylarUIPlugin.REPOSITORY_KIND)) {
103
			try {
104
				getXPlannerServer(repository);
105
			}
106
			catch (CoreException e) {
107
				MylarStatusHandler.log(e.getMessage(), this); 
108
			}
109
		}
110
	}
111
112
	public void repositoryRemoved(TaskRepository repository) {
113
		if (repository.getKind().equals(XPlannerMylarUIPlugin.REPOSITORY_KIND)) {
114
			String serverHostname = getServerHost(repository);
115
			XPlannerServer server = serverManager.getServer(serverHostname);
116
			removeServer(server);
117
			XPlannerRepositoryUtils.removeValidatedRepositoryUrl(repository.getUrl());
118
		}
119
	}
120
	
121
	public void repositorySettingsChanged(TaskRepository repository) {
122
		repositoryRemoved(repository);
123
		repositoryAdded(repository);
124
	}
125
126
	public void refreshServerSettings(TaskRepository repository) {
127
		String serverHostname = getServerHost(repository);
128
		XPlannerServer server = serverManager.getServer(serverHostname);
129
		if (server != null) {
130
			server.refreshDetails();
131
		}
132
	}
133
	
134
	
135
	private void removeServer(XPlannerServer server) {
136
		if (server != null) {
137
			server.logout();
138
			serverManager.removeServer(server);
139
		}
140
	} 
141
142
	/**
143
	 * Validate the server URL and user credentials
144
	 * @param serverUrl Location of the XPlanner Server
145
	 * @param user Username
146
	 * @param password Password
147
	 * @return String describing validation failure or null if the details are valid
148
	 */
149
	public void validateServerAndCredentials(String serverUrl, String user, 
150
		String password) throws Exception {
151
		
152
		XPlannerRepositoryUtils.removeValidatedRepositoryUrl(serverUrl);
153
		serverManager.testConnection(serverUrl, user, password);
154
		XPlannerRepositoryUtils.addValidatedRepositoryUrl(serverUrl);
155
	}
156
157
	private static String getServerHost(TaskRepository repository) {
158
		try {
159
			return new URL(repository.getUrl()).getHost();
160
		} catch (MalformedURLException ex) {
161
			throw new RuntimeException(Messages.XPlannerServerFacade_INVALID_URL_EXCEPTION+repository.getUrl(), ex);
162
		}
163
	}
164
	
165
	/**
166
	 * TODO: refactor
167
	 */
168
	public static void handleConnectionException(Exception e) {
169
		if (e instanceof ServiceUnavailableException) {
170
			MylarStatusHandler.fail(e, Messages.XPlannerServerFacade_CONNECTION_FAILURE_ERROR
171
					+ Messages.XPlannerServerFacade_NETWORK_CONNECTION_FAILURE,
172
					true);
173
		} 
174
		else if (e instanceof AuthenticationException) {
175
			MylarStatusHandler.fail(e, Messages.XPlannerServerFacade_AUTHENTICATION_FAILED
176
					+ Messages.XPlannerServerFacade_USERNAME_PASSWORD_ERROR, true);
177
		} 
178
		else if (e instanceof RuntimeException) {
179
			MylarStatusHandler.fail(e, Messages.XPlannerServerFacade_NO_REPOSITORY_FOUND
180
					+ Messages.XPlannerServerFacade_VERIFY_VALID_REPOSITORY, true);
181
		} 
182
		else {
183
			MylarStatusHandler.fail(e, Messages.XPlannerServerFacade_COULD_NOT_CONNECT_TO_REPOSITORY
184
					+ Messages.XPlannerServerFacade_CHECK_CREDENTIALS, true);
185
		}
186
	}	
187
}
(-)src/org/eclipse/mylyn/xplanner/ui/XPlannerTaskExternalizer.java (-285 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 - 2007 CodeGear 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
package org.eclipse.mylar.xplanner.ui;
9
10
import java.util.ArrayList;
11
import java.util.Iterator;
12
import java.util.List;
13
import java.util.StringTokenizer;
14
15
import org.eclipse.mylar.core.MylarStatusHandler;
16
import org.eclipse.mylar.internal.tasks.core.RepositoryTaskHandleUtil;
17
import org.eclipse.mylar.tasks.core.AbstractQueryHit;
18
import org.eclipse.mylar.tasks.core.AbstractRepositoryQuery;
19
import org.eclipse.mylar.tasks.core.AbstractTaskContainer;
20
import org.eclipse.mylar.tasks.core.DelegatingTaskExternalizer;
21
import org.eclipse.mylar.tasks.core.ITask;
22
import org.eclipse.mylar.tasks.core.ITaskListExternalizer;
23
import org.eclipse.mylar.tasks.core.TaskExternalizationException;
24
import org.eclipse.mylar.tasks.core.TaskList;
25
import org.eclipse.mylar.tasks.ui.TasksUiPlugin;
26
import org.w3c.dom.Document;
27
import org.w3c.dom.Element;
28
import org.w3c.dom.Node;
29
30
/**
31
 * @author Ravi Kumar 
32
 * @author Helen Bershadskaya 
33
 */
34
public class XPlannerTaskExternalizer extends DelegatingTaskExternalizer {
35
36
	private static final String TOKEN_SEPARATOR = ";"; //$NON-NLS-1$
37
38
	private static final String KEY_XPLANNER = "XPlanner"; //$NON-NLS-1$
39
40
	private static final String KEY_CUSTOM = "XPlannerCustom"; //$NON-NLS-1$
41
42
	private static final String KEY_XPLANNER_CATEGORY = "XPlannerQuery" + KEY_CATEGORY; //$NON-NLS-1$
43
44
	private static final String KEY_XPLANNER_QUERY_HIT = KEY_XPLANNER + KEY_QUERY_HIT;
45
46
	private static final String KEY_XPLANNER_QUERY = KEY_XPLANNER + KEY_QUERY;
47
48
	private static final String KEY_XPLANNER_CUSTOM = KEY_XPLANNER + KEY_CUSTOM + KEY_QUERY;
49
50
	private static final String KEY_XPLANNER_ITEM = "XPlannerItem"; //$NON-NLS-1$
51
52
	private static final String KEY_QUERY_NAME = "QueryName"; //$NON-NLS-1$
53
54
	private static final String KEY_QUERY_CONTENT_ID_TYPE = "QueryContentIdType"; //$NON-NLS-1$
55
56
	private static final String KEY_QUERY_IS_TASKS = "QueryIsTasks"; //$NON-NLS-1$
57
58
	private static final String KEY_QUERY_CONTENT_ID = "QueryConentId"; //$NON-NLS-1$
59
60
	private static final String KEY_QUERY_PERSON_ID = "QueryPersonId"; //$NON-NLS-1$
61
62
	private static final String KEY_QUERY_MY_CURRENT_TASKS = "QueryMyCurrentTasks"; //$NON-NLS-1$
63
64
	private static final String KEY_KEY = "Key"; //$NON-NLS-1$
65
	
66
	public boolean canReadQuery(Node node) {
67
		return node.getNodeName().equals(KEY_XPLANNER_QUERY) || node.getNodeName().equals(KEY_XPLANNER_CUSTOM);
68
	}
69
70
	public boolean canCreateElementFor(AbstractRepositoryQuery category) {
71
		return category instanceof XPlannerCustomQuery;
72
	}
73
74
	public boolean canCreateElementFor(ITask task) {
75
		return task instanceof XPlannerTask;
76
	}
77
78
	public AbstractRepositoryQuery readQuery(Node node, TaskList taskList) throws TaskExternalizationException {
79
		Element element = (Element) node;
80
81
		AbstractRepositoryQuery query = null;
82
		String custom = element.getAttribute(KEY_QUERY_NAME);
83
		if (custom != null && custom.length() > 0) {
84
			query = new XPlannerCustomQuery(element.getAttribute(KEY_REPOSITORY_URL), custom, TasksUiPlugin
85
					.getTaskListManager().getTaskList());
86
			initializeQuery((XPlannerCustomQuery)query, element);
87
		}
88
89
		return query;
90
	}
91
92
	public Element createTaskElement(ITask task, Document doc, Element parent) {
93
		Element node = super.createTaskElement(task, doc, parent);
94
		node.setAttribute(KEY_KEY, ((XPlannerTask) task).getKey());
95
		return node;
96
	}
97
98
	private void initializeQuery(XPlannerCustomQuery query, Element element) {
99
		String myCurrentTasks = element.getAttribute(KEY_QUERY_MY_CURRENT_TASKS);
100
		if (myCurrentTasks != null && Boolean.valueOf(myCurrentTasks)) {
101
			query.setMyCurrentTasks(true);
102
		}
103
		else {
104
			// selected content type
105
			String contentIdType = element.getAttribute(KEY_QUERY_CONTENT_ID_TYPE);
106
			if (contentIdType != null) {
107
				query.setContentIdType((XPlannerCustomQuery.ContentIdType.valueOf(contentIdType)));
108
			}
109
110
			// use tasks?
111
			String useTasks = element.getAttribute(KEY_QUERY_IS_TASKS);
112
			if (useTasks != null) {
113
			  query.setUseTasks(Boolean.valueOf(useTasks));
114
			}  
115
			
116
			// use all?
117
			String personId = element.getAttribute(KEY_QUERY_PERSON_ID);
118
			if (personId != null) {
119
			  query.setPersonId(Integer.valueOf(personId));
120
			}  
121
			
122
			// content id
123
			String contentIds = element.getAttribute(KEY_QUERY_CONTENT_ID);
124
			if (contentIds != null) {
125
				query.setContentIds(decodeIds(contentIds));
126
			}
127
		}	
128
	}
129
	
130
	private String encodeIds(List<Integer> contentIds) {
131
		StringBuilder result = new StringBuilder();
132
		for (Iterator<Integer> iter = contentIds.iterator(); iter.hasNext();) {
133
			Integer id = iter.next();
134
			result.append(id);
135
			if (iter.hasNext()) {
136
				result.append(TOKEN_SEPARATOR);
137
			}
138
		}
139
140
		return result.toString();
141
	}
142
143
	private List<Integer> decodeIds(String encoded) {
144
		if (encoded == null) {
145
			return XPlannerCustomQuery.INVALID_IDS;
146
		}
147
		
148
		StringTokenizer tokens = new StringTokenizer(encoded, TOKEN_SEPARATOR);
149
		ArrayList<Integer> ids = new ArrayList<Integer>();
150
		while (tokens.hasMoreTokens()) {
151
			ids.add(Integer.valueOf(tokens.nextToken()));
152
		}
153
		
154
		return ids;
155
	}
156
157
	
158
	public Element createQueryElement(AbstractRepositoryQuery query, Document doc, Element parent) {
159
		String queryTagName = getQueryTagNameForElement(query);
160
		Element node = doc.createElement(queryTagName);
161
162
		node.setAttribute(KEY_NAME, query.getSummary());
163
		node.setAttribute(KEY_QUERY_STRING, query.getUrl());
164
		node.setAttribute(KEY_REPOSITORY_URL, query.getRepositoryUrl());
165
166
		XPlannerCustomQuery xplannerCustomQuery = (XPlannerCustomQuery) query;
167
		
168
		// name
169
		String queryName = xplannerCustomQuery.getQueryName();
170
		node.setAttribute(KEY_QUERY_NAME, queryName);
171
		
172
		boolean isMyCurrentTasks = xplannerCustomQuery.isMyCurrentTasks();
173
		if (isMyCurrentTasks) {
174
			// show only my current tasks
175
			node.setAttribute(KEY_QUERY_MY_CURRENT_TASKS, Boolean.toString(true));
176
		}
177
		else {
178
			// don't show only my current tasks
179
			node.setAttribute(KEY_QUERY_MY_CURRENT_TASKS, Boolean.toString(false));
180
			
181
			// selected content type
182
			String contentIdType = xplannerCustomQuery.getContentIdType().name();
183
			node.setAttribute(KEY_QUERY_CONTENT_ID_TYPE, contentIdType);
184
185
			// is tasks
186
			boolean isUseTasks = xplannerCustomQuery.isUseTasks();
187
			node.setAttribute(KEY_QUERY_IS_TASKS, Boolean.toString(isUseTasks));
188
			
189
			// content id
190
			List<Integer> contentIds = xplannerCustomQuery.getContentIds();
191
			node.setAttribute(KEY_QUERY_CONTENT_ID, encodeIds(contentIds));
192
			
193
			// person id
194
			int personId = xplannerCustomQuery.getPersonId();
195
			node.setAttribute(KEY_QUERY_PERSON_ID, Integer.toString(personId));
196
		}
197
		
198
		for (AbstractQueryHit hit : query.getHits()) {
199
				try {
200
					Element element = null;
201
					for (ITaskListExternalizer externalizer : super.getDelegateExternalizers()) {
202
						if (externalizer.canCreateElementFor(hit)) {
203
							element = externalizer.createQueryHitElement(hit, doc, node);
204
						}
205
					}
206
					if (element == null) {
207
						createQueryHitElement(hit, doc, node);
208
					}	
209
				} 
210
				catch (Exception e) {
211
					MylarStatusHandler.log(e, e.getMessage());
212
				}
213
		}
214
		parent.appendChild(node);
215
		return node;
216
	}
217
218
	@Override
219
	public String getTaskTagName() {
220
		return KEY_XPLANNER_ITEM;
221
	}
222
223
	@Override
224
	public ITask createTask(String repositoryUrl, String taskId, String summary, Element element, TaskList taskList, AbstractTaskContainer category, ITask parent)
225
			throws TaskExternalizationException {
226
227
		String key;
228
		XPlannerTask task = new XPlannerTask(repositoryUrl, taskId, summary, false);
229
		if (element.hasAttribute(KEY_KEY)) {
230
			key = element.getAttribute(KEY_KEY);
231
			task.setKey(key);
232
		} 
233
		else {
234
			// ignore if key not found
235
		}
236
		return task;
237
	}
238
239
	public boolean canReadQueryHit(Node node) {
240
		return node.getNodeName().equals(getQueryHitTagName());
241
	}
242
243
	@Override
244
	public AbstractQueryHit createQueryHit(String repositoryUrl, String taskId, String summary, Element element, TaskList taskList, AbstractRepositoryQuery query)
245
		throws TaskExternalizationException {
246
247
		String handle;
248
		if (element.hasAttribute(KEY_HANDLE)) {
249
			handle = element.getAttribute(KEY_HANDLE);
250
		} 
251
		else {
252
			throw new TaskExternalizationException(Messages.XPlannerTaskExternalizer_HANDLE_NOT_STORED_EXCEPTION);
253
		}
254
255
		XPlannerQueryHit hit = null;		
256
		ITask correspondingTask = taskList.getTask(handle);
257
		if (correspondingTask instanceof XPlannerTask) {
258
			String id = RepositoryTaskHandleUtil.getTaskId(handle);
259
			hit = new XPlannerQueryHit(taskList, 
260
				correspondingTask.getSummary(), correspondingTask.getPriority(),
261
				query.getRepositoryUrl(), id, (XPlannerTask)correspondingTask);
262
			hit.setHandleIdentifier(handle);
263
		}
264
		
265
		return hit;
266
	}
267
268
	public String getQueryTagNameForElement(AbstractRepositoryQuery query) {
269
		if (query instanceof XPlannerCustomQuery) {
270
			return KEY_XPLANNER_CUSTOM;
271
		}
272
		return ""; //$NON-NLS-1$
273
	}
274
275
	@Override
276
	public String getCategoryTagName() {
277
		return KEY_XPLANNER_CATEGORY;
278
	}
279
280
	@Override
281
	public String getQueryHitTagName() {
282
		return KEY_XPLANNER_QUERY_HIT;
283
	}
284
285
}
(-)src/org/eclipse/mylyn/xplanner/ui/XPlannerRepositoryUtils.java (-57 / +92 lines)
Lines 5-14 Link Here
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
package org.eclipse.mylar.xplanner.ui;
8
package org.eclipse.mylyn.xplanner.ui;
9
9
10
import java.io.IOException;
10
import java.io.IOException;
11
import java.net.MalformedURLException;
11
import java.net.MalformedURLException;
12
import java.net.Proxy;
12
import java.rmi.RemoteException;
13
import java.rmi.RemoteException;
13
import java.security.GeneralSecurityException;
14
import java.security.GeneralSecurityException;
14
import java.text.MessageFormat;
15
import java.text.MessageFormat;
Lines 18-38 Link Here
18
19
19
import javax.security.auth.login.LoginException;
20
import javax.security.auth.login.LoginException;
20
21
21
import org.eclipse.core.runtime.CoreException;
22
import org.eclipse.core.runtime.*;
22
import org.eclipse.core.runtime.IStatus;
23
import org.eclipse.mylyn.internal.tasks.core.RepositoryTaskHandleUtil;
23
import org.eclipse.core.runtime.Status;
24
import org.eclipse.mylyn.tasks.core.*;
24
import org.eclipse.mylar.internal.tasks.core.RepositoryTaskHandleUtil;
25
import org.eclipse.mylyn.tasks.ui.TasksUiPlugin;
25
import org.eclipse.mylar.tasks.core.RepositoryTaskAttribute;
26
import org.eclipse.mylyn.xplanner.core.XPlannerCorePlugin;
26
import org.eclipse.mylar.tasks.core.RepositoryTaskData;
27
import org.eclipse.mylyn.xplanner.core.service.XPlannerClient;
27
import org.eclipse.mylar.tasks.core.TaskRepository;
28
import org.xplanner.soap.*;
28
import org.eclipse.mylar.tasks.ui.TasksUiPlugin;
29
import org.eclipse.mylar.xplanner.core.XPlannerCorePlugin;
30
import org.eclipse.mylar.xplanner.core.service.XPlannerServer;
31
import org.xplanner.soap.IterationData;
32
import org.xplanner.soap.PersonData;
33
import org.xplanner.soap.ProjectData;
34
import org.xplanner.soap.TaskData;
35
import org.xplanner.soap.UserStoryData;
36
29
37
/**
30
/**
38
 * @author Ravi Kumar
31
 * @author Ravi Kumar
Lines 43-67 Link Here
43
		
36
		
44
	}
37
	}
45
	
38
	
46
	public static RepositoryTaskData createRepositoryTaskData(TaskRepository repository, XPlannerTask xplannerTask, XPlannerServer server) throws CoreException {
39
	public static RepositoryTaskData createRepositoryTaskData(TaskRepository repository, XPlannerTask xplannerTask, XPlannerClient client) throws CoreException {
47
		RepositoryTaskData repositoryTaskData = null;
40
		RepositoryTaskData repositoryTaskData = null;
48
		
41
		
49
		try {
42
		try {
50
			if (XPlannerTask.Kind.TASK.toString().equals(xplannerTask.getTaskKind())) {
43
			if (XPlannerTask.Kind.TASK.toString().equals(xplannerTask.getTaskKind())) {
51
				TaskData taskData = server.getTask(Integer.valueOf(xplannerTask.getKey()).intValue());
44
				TaskData taskData = client.getTask(Integer.valueOf(xplannerTask.getTaskId()).intValue());
52
				repositoryTaskData = XPlannerRepositoryUtils.getXPlannerRepositoryTaskData(
45
				repositoryTaskData = XPlannerRepositoryUtils.getXPlannerRepositoryTaskData(
53
						repository.getUrl(), taskData, RepositoryTaskHandleUtil.getTaskId(xplannerTask.getHandleIdentifier()));
46
						repository.getUrl(), taskData, RepositoryTaskHandleUtil.getTaskId(xplannerTask.getHandleIdentifier()));
54
				xplannerTask.setCompleted(taskData.isCompleted());
47
				xplannerTask.setCompleted(taskData.isCompleted());
55
			}
48
			}
56
			else if (XPlannerTask.Kind.USER_STORY.toString().equals(xplannerTask.getTaskKind())) {
49
			else if (XPlannerTask.Kind.USER_STORY.toString().equals(xplannerTask.getTaskKind())) {
57
				UserStoryData userStory = server.getUserStory(Integer.valueOf(xplannerTask.getKey()).intValue());
50
				UserStoryData userStory = client.getUserStory(Integer.valueOf(xplannerTask.getTaskId()).intValue());
58
				repositoryTaskData = XPlannerRepositoryUtils.getXPlannerRepositoryTaskData(
51
				repositoryTaskData = XPlannerRepositoryUtils.getXPlannerRepositoryTaskData(
59
						repository.getUrl(), userStory, RepositoryTaskHandleUtil.getTaskId(xplannerTask.getHandleIdentifier()));
52
						repository.getUrl(), userStory, RepositoryTaskHandleUtil.getTaskId(xplannerTask.getHandleIdentifier()));
60
				xplannerTask.setCompleted(userStory.isCompleted());
53
				xplannerTask.setCompleted(userStory.isCompleted());
61
			}
54
			}
62
		} 
55
		} 
63
		catch (final Exception e) {
56
		catch (final Exception e) {
64
			throw new CoreException(new Status(IStatus.ERROR, XPlannerMylarUIPlugin.PLUGIN_ID, 0, 
57
			throw new CoreException(new Status(IStatus.ERROR, XPlannerMylynUIPlugin.PLUGIN_ID, 0, 
65
				MessageFormat.format(Messages.XPlannerRepositoryUtils_TASK_DOWNLOAD_FAILED,
58
				MessageFormat.format(Messages.XPlannerRepositoryUtils_TASK_DOWNLOAD_FAILED,
66
					  xplannerTask.getRepositoryUrl(), TasksUiPlugin.LABEL_VIEW_REPOSITORIES), e));
59
					  xplannerTask.getRepositoryUrl(), TasksUiPlugin.LABEL_VIEW_REPOSITORIES), e));
67
		}
60
		}
Lines 69-80 Link Here
69
		return repositoryTaskData;
62
		return repositoryTaskData;
70
	}
63
	}
71
64
65
	public static RepositoryTaskData createRepositoryTaskData(TaskRepository repository, 
66
			String taskId) throws CoreException {
67
		
68
		RepositoryTaskData repositoryTaskData = null;
69
		
70
		XPlannerClient client = XPlannerClientFacade.getDefault().getXPlannerClient(repository);
71
		
72
		try {
73
			TaskData taskData = client.getTask(Integer.valueOf(taskId).intValue());
74
			if (taskData != null) {
75
				repositoryTaskData = XPlannerRepositoryUtils.getXPlannerRepositoryTaskData(
76
						repository.getUrl(), taskData, taskId);
77
			}
78
			else {
79
				UserStoryData userStory = client.getUserStory(Integer.valueOf(taskId).intValue());
80
				if (userStory != null) {
81
					repositoryTaskData = XPlannerRepositoryUtils.getXPlannerRepositoryTaskData(
82
							repository.getUrl(), userStory, taskId);
83
				}
84
			}
85
		} 
86
		catch (final Exception e) {
87
			throw new CoreException(new Status(IStatus.ERROR, XPlannerMylynUIPlugin.PLUGIN_ID, 0, 
88
				MessageFormat.format(Messages.XPlannerRepositoryUtils_TASK_DOWNLOAD_FAILED,
89
					  repository.getUrl(), TasksUiPlugin.LABEL_VIEW_REPOSITORIES), e));
90
		}
91
		
92
		return repositoryTaskData;
93
	}
94
72
	public static RepositoryTaskData getXPlannerRepositoryTaskData(String repositoryUrl, TaskData taskData, String id) 
95
	public static RepositoryTaskData getXPlannerRepositoryTaskData(String repositoryUrl, TaskData taskData, String id) 
73
		throws IOException, MalformedURLException, LoginException, GeneralSecurityException, CoreException {
96
		throws IOException, MalformedURLException, LoginException, GeneralSecurityException, CoreException {
74
97
75
		RepositoryTaskData repositoryTaskData = new RepositoryTaskData(
98
		RepositoryTaskData repositoryTaskData = new RepositoryTaskData(
76
				new XPlannerAttributeFactory(),
99
				new XPlannerAttributeFactory(),
77
				XPlannerMylarUIPlugin.REPOSITORY_KIND, repositoryUrl, id, XPlannerTask.Kind.TASK.toString());
100
				XPlannerMylynUIPlugin.REPOSITORY_KIND, repositoryUrl, id, XPlannerTask.Kind.TASK.toString());
78
		
101
		
79
		setupTaskAttributes(taskData, repositoryTaskData);
102
		setupTaskAttributes(taskData, repositoryTaskData);
80
103
Lines 85-91 Link Here
85
		throws IOException, MalformedURLException, LoginException, GeneralSecurityException, CoreException {
108
		throws IOException, MalformedURLException, LoginException, GeneralSecurityException, CoreException {
86
109
87
		RepositoryTaskData repositoryTaskData = new RepositoryTaskData(new XPlannerAttributeFactory(),
110
		RepositoryTaskData repositoryTaskData = new RepositoryTaskData(new XPlannerAttributeFactory(),
88
				XPlannerMylarUIPlugin.REPOSITORY_KIND, repositoryUrl, id, XPlannerTask.Kind.USER_STORY.toString());
111
				XPlannerMylynUIPlugin.REPOSITORY_KIND, repositoryUrl, id, XPlannerTask.Kind.USER_STORY.toString());
89
		setupUserStoryAttributes(userStory, repositoryTaskData);
112
		setupUserStoryAttributes(userStory, repositoryTaskData);
90
	
113
	
91
		return repositoryTaskData;
114
		return repositoryTaskData;
Lines 95-109 Link Here
95
		throws CoreException {
118
		throws CoreException {
96
		
119
		
97
		TaskRepository repository = TasksUiPlugin.getRepositoryManager().getRepository(
120
		TaskRepository repository = TasksUiPlugin.getRepositoryManager().getRepository(
98
				XPlannerMylarUIPlugin.REPOSITORY_KIND, repositoryTaskData.getRepositoryUrl());
121
				XPlannerMylynUIPlugin.REPOSITORY_KIND, repositoryTaskData.getRepositoryUrl());
99
		XPlannerServer server = XPlannerServerFacade.getDefault().getXPlannerServer(repository);
122
		XPlannerClient client = XPlannerClientFacade.getDefault().getXPlannerClient(repository);
100
123
101
		// description
124
		// description
102
		repositoryTaskData.setAttributeValue(RepositoryTaskAttribute.DESCRIPTION, taskData.getDescription());
125
		repositoryTaskData.setAttributeValue(RepositoryTaskAttribute.DESCRIPTION, taskData.getDescription());
103
		
126
		
104
		// priority
127
		// priority
105
		repositoryTaskData.setAttributeValue(RepositoryTaskAttribute.PRIORITY, 
128
		repositoryTaskData.setAttributeValue(RepositoryTaskAttribute.PRIORITY, 
106
			getPriorityFromXPlannerObject(taskData, server));
129
			getPriorityFromXPlannerObject(taskData, client));
107
		
130
		
108
		// status
131
		// status
109
		repositoryTaskData.setAttributeValue(RepositoryTaskAttribute.STATUS, taskData.getDispositionName());
132
		repositoryTaskData.setAttributeValue(RepositoryTaskAttribute.STATUS, taskData.getDispositionName());
Lines 113-119 Link Here
113
136
114
		// assigned to 
137
		// assigned to 
115
		repositoryTaskData.setAttributeValue(RepositoryTaskAttribute.USER_ASSIGNED, getPersonName(
138
		repositoryTaskData.setAttributeValue(RepositoryTaskAttribute.USER_ASSIGNED, getPersonName(
116
			taskData.getAcceptorId(), server));
139
			taskData.getAcceptorId(), client));
117
		
140
		
118
		// createdDate 
141
		// createdDate 
119
		Date createdDate = taskData.getCreatedDate().getTime();
142
		Date createdDate = taskData.getCreatedDate().getTime();
Lines 143-156 Link Here
143
		repositoryTaskData.setAttributeValue(XPlannerAttributeFactory.ATTRIBUTE_ADJUSTED_ESTIMATED_HOURS_NAME, "" + taskData.getAdjustedEstimatedHours()); //$NON-NLS-1$
166
		repositoryTaskData.setAttributeValue(XPlannerAttributeFactory.ATTRIBUTE_ADJUSTED_ESTIMATED_HOURS_NAME, "" + taskData.getAdjustedEstimatedHours()); //$NON-NLS-1$
144
167
145
		// project name
168
		// project name
146
		repositoryTaskData.setAttributeValue(XPlannerAttributeFactory.ATTRIBUTE_PROJECT_NAME, getProjectName(taskData, server));
169
		repositoryTaskData.setAttributeValue(XPlannerAttributeFactory.ATTRIBUTE_PROJECT_NAME, getProjectName(taskData, client));
147
170
148
		// iteration name
171
		// iteration name
149
		repositoryTaskData.setAttributeValue(XPlannerAttributeFactory.ATTRIBUTE_ITERATION_NAME, getIterationName(taskData, server));
172
		repositoryTaskData.setAttributeValue(XPlannerAttributeFactory.ATTRIBUTE_ITERATION_NAME, getIterationName(taskData, client));
150
173
151
		// user story name
174
		// user story name
152
		repositoryTaskData.setAttributeValue(XPlannerAttributeFactory.ATTRIBUTE_USER_STORY_NAME, 
175
		repositoryTaskData.setAttributeValue(XPlannerAttributeFactory.ATTRIBUTE_USER_STORY_NAME, 
153
				getUserStoryName(taskData, server));
176
				getUserStoryName(taskData, client));
154
177
155
		// completed
178
		// completed
156
		repositoryTaskData.setAttributeValue(XPlannerAttributeFactory.ATTRIBUTE_TASK_COMPLETED, 
179
		repositoryTaskData.setAttributeValue(XPlannerAttributeFactory.ATTRIBUTE_TASK_COMPLETED, 
Lines 161-175 Link Here
161
		throws CoreException {
184
		throws CoreException {
162
		
185
		
163
		TaskRepository repository = TasksUiPlugin.getRepositoryManager().getRepository(
186
		TaskRepository repository = TasksUiPlugin.getRepositoryManager().getRepository(
164
				XPlannerMylarUIPlugin.REPOSITORY_KIND, repositoryTaskData.getRepositoryUrl());
187
				XPlannerMylynUIPlugin.REPOSITORY_KIND, repositoryTaskData.getRepositoryUrl());
165
		XPlannerServer server = XPlannerServerFacade.getDefault().getXPlannerServer(repository);
188
		XPlannerClient client = XPlannerClientFacade.getDefault().getXPlannerClient(repository);
166
189
167
		// description
190
		// description
168
		repositoryTaskData.setAttributeValue(RepositoryTaskAttribute.DESCRIPTION, userStory.getDescription());
191
		repositoryTaskData.setAttributeValue(RepositoryTaskAttribute.DESCRIPTION, userStory.getDescription());
169
		
192
		
170
		// priority
193
		// priority
171
		repositoryTaskData.setAttributeValue(RepositoryTaskAttribute.PRIORITY, 
194
		repositoryTaskData.setAttributeValue(RepositoryTaskAttribute.PRIORITY, 
172
			getPriorityFromXPlannerObject(userStory, server));
195
			getPriorityFromXPlannerObject(userStory, client));
173
		
196
		
174
		// summary
197
		// summary
175
		repositoryTaskData.setAttributeValue(RepositoryTaskAttribute.SUMMARY, userStory.getName());
198
		repositoryTaskData.setAttributeValue(RepositoryTaskAttribute.SUMMARY, userStory.getName());
Lines 179-185 Link Here
179
		
202
		
180
		// assigned to 
203
		// assigned to 
181
		repositoryTaskData.setAttributeValue(RepositoryTaskAttribute.USER_ASSIGNED, getPersonName(
204
		repositoryTaskData.setAttributeValue(RepositoryTaskAttribute.USER_ASSIGNED, getPersonName(
182
				userStory.getTrackerId(), server));
205
				userStory.getTrackerId(), client));
183
		
206
		
184
		// createdDate -- user story doesn't have created date
207
		// createdDate -- user story doesn't have created date
185
		
208
		
Lines 206-215 Link Here
206
		repositoryTaskData.setAttributeValue(XPlannerAttributeFactory.ATTRIBUTE_ADJUSTED_ESTIMATED_HOURS_NAME, "" + userStory.getAdjustedEstimatedHours()); //$NON-NLS-1$
229
		repositoryTaskData.setAttributeValue(XPlannerAttributeFactory.ATTRIBUTE_ADJUSTED_ESTIMATED_HOURS_NAME, "" + userStory.getAdjustedEstimatedHours()); //$NON-NLS-1$
207
230
208
		// project name
231
		// project name
209
		repositoryTaskData.setAttributeValue(XPlannerAttributeFactory.ATTRIBUTE_PROJECT_NAME, getProjectName(userStory, server));
232
		repositoryTaskData.setAttributeValue(XPlannerAttributeFactory.ATTRIBUTE_PROJECT_NAME, getProjectName(userStory, client));
210
233
211
		// iteration name
234
		// iteration name
212
		repositoryTaskData.setAttributeValue(XPlannerAttributeFactory.ATTRIBUTE_ITERATION_NAME, getIterationName(userStory, server));
235
		repositoryTaskData.setAttributeValue(XPlannerAttributeFactory.ATTRIBUTE_ITERATION_NAME, getIterationName(userStory, client));
213
	}
236
	}
214
	
237
	
215
	public static String getProjectName(RepositoryTaskData repositoryTaskData) {
238
	public static String getProjectName(RepositoryTaskData repositoryTaskData) {
Lines 224-234 Link Here
224
		return repositoryTaskData.getAttributeValue(XPlannerAttributeFactory.ATTRIBUTE_USER_STORY_NAME);
247
		return repositoryTaskData.getAttributeValue(XPlannerAttributeFactory.ATTRIBUTE_USER_STORY_NAME);
225
	}
248
	}
226
	
249
	
227
	public static String getPersonName(int personId, XPlannerServer server) {
250
	public static String getPersonName(int personId, XPlannerClient client) {
228
		String personName = Messages.XPlannerRepositoryUtils_NO_PERSON_NAME;
251
		String personName = Messages.XPlannerRepositoryUtils_NO_PERSON_NAME;
229
252
230
		try {
253
		try {
231
		  PersonData personData = server.getPerson(personId);
254
		  PersonData personData = client.getPerson(personId);
232
		  if (personData != null) {
255
		  if (personData != null) {
233
		  	personName = personData.getName();
256
		  	personName = personData.getName();
234
		  }
257
		  }
Lines 273-291 Link Here
273
			createdDate = XPlannerAttributeFactory.DATE_FORMAT.parse(dateString);
296
			createdDate = XPlannerAttributeFactory.DATE_FORMAT.parse(dateString);
274
		}
297
		}
275
		catch (ParseException e) {
298
		catch (ParseException e) {
276
			XPlannerMylarUIPlugin.log(e.getCause(), "", false);
299
			XPlannerMylynUIPlugin.log(e.getCause(), "", false); //$NON-NLS-1$
277
		}
300
		}
278
		
301
		
279
		return createdDate;
302
		return createdDate;
280
	}
303
	}
281
304
282
	public static String getProjectName(TaskData taskData, XPlannerServer server) {
305
	public static String getProjectName(TaskData taskData, XPlannerClient client) {
283
	  String projectName = Messages.XPlannerRepositoryUtils_NO_PROJECT_NAME;
306
	  String projectName = Messages.XPlannerRepositoryUtils_NO_PROJECT_NAME;
284
307
285
	  UserStoryData userStory;
308
	  UserStoryData userStory;
286
		try {
309
		try {
287
			userStory = server.getUserStory(taskData.getStoryId());
310
			userStory = client.getUserStory(taskData.getStoryId());
288
			projectName = getProjectName(userStory, server);
311
			projectName = getProjectName(userStory, client);
289
		}
312
		}
290
		catch (RemoteException e) {
313
		catch (RemoteException e) {
291
			// TODO Auto-generated catch block
314
			// TODO Auto-generated catch block
Lines 295-308 Link Here
295
		return projectName;
318
		return projectName;
296
	}
319
	}
297
	
320
	
298
	public static String getProjectName(UserStoryData userStory, XPlannerServer server) {
321
	public static String getProjectName(UserStoryData userStory, XPlannerClient client) {
299
	  String projectName = Messages.XPlannerRepositoryUtils_NO_PROJECT_NAME;
322
	  String projectName = Messages.XPlannerRepositoryUtils_NO_PROJECT_NAME;
300
	  
323
	  
301
		try {
324
		try {
302
		  if (userStory != null) {
325
		  if (userStory != null) {
303
		    IterationData iteration = server.getIteration(userStory.getIterationId());
326
		    IterationData iteration = client.getIteration(userStory.getIterationId());
304
		    if (iteration != null) {
327
		    if (iteration != null) {
305
		      ProjectData project = server.getProject(iteration.getProjectId());
328
		      ProjectData project = client.getProject(iteration.getProjectId());
306
		      if (project != null) {
329
		      if (project != null) {
307
		        projectName = project.getName();
330
		        projectName = project.getName();
308
		      }  
331
		      }  
Lines 316-327 Link Here
316
	  return projectName;
339
	  return projectName;
317
	}
340
	}
318
341
319
	public static String getIterationName(TaskData taskData, XPlannerServer server) {
342
	public static String getIterationName(TaskData taskData, XPlannerClient client) {
320
	  String iterationName = Messages.XPlannerRepositoryUtils_NO_ITERATION_NAME;
343
	  String iterationName = Messages.XPlannerRepositoryUtils_NO_ITERATION_NAME;
321
	  
344
	  
322
		try {
345
		try {
323
			UserStoryData userStory = server.getUserStory(taskData.getStoryId());
346
			UserStoryData userStory = client.getUserStory(taskData.getStoryId());
324
			iterationName = getIterationName(userStory, server);
347
			iterationName = getIterationName(userStory, client);
325
		}
348
		}
326
		catch (RemoteException e) {
349
		catch (RemoteException e) {
327
			// TODO Auto-generated catch block
350
			// TODO Auto-generated catch block
Lines 331-341 Link Here
331
		return iterationName;
354
		return iterationName;
332
	}
355
	}
333
356
334
	public static String getIterationName(UserStoryData userStory, XPlannerServer server) {
357
	public static String getIterationName(UserStoryData userStory, XPlannerClient client) {
335
	  String iterationName = Messages.XPlannerRepositoryUtils_NO_ITERATION_NAME;
358
	  String iterationName = Messages.XPlannerRepositoryUtils_NO_ITERATION_NAME;
336
	  
359
	  
337
		try {
360
		try {
338
	    IterationData iteration = server.getIteration(userStory.getIterationId());
361
	    IterationData iteration = client.getIteration(userStory.getIterationId());
339
	    if (iteration != null) {
362
	    if (iteration != null) {
340
	      iterationName = iteration.getName();
363
	      iterationName = iteration.getName();
341
	    }
364
	    }
Lines 347-357 Link Here
347
	  return iterationName;
370
	  return iterationName;
348
	}
371
	}
349
372
350
	public static String getUserStoryName(TaskData taskData, XPlannerServer server) {
373
	public static String getUserStoryName(TaskData taskData, XPlannerClient client) {
351
	  String userStoryName = Messages.XPlannerRepositoryUtils_NO_USER_STORY_NAME;
374
	  String userStoryName = Messages.XPlannerRepositoryUtils_NO_USER_STORY_NAME;
352
	  
375
	  
353
		try {
376
		try {
354
      UserStoryData userStory = server.getUserStory(taskData.getStoryId());
377
      UserStoryData userStory = client.getUserStory(taskData.getStoryId());
355
		  if (userStory != null) {
378
		  if (userStory != null) {
356
		  	userStoryName = userStory.getName();
379
		  	userStoryName = userStory.getName();
357
		  }
380
		  }
Lines 376-388 Link Here
376
		return repositoryTaskData.getAttributeValue(RepositoryTaskAttribute.SUMMARY);
399
		return repositoryTaskData.getAttributeValue(RepositoryTaskAttribute.SUMMARY);
377
	}
400
	}
378
401
379
	public static String getPriorityFromXPlannerObject(Object xplannerObject, XPlannerServer server) {
402
	public static String getPriorityFromXPlannerObject(Object xplannerObject, XPlannerClient client) {
380
		int priority = -1;
403
		int priority = -1;
381
		UserStoryData userStory = null;
404
		UserStoryData userStory = null;
382
		
405
		
383
		try {
406
		try {
384
			if (xplannerObject instanceof TaskData) {
407
			if (xplannerObject instanceof TaskData) {
385
				userStory = server.getUserStory(((TaskData)xplannerObject).getStoryId());
408
				userStory = client.getUserStory(((TaskData)xplannerObject).getStoryId());
386
			}
409
			}
387
			else if (xplannerObject instanceof UserStoryData) {
410
			else if (xplannerObject instanceof UserStoryData) {
388
				userStory = (UserStoryData)xplannerObject;
411
				userStory = (UserStoryData)xplannerObject;
Lines 418-439 Link Here
418
		}
441
		}
419
		
442
		
420
		TaskRepository taskRepository = TasksUiPlugin.getRepositoryManager().getRepository(
443
		TaskRepository taskRepository = TasksUiPlugin.getRepositoryManager().getRepository(
421
				XPlannerMylarUIPlugin.REPOSITORY_KIND, repositoryUrl);		
444
				XPlannerMylynUIPlugin.REPOSITORY_KIND, repositoryUrl);		
422
		if (taskRepository != null && !isRepositoryUrlValidated(taskRepository.getUrl())) {
445
		if (taskRepository != null && !isRepositoryUrlValidated(taskRepository.getUrl())) {
423
			validateRepository(taskRepository);
446
			validateRepository(taskRepository);
424
		}
447
		}
425
	}
448
	}
426
449
427
	public static void validateRepository(TaskRepository taskRepository) throws CoreException {
450
	public static void validateRepository(TaskRepository taskRepository) throws CoreException {
451
		validateRepository(taskRepository.getUrl(),
452
				taskRepository.getUserName(), taskRepository.getPassword(), taskRepository.getProxy(), 
453
				taskRepository.getHttpUser(), taskRepository.getHttpPassword());
454
	}
455
	
456
	public static void validateRepository(String url, String userName, String password) throws CoreException {
457
		validateRepository(url, userName, password, Proxy.NO_PROXY, null, null);
458
	}
459
	
460
	public static void validateRepository(String url, String userName, String password,
461
		Proxy proxy, String httpUser, String httpPassword) throws CoreException {
462
		
428
		try {
463
		try {
429
			XPlannerServerFacade.getDefault().validateServerAndCredentials(
464
			XPlannerClientFacade.getDefault().validateServerAndCredentials(url, userName, password,
430
					taskRepository.getUrl(),
465
				proxy, httpUser, httpPassword);
431
					taskRepository.getUserName(), taskRepository.getPassword());
432
		} 
466
		} 
433
		catch (Exception e) {
467
		catch (Exception e) {
434
			throw new CoreException(XPlannerCorePlugin.toStatus(e));
468
			throw new CoreException(XPlannerCorePlugin.toStatus(e));
435
		}
469
		}
436
470
437
	}
471
	}
472
	
438
}
473
}
439
 
474
 
(-)src/org/eclipse/mylyn/xplanner/ui/XPlannerRepositoryConnector.java (-171 / +236 lines)
Lines 5-80 Link Here
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
package org.eclipse.mylar.xplanner.ui;
8
package org.eclipse.mylyn.xplanner.ui;
9
9
10
import java.rmi.RemoteException;
10
import java.rmi.RemoteException;
11
import java.text.MessageFormat;
11
import java.text.MessageFormat;
12
import java.util.ArrayList;
12
import java.text.ParseException;
13
import java.util.Arrays;
13
import java.util.*;
14
import java.util.Collections;
14
15
import java.util.Date;
15
import org.eclipse.core.runtime.*;
16
import java.util.HashSet;
16
import org.eclipse.mylyn.internal.tasks.core.RepositoryTaskHandleUtil;
17
import java.util.List;
17
import org.eclipse.mylyn.monitor.core.StatusHandler;
18
import java.util.Set;
18
import org.eclipse.mylyn.tasks.core.*;
19
19
import org.eclipse.mylyn.tasks.ui.TasksUiPlugin;
20
import org.eclipse.core.runtime.CoreException;
20
import org.eclipse.mylyn.xplanner.core.service.XPlannerClient;
21
import org.eclipse.core.runtime.IProgressMonitor;
21
import org.eclipse.mylyn.xplanner.wsdl.soap.domain.DomainData;
22
import org.eclipse.core.runtime.IStatus;
23
import org.eclipse.core.runtime.Status;
24
import org.eclipse.mylar.internal.tasks.core.RepositoryTaskHandleUtil;
25
import org.eclipse.mylar.tasks.core.AbstractRepositoryConnector;
26
import org.eclipse.mylar.tasks.core.AbstractRepositoryQuery;
27
import org.eclipse.mylar.tasks.core.AbstractRepositoryTask;
28
import org.eclipse.mylar.tasks.core.IAttachmentHandler;
29
import org.eclipse.mylar.tasks.core.ITask;
30
import org.eclipse.mylar.tasks.core.ITaskDataHandler;
31
import org.eclipse.mylar.tasks.core.QueryHitCollector;
32
import org.eclipse.mylar.tasks.core.RepositoryTaskData;
33
import org.eclipse.mylar.tasks.core.TaskList;
34
import org.eclipse.mylar.tasks.core.TaskRepository;
35
import org.eclipse.mylar.tasks.ui.TasksUiPlugin;
36
import org.eclipse.mylar.xplanner.core.service.XPlannerServer;
37
import org.xplanner.soap.TaskData;
22
import org.xplanner.soap.TaskData;
38
import org.xplanner.soap.UserStoryData;
23
import org.xplanner.soap.UserStoryData;
39
24
40
import org.eclipse.mylar.xplanner.wsdl.soap.domain.DomainData;
41
42
/**
25
/**
43
 * @author Ravi Kumar 
26
 * @author Ravi Kumar 
44
 * @author Helen Bershadskaya 
27
 * @author Helen Bershadskaya 
45
 */
28
 */
46
public class XPlannerRepositoryConnector extends AbstractRepositoryConnector {
29
public class XPlannerRepositoryConnector extends AbstractRepositoryConnector {
47
30
48
	private static final String VERSION_SUPPORT = Messages.XPlannerRepositoryConnector_VERSION_SUPPORT;
31
	//private static final String VERSION_SUPPORT = Messages.XPlannerRepositoryConnector_VERSION_SUPPORT;
49
32
50
	private XPlannerOfflineTaskHandler offlineHandler;
33
	private XPlannerTaskDataHandler offlineHandler;
51
	
34
	
52
	private List<String> supportedVersions;
35
	//private List<String> supportedVersions;
53
36
54
	/** Name initially given to new tasks. Public for testing */
37
	/** Name initially given to new tasks. Public for testing */
55
	public static final String NEW_TASK_DESC = Messages.XPlannerRepositoryConnector_NEW_TASK_DESCRIPTION;
38
	public static final String NEW_TASK_DESC = Messages.XPlannerRepositoryConnector_NEW_TASK_DESCRIPTION;
56
39
57
	public void init(TaskList taskList) {
40
	public void init(TaskList taskList) {
58
		super.init(taskList);
41
		super.init(taskList);
59
		this.offlineHandler = new XPlannerOfflineTaskHandler(taskList);
42
		this.offlineHandler = new XPlannerTaskDataHandler(taskList);
60
	}
43
	}
61
44
62
	public String getLabel() {
45
	public String getLabel() {
63
		return XPlannerMylarUIPlugin.XPLANNER_CLIENT_LABEL;
46
		return XPlannerMylynUIPlugin.XPLANNER_CLIENT_LABEL;
64
	}
47
	}
65
48
66
	public String getRepositoryType() {
49
	public String getConnectorKind() {
67
		return XPlannerMylarUIPlugin.REPOSITORY_KIND;
50
		return XPlannerMylynUIPlugin.REPOSITORY_KIND;
68
	}
51
	}
69
52
70
	@Override
53
	@Override
71
	public IAttachmentHandler getAttachmentHandler() {
54
	public AbstractAttachmentHandler getAttachmentHandler() {
72
		// not implemented
55
		// not implemented yet
73
		return null;
56
		return null;
74
	}
57
	}
75
58
76
	@Override
59
	@Override
77
	public ITaskDataHandler getTaskDataHandler() {
60
	public AbstractTaskDataHandler getTaskDataHandler() {
78
		return offlineHandler;
61
		return offlineHandler;
79
	}
62
	}
80
63
Lines 83-128 Link Here
83
		return true;
66
		return true;
84
	}
67
	}
85
68
86
	@Override
69
	protected AbstractTask makeTask(String repositoryUrl, String id, String summary) {
87
	public AbstractRepositoryTask createTaskFromExistingKey(TaskRepository repository, String key)
70
		return new XPlannerTask(repositoryUrl, id, summary);
88
		throws CoreException {
71
	}
72
73
	public AbstractTask createTask(String repositoryUrl, String id, String summary) {
74
		AbstractTask task = null;
89
		
75
		
76
		TaskRepository repository = TasksUiPlugin.getRepositoryManager().getRepository(
77
			XPlannerMylynUIPlugin.REPOSITORY_KIND, repositoryUrl);
78
		String handleIdentifier = RepositoryTaskHandleUtil.getHandle(repository.getUrl(), id);
79
		AbstractTask existingTask = TasksUiPlugin.getTaskListManager().getTaskList().getTask(
80
			handleIdentifier);
81
82
		if (existingTask instanceof XPlannerTask) {
83
			task = (XPlannerTask) existingTask;
84
		} 
85
		else {
86
			try {
87
				task = createTask(repository, id);
88
			}
89
			catch (CoreException e) {
90
				XPlannerMylynUIPlugin.log(e, "", false); //$NON-NLS-1$
91
			}
92
		}
93
94
		return task;
95
	}
96
	
97
	private AbstractTask createTask(TaskRepository repository, String key) throws CoreException {
98
		XPlannerTask task = null;
99
90
		XPlannerRepositoryUtils.checkRepositoryValidated(repository.getUrl());
100
		XPlannerRepositoryUtils.checkRepositoryValidated(repository.getUrl());
91
		XPlannerServer server = XPlannerServerFacade.getDefault().getXPlannerServer(repository);
101
		XPlannerClient client = XPlannerClientFacade.getDefault().getXPlannerClient(repository);
92
		if (server != null) {
102
		if (client != null) {
93
			XPlannerTask task = null;
94
			try {
103
			try {
95
				// first check if taskdata exists
104
				// first check if taskdata exists
96
				TaskData taskData = server.getTask(Integer.valueOf(key).intValue());
105
				TaskData taskData = client.getTask(Integer.valueOf(key).intValue());
97
				if (taskData != null) {
106
				if (taskData != null) {
98
					task = createTask(taskData, taskData.getName(), String.valueOf(taskData.getId()), repository);
107
					task = createTask(taskData, taskData.getName(), String.valueOf(taskData.getId()), repository);
99
					updateTaskDetails(repository.getUrl(), task, taskData, true);
100
				}
108
				}
101
				else {
109
				else {
102
					// otherwise check if a user story exists
110
					// otherwise check if a user story exists
103
					UserStoryData userStory = server.getUserStory(Integer.valueOf(key).intValue());
111
					UserStoryData userStory = client.getUserStory(Integer.valueOf(key).intValue());
104
					if (userStory != null) {
112
					if (userStory != null) {
105
						task = createTask(userStory, userStory.getName(), String.valueOf(userStory.getId()), repository);
113
						task = createTask(userStory, userStory.getName(), String.valueOf(userStory.getId()), repository);
106
						updateTaskDetails(repository.getUrl(), task, userStory, true);
107
					}
114
					}
108
				}
115
				}
109
			} 
116
			} 
110
			catch (Exception e) {
117
			catch (Exception e) {
111
				e.printStackTrace();
118
				e.printStackTrace();
112
			} 
119
			} 
113
114
			if (task != null) {
115
				TasksUiPlugin.getTaskListManager().getTaskList().addTask(task);
116
				return task;
117
			}
118
119
		}
120
		}
120
		return null;
121
		
122
		return task;
121
	}
123
	}
122
124
123
	@Override
125
	@Override
124
	public IStatus performQuery(AbstractRepositoryQuery repositoryQuery, TaskRepository repository,
126
	public IStatus performQuery(AbstractRepositoryQuery repositoryQuery, TaskRepository repository,
125
			IProgressMonitor monitor, QueryHitCollector resultCollector) {
127
			IProgressMonitor monitor, ITaskCollector resultCollector) {
126
		
128
		
127
		if (!(repositoryQuery instanceof XPlannerCustomQuery)) {
129
		if (!(repositoryQuery instanceof XPlannerCustomQuery)) {
128
			return Status.OK_STATUS;
130
			return Status.OK_STATUS;
Lines 132-144 Link Here
132
134
133
135
134
		try {
136
		try {
135
			XPlannerServer server = XPlannerServerFacade.getDefault().getXPlannerServer(repository);
137
			monitor.beginTask("Running query", IProgressMonitor.UNKNOWN);
138
			XPlannerClient client = XPlannerClientFacade.getDefault().getXPlannerClient(repository);
136
139
137
			if (xplannerCustomQuery.isMyCurrentTasks()) {
140
			if (xplannerCustomQuery.isMyCurrentTasks()) {
138
				return queryMyCurrentTasks(xplannerCustomQuery, server, repository, resultCollector);
141
				return queryMyCurrentTasks(xplannerCustomQuery, client, repository, resultCollector);
139
			}
142
			}
140
			else {
143
			else {
141
				return queryTasks(xplannerCustomQuery, server, repository, resultCollector);
144
				return queryTasks(xplannerCustomQuery, client, repository, resultCollector);
142
			}
145
			}
143
			
146
			
144
		}
147
		}
Lines 147-155 Link Here
147
			if ((reason == null) || (reason.length() == 0)) {
150
			if ((reason == null) || (reason.length() == 0)) {
148
				reason = e.getClass().getName();
151
				reason = e.getClass().getName();
149
			}
152
			}
150
			return new Status(IStatus.OK, TasksUiPlugin.PLUGIN_ID, IStatus.ERROR, 
153
			return new Status(IStatus.OK, TasksUiPlugin.ID_PLUGIN, IStatus.ERROR, 
151
				MessageFormat.format(Messages.XPlannerRepositoryConnector_PerformQueryFailure, reason), e );
154
				MessageFormat.format(Messages.XPlannerRepositoryConnector_PerformQueryFailure, reason), e );
152
		}
155
		}
156
		finally {
157
			monitor.done();
158
		}
153
		
159
		
154
		//return Status.OK_STATUS;
160
		//return Status.OK_STATUS;
155
	}
161
	}
Lines 161-167 Link Here
161
167
162
//TODO -- no longer used -- remove if really unnecessary	
168
//TODO -- no longer used -- remove if really unnecessary	
163
//	private IStatus queryUserStories(XPlannerCustomQuery xplannerCustomQuery, 
169
//	private IStatus queryUserStories(XPlannerCustomQuery xplannerCustomQuery, 
164
//		XPlannerServer server, TaskRepository repository, QueryHitCollector resultCollector) throws RemoteException {
170
//		XPlannerClient client, TaskRepository repository, QueryHitCollector resultCollector) throws RemoteException {
165
//		
171
//		
166
//		int iterationId = xplannerCustomQuery.getContentId();
172
//		int iterationId = xplannerCustomQuery.getContentId();
167
//		UserStoryData[] userStories;
173
//		UserStoryData[] userStories;
Lines 169-204 Link Here
169
//		// check if want all or person's stories
175
//		// check if want all or person's stories
170
//		if (xplannerCustomQuery.getPersonId() != XPlannerCustomQuery.INVALID_ID) {
176
//		if (xplannerCustomQuery.getPersonId() != XPlannerCustomQuery.INVALID_ID) {
171
//			int trackerId = xplannerCustomQuery.getPersonId();
177
//			int trackerId = xplannerCustomQuery.getPersonId();
172
//			userStories = server.getIterationUserStoriesForTracker(trackerId, iterationId);
178
//			userStories = client.getIterationUserStoriesForTracker(trackerId, iterationId);
173
//		}
179
//		}
174
//		else {
180
//		else {
175
//			userStories = server.getUserStories(iterationId);
181
//			userStories = client.getUserStories(iterationId);
176
//		}
182
//		}
177
//		
183
//		
178
//		return getUserStoryQueryHits(Arrays.asList(userStories), repository, xplannerCustomQuery, resultCollector);
184
//		return getUserStoryQueryHits(Arrays.asList(userStories), repository, xplannerCustomQuery, resultCollector);
179
//	}
185
//	}
180
186
181
	private IStatus queryMyCurrentTasks(XPlannerCustomQuery xplannerCustomQuery,
187
	private IStatus queryMyCurrentTasks(XPlannerCustomQuery xplannerCustomQuery,
182
		XPlannerServer server, TaskRepository repository, QueryHitCollector resultCollector) throws RemoteException {
188
		XPlannerClient client, TaskRepository repository, ITaskCollector resultCollector) throws RemoteException {
183
		
189
		
184
		ArrayList<TaskData> xplannerTasks = new ArrayList<TaskData>();
190
		ArrayList<TaskData> xplannerTasks = new ArrayList<TaskData>();
185
		int currentPersonId = server.getCurrentPersonId();
191
		int currentPersonId = client.getCurrentPersonId();
186
		
192
		
187
		xplannerTasks.addAll(Arrays.asList(server.getCurrentTasksForPerson(currentPersonId)));
193
		xplannerTasks.addAll(Arrays.asList(client.getCurrentTasksForPerson(currentPersonId)));
188
		xplannerTasks.addAll(Arrays.asList(server.getPlannedTasksForPerson(currentPersonId)));
194
		xplannerTasks.addAll(Arrays.asList(client.getPlannedTasksForPerson(currentPersonId)));
189
		
195
		
190
		return getTaskQueryHits(xplannerTasks, repository, xplannerCustomQuery, resultCollector);
196
		return getTaskQueryHits(xplannerTasks, repository, xplannerCustomQuery, resultCollector);
191
	}
197
	}
192
198
193
	private IStatus queryTasks(XPlannerCustomQuery xplannerCustomQuery, 
199
	private IStatus queryTasks(XPlannerCustomQuery xplannerCustomQuery, 
194
		XPlannerServer server, TaskRepository repository, QueryHitCollector resultCollector) throws RemoteException {
200
		XPlannerClient client, TaskRepository repository, ITaskCollector resultCollector) throws RemoteException {
195
		
201
		
196
		List<Integer> contentIds = xplannerCustomQuery.getContentIds();
202
		List<Integer> contentIds = xplannerCustomQuery.getContentIds();
197
		ArrayList<TaskData> xplannerTasks = new ArrayList<TaskData>();
203
		ArrayList<TaskData> xplannerTasks = new ArrayList<TaskData>();
198
		XPlannerCustomQuery.ContentIdType contentIdType = xplannerCustomQuery.getContentIdType();
204
		XPlannerCustomQuery.ContentIdType contentIdType = xplannerCustomQuery.getContentIdType();
199
		
205
		
200
		for (Integer contentId : contentIds) {
206
		for (Integer contentId : contentIds) {
201
			addTasks(contentId, contentIdType, xplannerTasks, xplannerCustomQuery, server);
207
			addTasks(contentId, contentIdType, xplannerTasks, xplannerCustomQuery, client);
202
		}
208
		}
203
		
209
		
204
		return getTaskQueryHits(xplannerTasks, repository, xplannerCustomQuery, resultCollector);
210
		return getTaskQueryHits(xplannerTasks, repository, xplannerCustomQuery, resultCollector);
Lines 206-244 Link Here
206
212
207
	private void addTasks(int contentId, 
213
	private void addTasks(int contentId, 
208
		XPlannerCustomQuery.ContentIdType contentIdType, List<TaskData> xplannerTasks, 
214
		XPlannerCustomQuery.ContentIdType contentIdType, List<TaskData> xplannerTasks, 
209
		XPlannerCustomQuery xplannerCustomQuery, XPlannerServer server) throws RemoteException {
215
		XPlannerCustomQuery xplannerCustomQuery, XPlannerClient client) throws RemoteException {
210
		
216
		
211
		if (contentId == XPlannerCustomQuery.INVALID_ID) {
217
		if (contentId == XPlannerCustomQuery.INVALID_ID) {
212
			return;
218
			return;
213
		}
219
		}
214
		
220
		
215
		if (contentIdType == XPlannerCustomQuery.ContentIdType.PROJECT) {
221
		if (contentIdType == XPlannerCustomQuery.ContentIdType.PROJECT) {
216
			UserStoryData[] userStories = server.getUserStoriesForProject(contentId);
222
			UserStoryData[] userStories = client.getUserStoriesForProject(contentId);
217
			for (UserStoryData userStory : userStories) {
223
			for (UserStoryData userStory : userStories) {
218
				addUserStoryTasks(xplannerCustomQuery, userStory.getId(), xplannerTasks, server);
224
				addUserStoryTasks(xplannerCustomQuery, userStory.getId(), xplannerTasks, client);
219
			}
225
			}
220
		}
226
		}
221
		else if (contentIdType == XPlannerCustomQuery.ContentIdType.ITERATION) {
227
		else if (contentIdType == XPlannerCustomQuery.ContentIdType.ITERATION) {
222
			UserStoryData[] userStories = server.getUserStories(contentId);
228
			UserStoryData[] userStories = client.getUserStories(contentId);
223
			for (UserStoryData userStory : userStories) {
229
			for (UserStoryData userStory : userStories) {
224
				addUserStoryTasks(xplannerCustomQuery, userStory.getId(), xplannerTasks, server);
230
				addUserStoryTasks(xplannerCustomQuery, userStory.getId(), xplannerTasks, client);
225
			}
231
			}
226
		}
232
		}
227
		else if (contentIdType == XPlannerCustomQuery.ContentIdType.USER_STORY) {
233
		else if (contentIdType == XPlannerCustomQuery.ContentIdType.USER_STORY) {
228
			addUserStoryTasks(xplannerCustomQuery, contentId, xplannerTasks, server);
234
			addUserStoryTasks(xplannerCustomQuery, contentId, xplannerTasks, client);
229
		}
235
		}
230
	}
236
	}
231
237
232
	private void addUserStoryTasks(XPlannerCustomQuery query, int userStoryId, 
238
	private void addUserStoryTasks(XPlannerCustomQuery query, int userStoryId, 
233
		List<TaskData> xplannerTasks, XPlannerServer server) {
239
		List<TaskData> xplannerTasks, XPlannerClient client) {
234
		// check if want all or person's tasks
240
		// check if want all or person's tasks
235
		if (query.getPersonId() != XPlannerCustomQuery.INVALID_ID) {
241
		if (query.getPersonId() != XPlannerCustomQuery.INVALID_ID) {
236
			int personId = query.getPersonId();
242
			int personId = query.getPersonId();
237
			xplannerTasks.addAll(Arrays.asList(server.getUserStoryTasksForPerson(personId, userStoryId)));
243
			xplannerTasks.addAll(Arrays.asList(client.getUserStoryTasksForPerson(personId, userStoryId)));
238
		}
244
		}
239
		else {
245
		else {
240
			try {
246
			try {
241
				xplannerTasks.addAll(Arrays.asList(server.getTasks(userStoryId)));
247
				xplannerTasks.addAll(Arrays.asList(client.getTasks(userStoryId)));
242
			}
248
			}
243
			catch (RemoteException e) {
249
			catch (RemoteException e) {
244
				e.printStackTrace();
250
				e.printStackTrace();
Lines 247-328 Link Here
247
	}
253
	}
248
	
254
	
249
	private IStatus getTaskQueryHits(List<TaskData> tasks, 
255
	private IStatus getTaskQueryHits(List<TaskData> tasks, 
250
		TaskRepository repository, XPlannerCustomQuery query, QueryHitCollector resultCollector) {
256
		TaskRepository repository, XPlannerCustomQuery query, ITaskCollector resultCollector) {
251
		
257
		
252
		for (TaskData data : tasks) {
258
		for (TaskData data : tasks) {
253
			String id = String.valueOf(data.getId());
259
			String id = String.valueOf(data.getId());
254
			ITask task = TasksUiPlugin.getTaskListManager().getTaskList().getTask(repository.getUrl(), id);
260
			AbstractTask task = TasksUiPlugin.getTaskListManager().getTaskList().getTask(repository.getUrl(), id);
255
			if (!(task instanceof XPlannerTask)) {
261
			if (task != null) {
256
				task = createTask(data, data.getName(), id, repository);
262
				updateTaskDetails(repository.getUrl(), (XPlannerTask) task, data, false);
257
			}
258
			updateTaskDetails(repository.getUrl(), (XPlannerTask) task, data, false);
259
260
			XPlannerQueryHit hit = new XPlannerQueryHit(
261
				taskList, task.getSummary(), task.getPriority(), query.getRepositoryUrl(), 
262
				id, (XPlannerTask) task);
263
			try {
264
				resultCollector.accept(hit);
265
				} catch (CoreException e) {
266
				return new Status(IStatus.OK, TasksUiPlugin.PLUGIN_ID, IStatus.ERROR, 
267
						MessageFormat.format(Messages.XPlannerRepositoryConnector_ERROR_RETRIEVING_RESULTS, query.getRepositoryUrl()), e );
268
			}
263
			}
269
		}
264
270
		return Status.OK_STATUS;
265
//			try {
271
	}
266
// HeB -- priority already set in task				
272
	
267
//				XPlannerClient client = XPlannerClientFacade.getDefault().getXPlannerClient(repository);
273
	private IStatus getUserStoryQueryHits(List<UserStoryData> userStories, 
268
//				UserStoryData userStory = client.getUserStory(data.getStoryId());
274
		TaskRepository repository, XPlannerCustomQuery query, QueryHitCollector resultCollector) {
269
//				String priority = userStory == null ? AbstractTask.PriorityLevel.getDefault().toString() : 
275
		
270
//					"" + userStory.getPriority(); //$NON-NLS-1$
276
		for (UserStoryData data : userStories) {
271
//				task.setPriority(priority);
277
			String id = String.valueOf(data.getId());
272
			else {
278
			ITask task = TasksUiPlugin.getTaskListManager().getTaskList().getTask(repository.getUrl(), id);
273
				task = createTask(data, data.getName(), String.valueOf(data.getId()), repository);
279
			if (!(task instanceof XPlannerTask)) {
280
				task = createTask(data, data.getName(), id, repository);
281
			}
282
			updateTaskDetails(repository.getUrl(), (XPlannerTask) task, data, false);
283
284
			XPlannerQueryHit hit = new XPlannerQueryHit(taskList, 
285
				task.getSummary(), task.getPriority(), query.getRepositoryUrl(), 
286
				id, (XPlannerTask) task);
287
			try {
288
				resultCollector.accept(hit);
289
			} 
290
			catch (CoreException e) {
291
				return new Status(IStatus.OK, TasksUiPlugin.PLUGIN_ID, IStatus.ERROR, 
292
						MessageFormat.format(Messages.XPlannerRepositoryConnector_ERROR_RETRIEVING_RESULTS, query.getRepositoryUrl()), e );
293
			}
274
			}
275
			
276
			resultCollector.accept(task);
277
//			} 
278
//			catch (Exception e) {
279
//				return new Status(IStatus.OK, TasksUiPlugin.PLUGIN_ID, IStatus.ERROR, 
280
//						MessageFormat.format(Messages.XPlannerRepositoryConnector_ERROR_RETRIEVING_RESULTS, query.getRepositoryUrl()), e );
281
//			}
294
		}
282
		}
295
		
296
		return Status.OK_STATUS;
283
		return Status.OK_STATUS;
297
	}
284
	}
285
286
// no longer called -- calling routine commented out	
287
//	private IStatus getUserStoryQueryHits(List<UserStoryData> userStories, 
288
//		TaskRepository repository, XPlannerCustomQuery query, QueryHitCollector resultCollector) {
289
//		
290
//		for (UserStoryData data : userStories) {
291
//			String id = String.valueOf(data.getId());
292
//			ITask task = TasksUiPlugin.getTaskListManager().getTaskList().getTask(repository.getUrl(), id);
293
//			if (task != null) {
294
//				updateTaskDetails(repository.getUrl(), (XPlannerTask) task, data, false);
295
//			}
296
//
297
//			XPlannerQueryHit hit = new XPlannerQueryHit(taskList, 
298
//				data.getDescription(), "" + data.getPriority(), query.getRepositoryUrl(),  //$NON-NLS-1$
299
//				id);
300
//			resultCollector.accept(hit);
301
//		}
302
//		
303
//		return Status.OK_STATUS;
304
//	}
298
	
305
	
299
	@Override
306
	@Override
300
	public void updateTask(TaskRepository repository, AbstractRepositoryTask repositoryTask) throws CoreException {
307
	public void updateTaskFromRepository(TaskRepository repository, AbstractTask repositoryTask,
308
		IProgressMonitor monitor) throws CoreException {
309
		
301
		if (repository != null && repositoryTask instanceof XPlannerTask) {
310
		if (repository != null && repositoryTask instanceof XPlannerTask) {
302
			XPlannerTask xPlannerTask = (XPlannerTask) repositoryTask;
311
			XPlannerTask xPlannerTask = (XPlannerTask) repositoryTask;
303
			XPlannerServer server = XPlannerServerFacade.getDefault().getXPlannerServer(repository);
312
			XPlannerClient client = XPlannerClientFacade.getDefault().getXPlannerClient(repository);
304
			if (server != null) {
313
			if (client != null) {
305
				TaskData xplannerTaskData;
314
				TaskData xplannerTaskData;
306
				try {
315
				try {
307
					xplannerTaskData = server.getTask(Integer.valueOf(xPlannerTask.getKey()).intValue());
316
					xplannerTaskData = client.getTask(Integer.valueOf(xPlannerTask.getTaskId()).intValue());
308
					if (xplannerTaskData != null) {
317
					if (xplannerTaskData != null) {
309
						updateTaskDetails(repository.getUrl(), xPlannerTask, xplannerTaskData, true);
318
						updateTaskDetails(repository.getUrl(), xPlannerTask, xplannerTaskData, true);
310
					}
319
					}
320
					else {
321
						UserStoryData userStoryData;
322
						userStoryData = client.getUserStory(Integer.valueOf(xPlannerTask.getTaskId()).intValue());
323
						if (userStoryData != null) {
324
							updateTaskDetails(repository.getUrl(), xPlannerTask, userStoryData, true);
325
						}
326
					}
311
				}
327
				}
312
				catch (Exception e) {
328
				catch (Exception e) {
313
					throw new CoreException(new Status(IStatus.ERROR, 
329
					throw new CoreException(new Status(IStatus.ERROR, 
314
							XPlannerMylarUIPlugin.PLUGIN_ID, IStatus.ERROR, Messages.XPlannerRepositoryConnector_ERROR_UPDATING_TASK, e));
330
							XPlannerMylynUIPlugin.PLUGIN_ID, IStatus.ERROR, Messages.XPlannerRepositoryConnector_ERROR_UPDATING_TASK, e));
315
				}
331
				}
316
			}
332
			}
317
		}
333
		}
318
	}
334
	}
319
335
320
	@Override
336
	@Override
337
	public void updateTaskFromTaskData(TaskRepository repository, AbstractTask repositoryTask,
338
		RepositoryTaskData taskData) {
339
		
340
		if (taskData != null) {
341
			XPlannerTask xplannerTask = (XPlannerTask) repositoryTask;
342
			String url = repository.getUrl() + XPlannerMylynUIPlugin.TASK_URL_PREFIX + taskData.getId();
343
			xplannerTask.setUrl(url);
344
			xplannerTask.setSummary(taskData.getSummary());
345
			xplannerTask.setOwner(taskData.getAssignedTo());
346
			xplannerTask.setPriority(taskData.getAttributeValue(RepositoryTaskAttribute.PRIORITY));
347
			xplannerTask.setTaskKind(taskData.getTaskKind());
348
349
			
350
			if (XPlannerRepositoryUtils.isCompleted(taskData)) {
351
				xplannerTask.setCompleted(true);
352
				try {
353
					xplannerTask.setCompletionDate(	// guess that completed when last modified
354
							XPlannerAttributeFactory.TIME_DATE_FORMAT.parse(
355
							taskData.getAttribute(RepositoryTaskAttribute.DATE_MODIFIED).getValue()));
356
				}
357
				catch (ParseException e) {
358
					StatusHandler.log(e, Messages.XPlannerRepositoryConnector_COULD_NOT_CONVERT_TASK_DATE);
359
				}
360
			} 
361
			else {
362
				xplannerTask.setCompleted(false);
363
				xplannerTask.setCompletionDate(null);
364
			}
365
		}
366
	}
367
	
368
	@Override
321
	public String getRepositoryUrlFromTaskUrl(String url) {
369
	public String getRepositoryUrlFromTaskUrl(String url) {
322
		if (url == null) {
370
		if (url == null) {
323
			return null;
371
			return null;
324
		}
372
		}
325
		int index = url.indexOf(XPlannerMylarUIPlugin.DELIM_URL_PREFIX);
373
		int index = url.indexOf(XPlannerMylynUIPlugin.DELIM_URL_PREFIX);
326
		if (index != -1) {
374
		if (index != -1) {
327
			return url.substring(0, index);
375
			return url.substring(0, index);
328
		}
376
		}
Lines 331-341 Link Here
331
379
332
	public void updateTaskDetails(String repositoryUrl, XPlannerTask task, TaskData taskData, boolean notifyOfChange) {
380
	public void updateTaskDetails(String repositoryUrl, XPlannerTask task, TaskData taskData, boolean notifyOfChange) {
333
		if (taskData.getId() > 0) {
381
		if (taskData.getId() > 0) {
334
			String url = repositoryUrl + XPlannerMylarUIPlugin.TASK_URL_PREFIX + taskData.getId();
382
			String url = repositoryUrl + XPlannerMylynUIPlugin.TASK_URL_PREFIX + taskData.getId();
335
			task.setTaskUrl(url);
383
			task.setUrl(url);
336
			if (taskData.getName() != null) {
384
			if (taskData.getName() != null) {
337
				task.setDescription(taskData.getName());
385
				task.setSummary(taskData.getName());
338
				task.setKey(String.valueOf(taskData.getId()));
339
			}
386
			}
340
		}
387
		}
341
		if (taskData.isCompleted()) {
388
		if (taskData.isCompleted()) {
Lines 348-354 Link Here
348
		}
395
		}
349
396
350
		if (notifyOfChange) {
397
		if (notifyOfChange) {
351
			TasksUiPlugin.getTaskListManager().getTaskList().notifyLocalInfoChanged(task);
398
			TasksUiPlugin.getTaskListManager().getTaskList().notifyTaskChanged(task, true);
352
		}
399
		}
353
	}
400
	}
354
	
401
	
Lines 356-365 Link Here
356
		UserStoryData userStory, boolean notifyOfChange) {
403
		UserStoryData userStory, boolean notifyOfChange) {
357
		
404
		
358
		if (userStory.getId() > 0) {
405
		if (userStory.getId() > 0) {
359
			String url = repositoryUrl + XPlannerMylarUIPlugin.USER_STORY_URL_PREFIX + userStory.getId();
406
			String url = repositoryUrl + XPlannerMylynUIPlugin.USER_STORY_URL_PREFIX + userStory.getId();
360
			task.setTaskUrl(url);
407
			task.setUrl(url);
361
			if (userStory.getName() != null) {
408
			if (userStory.getName() != null) {
362
				task.setDescription(userStory.getName());
409
				task.setSummary(userStory.getName());
363
				task.setKey(String.valueOf(userStory.getId()));
410
				task.setKey(String.valueOf(userStory.getId()));
364
			}
411
			}
365
		}
412
		}
Lines 372-381 Link Here
372
		}
419
		}
373
	    
420
	    
374
		task.setPriority("" + userStory.getPriority()); //$NON-NLS-1$
421
		task.setPriority("" + userStory.getPriority()); //$NON-NLS-1$
375
		task.setKind(XPlannerTask.Kind.USER_STORY.toString());
422
		task.setTaskKind(XPlannerTask.Kind.USER_STORY.toString());
376
423
377
		if (notifyOfChange) {
424
		if (notifyOfChange) {
378
			TasksUiPlugin.getTaskListManager().getTaskList().notifyLocalInfoChanged(task);
425
			TasksUiPlugin.getTaskListManager().getTaskList().notifyTaskChanged(task, true);
379
		}
426
		}
380
	}
427
	}
381
	
428
	
Lines 384-412 Link Here
384
		
431
		
385
		XPlannerTask task;
432
		XPlannerTask task;
386
		
433
		
387
		String handleIdentifier = RepositoryTaskHandleUtil.getHandle(repository.getUrl(), id);
434
		AbstractTask existingTask = TasksUiPlugin.getTaskListManager().getTaskList().getTask(
388
		ITask existingTask = TasksUiPlugin.getTaskListManager().getTaskList().getTask(
435
			repository.getUrl(), id);	
389
			handleIdentifier);
390
		if (existingTask instanceof XPlannerTask) {
436
		if (existingTask instanceof XPlannerTask) {
391
			task = (XPlannerTask) existingTask;
437
			task = (XPlannerTask) existingTask;
392
		} 
438
		} 
393
		else {
439
		else {
394
			task = new XPlannerTask(repository.getUrl(), id, name, true);
440
			task = new XPlannerTask(repository.getUrl(), id, name);
395
			task.setKey(String.valueOf(data.getId()));
396
			task.setKind(data);
441
			task.setKind(data);
397
			TasksUiPlugin.getTaskListManager().getTaskList().addTask(task);
442
//HeB -- testing			
398
		}
443
//			TasksUiPlugin.getTaskListManager().getTaskList().addTask(task);
399
		
400
		RepositoryTaskData taskData = null;
401
		try {
402
			XPlannerServer server = XPlannerServerFacade.getDefault().getXPlannerServer(repository);
403
			taskData = XPlannerRepositoryUtils.createRepositoryTaskData(repository, task, server);
404
		} 
405
		catch (Throwable e) {
406
			e.printStackTrace();
407
		}
408
		if (taskData != null) {
409
			task.setTaskData(taskData);
410
		}
444
		}
411
445
412
		return task;
446
		return task;
Lines 419-449 Link Here
419
453
420
	@Override
454
	@Override
421
	public void updateAttributes(TaskRepository repository, IProgressMonitor monitor) throws CoreException {
455
	public void updateAttributes(TaskRepository repository, IProgressMonitor monitor) throws CoreException {
422
		XPlannerServerFacade.getDefault().refreshServerSettings(repository);
456
		XPlannerClientFacade.getDefault().refreshClientSettings(repository);
423
	}
457
	}
424
	
458
	
425
	public String getTaskWebUrl(String repositoryUrl, String taskId) {
459
	public String getTaskUrl(String repositoryUrl, String taskId) {
426
		String taskUrl = null;
460
		String taskUrl = null;
427
461
428
		TaskRepository repository = TasksUiPlugin.getRepositoryManager()
462
		TaskRepository repository = TasksUiPlugin.getRepositoryManager()
429
				.getRepository(XPlannerMylarUIPlugin.REPOSITORY_KIND, repositoryUrl);
463
				.getRepository(XPlannerMylynUIPlugin.REPOSITORY_KIND, repositoryUrl);
430
		try {
464
		try {
431
			XPlannerServer server = XPlannerServerFacade.getDefault().getXPlannerServer(repository);
465
			XPlannerClient client = XPlannerClientFacade.getDefault().getXPlannerClient(repository);
432
			if (server != null) {
466
			if (client != null) {
433
				TaskData taskData = server.getTask(Integer.valueOf(taskId).intValue());
467
				TaskData taskData = client.getTask(Integer.valueOf(taskId).intValue());
434
				// first check if taskdata exists
468
				// first check if taskdata exists
435
				if (taskData != null) {
469
				if (taskData != null) {
436
					if (taskData.getId() > 0) {
470
					if (taskData.getId() > 0) {
437
						taskUrl = repositoryUrl + XPlannerMylarUIPlugin.TASK_URL_PREFIX
471
						taskUrl = repositoryUrl + XPlannerMylynUIPlugin.TASK_URL_PREFIX
438
								+ taskData.getId();
472
								+ taskData.getId();
439
					}
473
					}
440
				}
474
				}
441
				else {
475
				else {
442
					// otherwise check if a user story exists
476
					// otherwise check if a user story exists
443
					UserStoryData userStory = server.getUserStory(Integer.valueOf(taskId)
477
					UserStoryData userStory = client.getUserStory(Integer.valueOf(taskId)
444
							.intValue());
478
							.intValue());
445
					if (userStory != null) {
479
					if (userStory != null) {
446
						taskUrl = repositoryUrl + XPlannerMylarUIPlugin.USER_STORY_URL_PREFIX + userStory.getId();
480
						taskUrl = repositoryUrl + XPlannerMylynUIPlugin.USER_STORY_URL_PREFIX + userStory.getId();
447
					}
481
					}
448
				}
482
				}
449
			}
483
			}
Lines 462-493 Link Here
462
			return null;
496
			return null;
463
		}
497
		}
464
		
498
		
465
		int index = url.indexOf(XPlannerMylarUIPlugin.DELIM_URL_SUFFIX);
499
		int index = url.indexOf(XPlannerMylynUIPlugin.DELIM_URL_SUFFIX);
466
		if (index != -1) {
500
		if (index != -1) {
467
			taskId = url.substring(index + XPlannerMylarUIPlugin.DELIM_URL_SUFFIX.length());
501
			taskId = url.substring(index + XPlannerMylynUIPlugin.DELIM_URL_SUFFIX.length());
468
		}
502
		}
469
		
503
		
470
		return taskId;
504
		return taskId;
471
	}
505
	}
472
	
506
	
473
	public Set<AbstractRepositoryTask> getChangedSinceLastSync(TaskRepository repository,
507
	public Set<AbstractTask> getChangedSinceLastSync(TaskRepository repository,
474
			Set<AbstractRepositoryTask> tasks) throws CoreException {
508
			Set<AbstractTask> tasks) throws CoreException {
475
	
509
	
476
		XPlannerServer server = XPlannerServerFacade.getDefault().getXPlannerServer(repository);
510
		XPlannerClient client = XPlannerClientFacade.getDefault().getXPlannerClient(repository);
477
		if (server == null) {
511
		if (client == null) {
478
			return Collections.emptySet();
512
			return Collections.emptySet();
479
		} 
513
		} 
480
		else {
514
		else {
481
			Set<AbstractRepositoryTask> changedTasks = new HashSet<AbstractRepositoryTask>();
515
			Set<AbstractTask> changedTasks = new HashSet<AbstractTask>();
482
			for (AbstractRepositoryTask task : tasks) {
516
			for (AbstractTask task : tasks) {
483
				if (task instanceof XPlannerTask) {
517
				if (task instanceof XPlannerTask) {
484
					XPlannerTask xplannerTask = (XPlannerTask) task;
518
					XPlannerTask xplannerTask = (XPlannerTask) task;
485
					TaskData taskData;
519
					TaskData taskData;
486
					try {
520
					try {
487
						taskData = server.getTask(Integer.valueOf(xplannerTask.getKey()).intValue());
521
						taskData = client.getTask(Integer.valueOf(xplannerTask.getTaskId()).intValue());
488
						if (taskData != null) {
522
						if (taskData != null) {
489
							Date lastUpdateTime = taskData.getLastUpdateTime().getTime();
523
							Date lastUpdateTime = taskData.getLastUpdateTime().getTime();
490
							String lastSynchStamp = xplannerTask.getLastSyncDateStamp();
524
							String lastSynchStamp = xplannerTask.getLastReadTimeStamp();
491
							Date lastSynchTime = null;
525
							Date lastSynchTime = null;
492
							if (lastSynchStamp != null && lastSynchStamp.length() > 0) {
526
							if (lastSynchStamp != null && lastSynchStamp.length() > 0) {
493
								lastSynchTime = XPlannerAttributeFactory.TIME_DATE_FORMAT.parse(lastSynchStamp);
527
								lastSynchTime = XPlannerAttributeFactory.TIME_DATE_FORMAT.parse(lastSynchStamp);
Lines 507-510 Link Here
507
		}
541
		}
508
	}
542
	}
509
543
544
	@Override
545
	public boolean markStaleTasks(TaskRepository repository,
546
		Set<AbstractTask> tasks, IProgressMonitor monitor) throws CoreException {
547
		
548
		boolean changed = false;
549
		
550
		try {
551
			monitor.beginTask("Getting changed tasks", IProgressMonitor.UNKNOWN);
552
			
553
			if (repository.getSynchronizationTimeStamp() == null) {
554
				for (AbstractTask task : tasks) {
555
					task.setStale(true);
556
				}
557
				changed = true;
558
			}
559
			else {
560
				Set<AbstractTask> changedTasks = getChangedSinceLastSync(repository, tasks);
561
				for (AbstractTask changedTask : changedTasks) {
562
					changedTask.setStale(true);
563
				}
564
	
565
				changed = true;
566
			}
567
		} 
568
		finally {
569
			monitor.done();
570
		}
571
		
572
		return changed;
573
	}
574
510
}
575
}
(-)src/org/eclipse/mylyn/xplanner/ui/messages.properties (-15 / +17 lines)
Lines 1-19 Link Here
1
MylarXPlannerPlugin_CLIENT_LABEL=XPlanner (supports 0.7 and later)
1
MylynXPlannerPlugin_CLIENT_LABEL=XPlanner (supports 0.7 and later)
2
MylarXPlannerPlugin_CLIENT_DIALOG_TITLE=Mylar XPlanner Client
2
MylynXPlannerPlugin_CLIENT_DIALOG_TITLE=Mylyn XPlanner Client
3
MylarXPlannerPlugin_NOT_AVAILABLE_IN_SKU=Mylar XPlanner plugin features are not available in this SKU
3
MylynXPlannerPlugin_NOT_AVAILABLE_IN_SKU=Mylyn XPlanner plugin features are not available in this SKU
4
MylarXPlannerPlugin_MYLAR_XPLANNER_ERROR_TITLE=Mylar XPlanner Error
4
MylynXPlannerPlugin_XPLANNER_ERROR_TITLE=Mylyn XPlanner Error
5
XPlannerServerFacade_SERVER_CONNECTION_ERROR=Error connecting to XPlanner Server
5
XPlannerClientFacade_SERVER_CONNECTION_ERROR=Error connecting to XPlanner Server
6
XPlannerServerFacade_CONNECTION_FAILURE_ERROR=XPlanner Connection Failure.\n\n
6
XPlannerClientFacade_CONNECTION_FAILURE_ERROR=XPlanner Connection Failure.\n\n
7
XPlannerServerFacade_INVALID_URL_EXCEPTION=Invalid url 
7
XPlannerClientFacade_INVALID_URL_EXCEPTION=Invalid url 
8
XPlannerServerFacade_NETWORK_CONNECTION_FAILURE=Please check your network connection and XPlanner server settings in the Task Repositories view.
8
XPlannerClientFacade_NETWORK_CONNECTION_FAILURE=Please check your network connection and XPlanner server settings in the Task Repositories view.
9
XPlannerRepositoryConnector_NEW_TASK_DESCRIPTION=New Task
9
XPlannerRepositoryConnector_NEW_TASK_DESCRIPTION=New Task
10
XPlannerRepositoryConnector_PerformQueryFailure=Mylar XPlanner query failure: {0}
10
XPlannerRepositoryConnector_PerformQueryFailure=Mylyn XPlanner query failure: {0}
11
XPlannerRepositoryConnector_ERROR_RETRIEVING_RESULTS=Error while retrieving results from: {0}
11
XPlannerRepositoryConnector_ERROR_RETRIEVING_RESULTS=Error while retrieving results from: {0}
12
XPlannerRepositoryConnector_COULD_NOT_CONVERT_TASK_DATE=Could not convert task date using format
12
XPlannerRepositoryConnector_ERROR_UPDATING_TASK=Error updating task
13
XPlannerRepositoryConnector_ERROR_UPDATING_TASK=Error updating task
13
XPlannerServerFacade_AUTHENTICATION_FAILED=XPlanner Authentication Failed.\n\n
14
XPlannerClientFacade_AUTHENTICATION_FAILED=XPlanner Authentication Failed.\n\n
14
XPlannerServerFacade_USERNAME_PASSWORD_ERROR=Please check your XPlanner username and password in the Task Repositories view
15
XPlannerClientFacade_USERNAME_PASSWORD_ERROR=Please check your XPlanner username and password in the Task Repositories view
15
XPlannerServerFacade_NO_REPOSITORY_FOUND=No XPlanner repository found.\n\n
16
XPlannerClientFacade_NO_REPOSITORY_FOUND=No XPlanner repository found.\n\n
16
XPlannerServerFacade_VERIFY_VALID_REPOSITORY=Please verify that a vaild XPlanner repository exists in the Task Repositories view
17
XPlannerClientFacade_VERIFY_VALID_REPOSITORY=Please verify that a vaild XPlanner repository exists in the Task Repositories view
17
XPlannerRepositoryConnector_VERSION_SUPPORT=0.7 and higher
18
XPlannerRepositoryConnector_VERSION_SUPPORT=0.7 and higher
18
XPlannerRepositoryConnector_ErrorDialogTitle=XPlanner Query Error
19
XPlannerRepositoryConnector_ErrorDialogTitle=XPlanner Query Error
19
XPlannerRepositoryUtils_TASK_DOWNLOAD_FAILED=Task download failed. Ensure proper repository configuration of {0} in {1}.
20
XPlannerRepositoryUtils_TASK_DOWNLOAD_FAILED=Task download failed. Ensure proper repository configuration of {0} in {1}.
Lines 21-28 Link Here
21
XPlannerRepositoryUtils_NO_PROJECT_NAME=<no project name>
22
XPlannerRepositoryUtils_NO_PROJECT_NAME=<no project name>
22
XPlannerRepositoryUtils_NO_ITERATION_NAME=<no iteration name>
23
XPlannerRepositoryUtils_NO_ITERATION_NAME=<no iteration name>
23
XPlannerRepositoryUtils_NO_USER_STORY_NAME=<no user story name>
24
XPlannerRepositoryUtils_NO_USER_STORY_NAME=<no user story name>
24
XPlannerServerFacade_COULD_NOT_CONNECT_TO_REPOSITORY=Could not connect to XPlanner repository.\n\n
25
XPlannerClientFacade_COULD_NOT_CONNECT_TO_REPOSITORY=Could not connect to XPlanner repository.\n\n
25
XPlannerTaskExternalizer_FAILED_TO_LOAD_HITS_EXCEPTION=Failed to load all hits
26
XPlannerTaskExternalizer_FAILED_TO_LOAD_HITS_EXCEPTION=Failed to load all hits
26
XPlannerTaskExternalizer_HANDLE_NOT_STORED_EXCEPTION=Handle not stored for task
27
XPlannerTaskExternalizer_HANDLE_NOT_STORED_EXCEPTION=Handle not stored for task
28
XPlannerOfflineTaskHandler_CANNOT_POST_DATA_TO_SERVER=Cannot post XPlanner task data to XPlanner server
27
XPlannerTaskExternalizer_DESCRIPTION_NOT_STORED_EXCEPTION=Description not stored for task
29
XPlannerTaskExternalizer_DESCRIPTION_NOT_STORED_EXCEPTION=Description not stored for task
28
XPlannerServerFacade_CHECK_CREDENTIALS=Please check your credentials in the Task Repositories view
30
XPlannerClientFacade_CHECK_CREDENTIALS=Please check your credentials in the Task Repositories view
(-)src/org/eclipse/mylyn/xplanner/ui/MylarXPlannerUtils.java (-34 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 - 2007 CodeGear 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
package org.eclipse.mylar.xplanner.ui;
9
10
import org.eclipse.mylar.tasks.core.TaskRepository;
11
import org.eclipse.mylar.tasks.ui.TasksUiPlugin;
12
import org.eclipse.mylar.xplanner.ui.wizard.NewXPlannerQueryWizard;
13
14
/**
15
 * @author Ravi Kumar
16
 * @author Helen Bershadskaya
17
 */
18
public class MylarXPlannerUtils {
19
	private MylarXPlannerUtils() {
20
		
21
	}
22
	
23
	public static void addNewMyTasksQuery(TaskRepository repository,
24
		String name) {
25
		
26
		XPlannerCustomQuery myTasksQuery = 
27
			new XPlannerCustomQuery(repository.getUrl(), name, 
28
				TasksUiPlugin.getTaskListManager().getTaskList());
29
		
30
		myTasksQuery.setMyCurrentTasks(true);
31
		NewXPlannerQueryWizard.addQuery(myTasksQuery, repository);
32
	}
33
			
34
}
(-)src/org/eclipse/mylyn/xplanner/ui/XPlannerImages.java (-4 / +4 lines)
Lines 5-18 Link Here
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
package org.eclipse.mylar.xplanner.ui;
8
package org.eclipse.mylyn.xplanner.ui;
9
9
10
import java.net.MalformedURLException;
10
import java.net.MalformedURLException;
11
import java.net.URL;
11
import java.net.URL;
12
12
13
import org.eclipse.jface.resource.ImageDescriptor;
13
import org.eclipse.jface.resource.ImageDescriptor;
14
import org.eclipse.jface.resource.ImageRegistry;
14
import org.eclipse.jface.resource.ImageRegistry;
15
import org.eclipse.mylar.internal.tasks.ui.TaskListImageDescriptor;
15
import org.eclipse.mylyn.internal.tasks.ui.TaskListImageDescriptor;
16
import org.eclipse.swt.graphics.Image;
16
import org.eclipse.swt.graphics.Image;
17
17
18
18
Lines 26-33 Link Here
26
26
27
	private static final String T_VIEW = "eview16"; //$NON-NLS-1$
27
	private static final String T_VIEW = "eview16"; //$NON-NLS-1$
28
28
29
	private static final URL baseURL = XPlannerMylarUIPlugin.getDefault() == null ? null :
29
	private static final URL baseURL = XPlannerMylynUIPlugin.getDefault() == null ? null :
30
		XPlannerMylarUIPlugin.getDefault().getBundle().getEntry("/icons/"); //$NON-NLS-1$ 
30
		XPlannerMylynUIPlugin.getDefault().getBundle().getEntry("/icons/"); //$NON-NLS-1$ 
31
31
32
	public static final ImageDescriptor OVERLAY_XPLANNER = create(T_VIEW, "overlay-xplanner.gif"); //$NON-NLS-1$
32
	public static final ImageDescriptor OVERLAY_XPLANNER = create(T_VIEW, "overlay-xplanner.gif"); //$NON-NLS-1$
33
	
33
	
(-)src/org/eclipse/mylyn/xplanner/ui/XPlannerQueryHit.java (-69 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 - 2007 CodeGear 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
package org.eclipse.mylar.xplanner.ui;
9
10
import org.eclipse.mylar.tasks.core.AbstractQueryHit;
11
import org.eclipse.mylar.tasks.core.AbstractRepositoryTask;
12
import org.eclipse.mylar.tasks.core.TaskList;
13
14
/**
15
 * Represents an XPlanner task returned as the result of a XPlanner query
16
 * 
17
 * @author Ravi Kumar 
18
 * @author Helen Bershadskaya 
19
 */
20
public class XPlannerQueryHit extends AbstractQueryHit {
21
22
	private XPlannerTask task = null;
23
24
	public XPlannerQueryHit(TaskList taskList, String description, String priority, 
25
			String repositoryUrl, String id, XPlannerTask task) {
26
		
27
		super(taskList, repositoryUrl, description, id);
28
		super.priority = priority;
29
		this.task = task;
30
	}
31
32
	@Override
33
	protected AbstractRepositoryTask createTask() {
34
		return task;  //TODO -- not sure if this is right, but corresponds to what we did before
35
	}
36
37
	/**
38
	 * @return null if there is no corresponding report
39
	 */
40
	public AbstractRepositoryTask getCorrespondingTask() {
41
		return task;
42
	}
43
44
	public void setCorrespondingTask(AbstractRepositoryTask task) {
45
		if (task instanceof XPlannerTask) {
46
			this.task = (XPlannerTask)task;
47
		}
48
	}
49
50
	public boolean isCompleted() {
51
		return task.isCompleted();
52
	}
53
54
	public String getPriority() {
55
		return task.getPriority();
56
	}
57
58
	public String getSummary() {
59
		return task.getSummary();
60
	}
61
62
	public void setDescription(String description) {
63
		task.setDescription(description);
64
	}
65
66
	public boolean isLocal() {
67
		return false;
68
	}
69
}
(-)src/org/eclipse/mylyn/xplanner/ui/XPlannerCustomQuery.java (-8 / +7 lines)
Lines 5-31 Link Here
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
package org.eclipse.mylar.xplanner.ui;
8
package org.eclipse.mylyn.xplanner.ui;
9
9
10
import java.util.Arrays;
10
import java.util.Arrays;
11
import java.util.List;
11
import java.util.List;
12
12
13
import org.eclipse.mylar.tasks.core.AbstractRepositoryQuery;
13
import org.eclipse.mylyn.tasks.core.AbstractRepositoryQuery;
14
import org.eclipse.mylar.tasks.core.TaskList;
15
14
16
15
17
16
18
/**
17
/**
19
 * An XPlannerCustomQuery represents a query for tasks or user stories from a XPlanner repository.
18
 * An XPlannerCustomQuery represents a query for tasks or user stories from a XPlanner repository.
20
 * 
19
 * 
21
 * @author Ravi Kumar 
20
 * @author Ravi Kumar  
22
 * @author Helen Bershadskaya 
21
 * @author Helen Bershadskaya 
23
 */
22
 */
24
public class XPlannerCustomQuery extends AbstractRepositoryQuery {
23
public class XPlannerCustomQuery extends AbstractRepositoryQuery {
25
24
26
	public static final int INVALID_ID = -1;
25
	public static final int INVALID_ID = -1;
27
	public static final List<Integer> INVALID_IDS = Arrays.asList(new Integer[] {INVALID_ID});
26
	public static final List<Integer> INVALID_IDS = Arrays.asList(new Integer[] {INVALID_ID});
28
	private static final int MAX_HITS = 75;
27
	//private static final int MAX_HITS = 75;
29
  public static enum ContentIdType {PROJECT, ITERATION, USER_STORY};  
28
  public static enum ContentIdType {PROJECT, ITERATION, USER_STORY};  
30
29
31
  private String queryName = null;
30
  private String queryName = null;
Lines 35-48 Link Here
35
  private boolean myCurrentTasks = false;
34
  private boolean myCurrentTasks = false;
36
  private ContentIdType contentIdType = ContentIdType.USER_STORY;  
35
  private ContentIdType contentIdType = ContentIdType.USER_STORY;  
37
    
36
    
38
	public XPlannerCustomQuery(String repositoryUrl, String queryName, TaskList taskList) {
37
	public XPlannerCustomQuery(String repositoryUrl, String queryName) {
39
		super(queryName, taskList);
38
		super(queryName);
40
		this.queryName = queryName;
39
		this.queryName = queryName;
41
		super.repositoryUrl = repositoryUrl;
40
		super.repositoryUrl = repositoryUrl;
42
	}
41
	}
43
42
44
	public String getRepositoryKind() {
43
	public String getRepositoryKind() {
45
		return XPlannerMylarUIPlugin.REPOSITORY_KIND;
44
		return XPlannerMylynUIPlugin.REPOSITORY_KIND;
46
	}
45
	}
47
	
46
	
48
	public String getQueryName() {
47
	public String getQueryName() {
(-)src/org/eclipse/mylyn/xplanner/ui/Messages.java (-16 / +20 lines)
Lines 5-11 Link Here
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
package org.eclipse.mylar.xplanner.ui;
8
package org.eclipse.mylyn.xplanner.ui;
9
9
10
import org.eclipse.osgi.util.NLS;
10
import org.eclipse.osgi.util.NLS;
11
11
Lines 14-28 Link Here
14
 * @author Helen Bershadskaya 
14
 * @author Helen Bershadskaya 
15
 */
15
 */
16
public class Messages extends NLS {
16
public class Messages extends NLS {
17
	private static final String BUNDLE_NAME = "org.eclipse.mylar.xplanner.ui.messages"; //$NON-NLS-1$
17
	private static final String BUNDLE_NAME = "org.eclipse.mylyn.xplanner.ui.messages"; //$NON-NLS-1$
18
18
19
	public static String MylarXPlannerPlugin_CLIENT_DIALOG_TITLE;
19
	public static String MylynXPlannerPlugin_CLIENT_DIALOG_TITLE;
20
20
21
	public static String MylarXPlannerPlugin_CLIENT_LABEL;
21
	public static String MylynXPlannerPlugin_CLIENT_LABEL;
22
22
23
	public static String MylarXPlannerPlugin_MYLAR_XPLANNER_ERROR_TITLE;
23
	public static String MylynXPlannerPlugin_XPLANNER_ERROR_TITLE;
24
24
25
	public static String MylarXPlannerPlugin_NOT_AVAILABLE_IN_SKU;
25
	public static String MylynXPlannerPlugin_NOT_AVAILABLE_IN_SKU;
26
27
	public static String XPlannerOfflineTaskHandler_CANNOT_POST_DATA_TO_SERVER;
28
29
	public static String XPlannerRepositoryConnector_COULD_NOT_CONVERT_TASK_DATE;
26
30
27
	public static String XPlannerRepositoryConnector_ERROR_RETRIEVING_RESULTS;
31
	public static String XPlannerRepositoryConnector_ERROR_RETRIEVING_RESULTS;
28
32
Lines 46-70 Link Here
46
50
47
	public static String XPlannerRepositoryUtils_TASK_DOWNLOAD_FAILED;
51
	public static String XPlannerRepositoryUtils_TASK_DOWNLOAD_FAILED;
48
52
49
	public static String XPlannerServerFacade_AUTHENTICATION_FAILED;
53
	public static String XPlannerClientFacade_AUTHENTICATION_FAILED;
50
54
51
	public static String XPlannerServerFacade_CHECK_CREDENTIALS;
55
	public static String XPlannerClientFacade_CHECK_CREDENTIALS;
52
56
53
	public static String XPlannerServerFacade_CONNECTION_FAILURE_ERROR;
57
	public static String XPlannerClientFacade_CONNECTION_FAILURE_ERROR;
54
58
55
	public static String XPlannerServerFacade_COULD_NOT_CONNECT_TO_REPOSITORY;
59
	public static String XPlannerClientFacade_COULD_NOT_CONNECT_TO_REPOSITORY;
56
60
57
	public static String XPlannerServerFacade_INVALID_URL_EXCEPTION;
61
	public static String XPlannerClientFacade_INVALID_URL_EXCEPTION;
58
62
59
	public static String XPlannerServerFacade_NETWORK_CONNECTION_FAILURE;
63
	public static String XPlannerClientFacade_NETWORK_CONNECTION_FAILURE;
60
64
61
	public static String XPlannerServerFacade_NO_REPOSITORY_FOUND;
65
	public static String XPlannerClientFacade_NO_REPOSITORY_FOUND;
62
66
63
	public static String XPlannerServerFacade_SERVER_CONNECTION_ERROR;
67
	public static String XPlannerClientFacade_SERVER_CONNECTION_ERROR;
64
68
65
	public static String XPlannerServerFacade_USERNAME_PASSWORD_ERROR;
69
	public static String XPlannerClientFacade_USERNAME_PASSWORD_ERROR;
66
70
67
	public static String XPlannerServerFacade_VERIFY_VALID_REPOSITORY;
71
	public static String XPlannerClientFacade_VERIFY_VALID_REPOSITORY;
68
72
69
	public static String XPlannerTaskExternalizer_DESCRIPTION_NOT_STORED_EXCEPTION;
73
	public static String XPlannerTaskExternalizer_DESCRIPTION_NOT_STORED_EXCEPTION;
70
74
(-)src/org/eclipse/mylyn/xplanner/ui/XPlannerTask.java (-26 / +33 lines)
Lines 5-24 Link Here
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
package org.eclipse.mylar.xplanner.ui;
8
package org.eclipse.mylyn.xplanner.ui;
9
9
10
import org.eclipse.mylar.tasks.core.AbstractRepositoryTask;
10
import org.eclipse.mylyn.tasks.core.AbstractTask;
11
import org.eclipse.mylar.tasks.core.RepositoryTaskAttribute;
11
import org.eclipse.mylyn.xplanner.wsdl.soap.domain.DomainData;
12
import org.xplanner.soap.IterationData;
12
import org.xplanner.soap.IterationData;
13
import org.xplanner.soap.UserStoryData;
13
import org.xplanner.soap.UserStoryData;
14
14
15
import org.eclipse.mylar.xplanner.wsdl.soap.domain.DomainData;
16
17
/**
15
/**
18
 * @author Ravi Kumar 
16
 * @author Ravi Kumar 
19
 * @author Helen Bershadskaya 
17
 * @author Helen Bershadskaya 
20
 */
18
 */
21
public class XPlannerTask extends AbstractRepositoryTask {
19
public class XPlannerTask extends AbstractTask {
22
20
23
	private String key = null;
21
	private String key = null;
24
22
Lines 38-43 Link Here
38
				return ""; //$NON-NLS-1$
36
				return ""; //$NON-NLS-1$
39
			}
37
			}
40
		}
38
		}
39
		
40
		public static Kind fromString(String kindValue) {
41
			Kind kind = null;
42
		
43
			if (kindValue == null) {
44
				kind = null;
45
			}
46
			else if (kindValue.equals(TASK.toString())) {
47
				kind = TASK;
48
			}
49
			else if (kindValue.equals(USER_STORY.toString())) {
50
				kind = USER_STORY;
51
			}
52
			else if (kindValue.equals(ITERATION.toString())) {
53
				kind = ITERATION;
54
			}
55
			
56
			return kind;
57
		}
58
41
	}
59
	}
42
60
43
	public void setKind(DomainData data) {
61
	public void setKind(DomainData data) {
Lines 50-69 Link Here
50
			tempKind = Kind.USER_STORY.toString();
68
			tempKind = Kind.USER_STORY.toString();
51
		}
69
		}
52
		
70
		
53
		setKind(tempKind);
71
		setTaskKind(tempKind);
54
	}
72
	}
55
	
73
	
56
	/**
74
	/**
57
	 * The handle is also the task's XPlanner url
75
	 * The handle is also the task's XPlanner url
58
	 */
76
	 */
59
	public XPlannerTask(String repositoryUrl, String id, String label, boolean newTask) {
77
	public XPlannerTask(String repositoryUrl, String id, String label) {
60
		super(repositoryUrl, id, label, newTask);
78
		super(repositoryUrl, id, label);
61
	}
79
	}
62
80
63
	public String getRepositoryKind() {
81
	public String getConnectorKind() {
64
		return XPlannerMylarUIPlugin.REPOSITORY_KIND;
82
		return XPlannerMylynUIPlugin.REPOSITORY_KIND;
65
	}
83
	}
66
84
85
	public boolean isLocal() {
86
		return false;
87
	}
88
	
67
	public String getKey() {
89
	public String getKey() {
68
		return key;
90
		return key;
69
	}
91
	}
Lines 71-89 Link Here
71
	public void setKey(String key) {
93
	public void setKey(String key) {
72
		this.key = key;
94
		this.key = key;
73
	}
95
	}
74
	
75
	@Override
76
	public String getPriority() {
77
		String priority;
78
		
79
		if (taskData != null && taskData.getAttribute(RepositoryTaskAttribute.PRIORITY) != null) {
80
			priority = taskData.getAttributeValue(RepositoryTaskAttribute.PRIORITY);
81
		} 
82
		else {
83
			priority = super.getPriority();
84
		}
85
		
86
		return priority;
87
	}
88
89
}
96
}
(-)src/org/eclipse/mylyn/xplanner/ui/XPlannerTaskDecorator.java (-12 / +6 lines)
Lines 5-38 Link Here
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
package org.eclipse.mylar.xplanner.ui;
8
package org.eclipse.mylyn.xplanner.ui;
9
9
10
import org.eclipse.jface.viewers.IDecoration;
10
import org.eclipse.jface.viewers.IDecoration;
11
import org.eclipse.jface.viewers.ILabelProviderListener;
11
import org.eclipse.jface.viewers.ILabelProviderListener;
12
import org.eclipse.jface.viewers.ILightweightLabelDecorator;
13
12
14
13
15
/**
14
/**
16
 * @author Ravi Kumar 
15
 * @author Ravi Kumar 
17
 * @author Helen Bershadskaya
16
 * @author Helen Bershadskaya
18
 */
17
 */
19
public class XPlannerTaskDecorator implements ILightweightLabelDecorator {
18
//HeB -- testing
19
public class XPlannerTaskDecorator {
20
20
21
	public void decorate(Object element, IDecoration decoration) {
21
	public void decorate(Object element, IDecoration decoration) {
22
		if (element instanceof XPlannerQueryHit) {
23
			XPlannerQueryHit hit = (XPlannerQueryHit) element;
24
			if (hit.getCorrespondingTask() != null) {
25
				decorate(hit.getCorrespondingTask(), decoration);
26
			}
27
		}
28
		if (element instanceof XPlannerTask) {
22
		if (element instanceof XPlannerTask) {
29
			XPlannerTask task = (XPlannerTask) element;
23
			XPlannerTask task = (XPlannerTask) element;
30
			if (XPlannerTask.Kind.ITERATION.toString().equals(task.getTaskKind())) {
24
			if (XPlannerTask.Kind.ITERATION.toString().equals(task.getTaskKind())) {
31
				decoration.addOverlay(XPlannerImages.OVERLAY_ITERATION, IDecoration.BOTTOM_RIGHT);
25
				decoration.addOverlay(XPlannerImages.OVERLAY_ITERATION);
32
			} else if (XPlannerTask.Kind.USER_STORY.toString().equals(task.getTaskKind())) {
26
			} else if (XPlannerTask.Kind.USER_STORY.toString().equals(task.getTaskKind())) {
33
				decoration.addOverlay(XPlannerImages.OVERLAY_USER_STORY, IDecoration.BOTTOM_RIGHT);
27
				decoration.addOverlay(XPlannerImages.OVERLAY_USER_STORY);
34
			} else if (XPlannerTask.Kind.TASK.toString().equals(task.getTaskKind())) {
28
			} else if (XPlannerTask.Kind.TASK.toString().equals(task.getTaskKind())) {
35
				decoration.addOverlay(XPlannerImages.OVERLAY_TASK, IDecoration.BOTTOM_RIGHT);
29
				decoration.addOverlay(XPlannerImages.OVERLAY_TASK);
36
			}
30
			}
37
		}
31
		}
38
	}
32
	}
(-)src/org/eclipse/mylyn/xplanner/ui/XPlannerRepositoryUi.java (-18 / +59 lines)
Lines 5-24 Link Here
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
package org.eclipse.mylar.xplanner.ui;
8
package org.eclipse.mylyn.xplanner.ui;
9
9
10
import java.util.ArrayList;
11
import java.util.List;
12
13
import org.eclipse.jface.resource.ImageDescriptor;
10
import org.eclipse.jface.viewers.IStructuredSelection;
14
import org.eclipse.jface.viewers.IStructuredSelection;
11
import org.eclipse.jface.wizard.IWizard;
15
import org.eclipse.jface.wizard.IWizard;
12
import org.eclipse.jface.wizard.WizardPage;
16
import org.eclipse.jface.wizard.WizardPage;
13
import org.eclipse.mylar.tasks.core.AbstractRepositoryQuery;
17
import org.eclipse.mylyn.tasks.core.*;
14
import org.eclipse.mylar.tasks.core.TaskRepository;
18
import org.eclipse.mylyn.tasks.ui.AbstractRepositoryConnectorUi;
15
import org.eclipse.mylar.tasks.ui.AbstractRepositoryConnectorUi;
19
import org.eclipse.mylyn.tasks.ui.wizards.AbstractRepositorySettingsPage;
16
import org.eclipse.mylar.tasks.ui.wizards.AbstractRepositorySettingsPage;
20
import org.eclipse.mylyn.tasks.ui.wizards.NewWebTaskWizard;
17
import org.eclipse.mylar.tasks.ui.wizards.NewWebTaskWizard;
21
import org.eclipse.mylyn.xplanner.ui.wizard.*;
18
import org.eclipse.mylar.xplanner.ui.wizard.EditXPlannerQueryWizard;
19
import org.eclipse.mylar.xplanner.ui.wizard.NewXPlannerQueryWizard;
20
import org.eclipse.mylar.xplanner.ui.wizard.XPlannerCustomQueryPage;
21
import org.eclipse.mylar.xplanner.ui.wizard.XPlannerRepositorySettingsPage;
22
22
23
/**
23
/**
24
 * @author Ravi Kumar 
24
 * @author Ravi Kumar 
Lines 31-36 Link Here
31
	}
31
	}
32
32
33
	@Override
33
	@Override
34
	public ImageDescriptor getTaskKindOverlay(AbstractTask task) {
35
		ImageDescriptor overlayImage;
36
		
37
		XPlannerTask.Kind kind = XPlannerTask.Kind.fromString(task.getTaskKind());
38
		if (kind.equals(XPlannerTask.Kind.TASK)) {
39
			overlayImage = XPlannerImages.OVERLAY_TASK;
40
		}
41
		else if (kind.equals(XPlannerTask.Kind.USER_STORY)) {
42
			overlayImage = XPlannerImages.OVERLAY_USER_STORY;
43
		}
44
		else if (kind.equals(XPlannerTask.Kind.ITERATION)) {
45
			overlayImage = XPlannerImages.OVERLAY_ITERATION;
46
		}
47
		else {
48
			overlayImage = super.getTaskKindOverlay(task);
49
		}
50
		
51
		return overlayImage;
52
	}
53
54
	@Override
34
	public WizardPage getSearchPage(TaskRepository repository, IStructuredSelection selection) {
55
	public WizardPage getSearchPage(TaskRepository repository, IStructuredSelection selection) {
35
		return new XPlannerCustomQueryPage(repository, null);
56
		return new XPlannerCustomQueryPage(repository, null);
36
	} 
57
	} 
Lines 66-72 Link Here
66
//				}
87
//				}
67
//			}
88
//			}
68
//		} catch (Exception e) {
89
//		} catch (Exception e) {
69
//			MylarStatusHandler.fail(e, e.getMessage(), true);
90
//			MylynStatusHandler.fail(e, e.getMessage(), true);
70
//		}
91
//		}
71
//	
92
//	
72
//	}
93
//	}
Lines 78-90 Link Here
78
	}
99
	}
79
100
80
	@Override
101
	@Override
81
	public boolean hasRichEditor() {
102
	public String getConnectorKind() {
82
		return true;
103
		return XPlannerMylynUIPlugin.REPOSITORY_KIND;
83
	}
84
85
	@Override
86
	public String getRepositoryType() {
87
		return XPlannerMylarUIPlugin.REPOSITORY_KIND;
88
	}
104
	}
89
105
90
	@Override
106
	@Override
Lines 92-95 Link Here
92
		return true;
108
		return true;
93
	}
109
	}
94
	
110
	
111
	@Override
112
	public String getTaskKindLabel(AbstractTask repositoryTask) {
113
		return repositoryTask == null ? super.getTaskKindLabel(repositoryTask) :
114
			repositoryTask.getTaskKind();
115
	}
116
	
117
	@Override
118
	public List<AbstractTaskContainer> getLegendItems() {
119
		List<AbstractTaskContainer> legendItems = new ArrayList<AbstractTaskContainer>();
120
		
121
		XPlannerTask task = new XPlannerTask("", XPlannerTask.Kind.TASK.name(), XPlannerTask.Kind.TASK.toString());
122
		task.setTaskKind(XPlannerTask.Kind.TASK.toString());		
123
		legendItems.add(task);
124
125
		XPlannerTask userStory = new XPlannerTask("", XPlannerTask.Kind.USER_STORY.name(), XPlannerTask.Kind.USER_STORY.toString());
126
		userStory.setTaskKind(XPlannerTask.Kind.USER_STORY.toString());		
127
		legendItems.add(userStory);
128
129
		XPlannerTask iteration = new XPlannerTask("", XPlannerTask.Kind.ITERATION.name(), XPlannerTask.Kind.ITERATION.toString());
130
		iteration.setTaskKind(XPlannerTask.Kind.ITERATION.toString());		
131
		legendItems.add(iteration);
132
133
		return legendItems;
134
	}
135
95
}
136
}
(-)src/org/eclipse/mylyn/xplanner/ui/XPlannerMylarUIPlugin.java (-99 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 - 2007 CodeGear 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
package org.eclipse.mylar.xplanner.ui;
9
10
import org.eclipse.core.runtime.IStatus;
11
import org.eclipse.core.runtime.Platform;
12
import org.eclipse.core.runtime.Status;
13
import org.eclipse.jface.dialogs.MessageDialog;
14
import org.eclipse.jface.resource.ImageDescriptor;
15
import org.eclipse.mylar.core.MylarStatusHandler;
16
import org.eclipse.swt.widgets.Shell;
17
import org.eclipse.ui.PlatformUI;
18
import org.eclipse.ui.plugin.AbstractUIPlugin;
19
import org.osgi.framework.BundleContext;
20
21
/**
22
 * @author Ravi Kumar 
23
 * @author Helen Bershadskaya 
24
 */
25
public class XPlannerMylarUIPlugin extends AbstractUIPlugin {
26
27
	private static XPlannerMylarUIPlugin INSTANCE;
28
29
	public static final String PLUGIN_ID = "org.eclipse.mylar.xplanner.ui"; //$NON-NLS-1$
30
31
	public final static String REPOSITORY_KIND = "xplanner"; //$NON-NLS-1$
32
33
	public final static String XPLANNER_CLIENT_LABEL = Messages.MylarXPlannerPlugin_CLIENT_LABEL;
34
35
	public final static String TITLE_MESSAGE_DIALOG = Messages.MylarXPlannerPlugin_CLIENT_DIALOG_TITLE;
36
37
	public static final String DELIM_URL_PREFIX = "/do/view/"; //$NON-NLS-1$
38
39
	public final static String DELIM_URL_SUFFIX = "?oid="; //$NON-NLS-1$
40
41
	public final static String TASK_URL_PREFIX = DELIM_URL_PREFIX + "task" + DELIM_URL_SUFFIX; //$NON-NLS-1$
42
43
	public final static String USER_STORY_URL_PREFIX = DELIM_URL_PREFIX + "userstory" + DELIM_URL_SUFFIX; //$NON-NLS-1$
44
45
	public final static String ITERATION_URL_PREFIX = DELIM_URL_PREFIX + "iteration" + DELIM_URL_SUFFIX; //$NON-NLS-1$
46
47
	public final static IStatus NO_LICENSE_STATUS = new Status(IStatus.INFO, XPlannerMylarUIPlugin.PLUGIN_ID,
48
			0, Messages.MylarXPlannerPlugin_NOT_AVAILABLE_IN_SKU, null);
49
50
	public XPlannerMylarUIPlugin() {
51
		INSTANCE = this;
52
	}
53
54
	public void stop(BundleContext context) throws Exception {
55
		super.stop(context);
56
		INSTANCE = null;
57
		XPlannerServerFacade.getDefault().logOutFromAll();
58
	}
59
60
	public static void log(final Throwable e, final String message, boolean informUser) {
61
		if (Platform.isRunning() && informUser) {
62
			try {
63
				PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
64
					public void run() {
65
						Shell shell = null;
66
						if (PlatformUI.getWorkbench() != null
67
								&& PlatformUI.getWorkbench().getActiveWorkbenchWindow() != null) {
68
							shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
69
						}
70
						String displayMessage = message == null ? e.getMessage() : message + "\n" + e.getMessage(); //$NON-NLS-1$
71
						MessageDialog.openError(shell, Messages.MylarXPlannerPlugin_MYLAR_XPLANNER_ERROR_TITLE, displayMessage); 
72
					}
73
				});
74
			} 
75
			catch (Throwable t) {
76
				t.printStackTrace();
77
			}
78
		}
79
		else {
80
			MylarStatusHandler.log(e, message == null ? Messages.MylarXPlannerPlugin_MYLAR_XPLANNER_ERROR_TITLE : message);
81
		}
82
	}
83
84
	public static XPlannerMylarUIPlugin getDefault() {
85
		return INSTANCE;
86
	}
87
88
	/**
89
	 * Returns an image descriptor for the image file at the given plug-in
90
	 * relative path.
91
	 * 
92
	 * @param path
93
	 *            the path
94
	 * @return the image descriptor
95
	 */
96
	public static ImageDescriptor getImageDescriptor(String path) {
97
		return AbstractUIPlugin.imageDescriptorFromPlugin(PLUGIN_ID, path);
98
	}
99
}
(-)src/org/eclipse/mylyn/xplanner/ui/XPlannerOfflineTaskHandler.java (-147 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 - 2007 CodeGear 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
package org.eclipse.mylar.xplanner.ui;
9
10
import java.net.Proxy;
11
import java.rmi.RemoteException;
12
13
import javax.security.auth.login.LoginException;
14
15
import org.eclipse.core.runtime.CoreException;
16
import org.eclipse.core.runtime.IProgressMonitor;
17
import org.eclipse.core.runtime.Status;
18
import org.eclipse.mylar.tasks.core.AbstractAttributeFactory;
19
import org.eclipse.mylar.tasks.core.AbstractRepositoryConnector;
20
import org.eclipse.mylar.tasks.core.AbstractRepositoryTask;
21
import org.eclipse.mylar.tasks.core.ITask;
22
import org.eclipse.mylar.tasks.core.ITaskDataHandler;
23
import org.eclipse.mylar.tasks.core.RepositoryTaskData;
24
import org.eclipse.mylar.tasks.core.TaskList;
25
import org.eclipse.mylar.tasks.core.TaskRepository;
26
import org.eclipse.mylar.tasks.ui.TasksUiPlugin;
27
import org.eclipse.mylar.xplanner.core.XPlannerCorePlugin;
28
import org.eclipse.mylar.xplanner.core.service.XPlannerServer;
29
import org.xplanner.soap.TaskData;
30
import org.xplanner.soap.UserStoryData;
31
32
/**
33
 * @author Ravi Kumar
34
 * @author Helen Bershadskaya
35
 */
36
public class XPlannerOfflineTaskHandler implements ITaskDataHandler {
37
	private AbstractAttributeFactory attributeFactory = new XPlannerAttributeFactory();
38
	
39
	public XPlannerOfflineTaskHandler(TaskList taskList) {
40
		//TODO -- tasklist?
41
	}
42
	
43
	public RepositoryTaskData downloadTaskData(AbstractRepositoryTask repositoryTask, TaskRepository repository, Proxy proxySettings) 
44
		throws CoreException, LoginException {
45
		
46
		if (!(repositoryTask instanceof XPlannerTask)) {
47
			return null;
48
		}
49
		
50
		RepositoryTaskData repositoryTaskData = null;
51
		XPlannerTask xplannerTask = (XPlannerTask)repositoryTask;
52
		
53
		XPlannerServer server = XPlannerServerFacade.getDefault().getXPlannerServer(repository);
54
		repositoryTaskData = XPlannerRepositoryUtils.createRepositoryTaskData(repository, xplannerTask, server); 
55
		
56
		return repositoryTaskData;
57
	}
58
59
	public boolean initializeTaskData(TaskRepository repository, RepositoryTaskData data, IProgressMonitor monitor)
60
		throws CoreException {
61
		
62
		// currently don't create new tasks
63
		return false;
64
	}
65
66
	public AbstractAttributeFactory getAttributeFactory(String repositoryUrl, String repositoryKind, String taskKind) {
67
		return attributeFactory;
68
	}
69
	
70
	public String postTaskData(TaskRepository repository, final RepositoryTaskData repositoryTaskData) throws CoreException {
71
		String resultId = null;
72
		
73
		try {
74
			resultId = postChangesToRepository(repositoryTaskData);
75
		} 
76
		catch (Exception e) {
77
			throw new CoreException(new Status(Status.ERROR,
78
					XPlannerCorePlugin.ID, Status.ERROR, "Cannot post XPlanner task data to XPlanner server", null));
79
		}
80
		
81
		return resultId;
82
	}
83
84
	private String postChangesToRepository(RepositoryTaskData repositoryTaskData) throws CoreException {
85
		String error = null;
86
		
87
		TaskRepository repository = TasksUiPlugin.getRepositoryManager().getRepository(
88
				repositoryTaskData.getRepositoryKind(), repositoryTaskData.getRepositoryUrl());
89
		
90
		XPlannerServer server = XPlannerServerFacade.getDefault().getXPlannerServer(repository);
91
		if (server != null) {
92
			try {
93
				// first check if taskdata exists
94
				TaskData taskData = server.getTask(Integer.valueOf(repositoryTaskData.getId()).intValue());
95
				if (taskData != null) {
96
					taskData.setName(repositoryTaskData.getSummary());
97
					taskData.setDescription(XPlannerRepositoryUtils.getDescription(repositoryTaskData));
98
					taskData.setEstimatedHours(Double.valueOf(
99
							repositoryTaskData.getAttribute(XPlannerAttributeFactory.ATTRIBUTE_EST_HOURS_NAME).getValue()));
100
					taskData.setCompleted(XPlannerRepositoryUtils.isCompleted(repositoryTaskData));
101
					server.update(taskData);
102
				}
103
				else {
104
					// otherwise check if a user story exists
105
					UserStoryData userStory = server.getUserStory(Integer.valueOf(repositoryTaskData.getId()).intValue());
106
					if (userStory != null) {
107
						userStory.setName(repositoryTaskData.getSummary());
108
						userStory.setDescription(XPlannerRepositoryUtils.getDescription(repositoryTaskData));
109
						userStory.setActualHours(Double.valueOf(
110
								repositoryTaskData.getAttribute(XPlannerAttributeFactory.ATTRIBUTE_ACT_HOURS_NAME).getValue()));
111
						server.update(userStory);
112
					}
113
				}
114
			} 
115
			catch (NumberFormatException e) {
116
				XPlannerMylarUIPlugin.log(e.getCause(), "", false);
117
				error = e.getMessage();
118
			} 
119
			catch (RemoteException e) {
120
				XPlannerMylarUIPlugin.log(e.getCause(), "", false);
121
				error = e.getMessage();
122
			}
123
		}
124
		
125
		return error;
126
	}
127
128
	public RepositoryTaskData getTaskData(TaskRepository repository, String taskId) throws CoreException {
129
		RepositoryTaskData repositoryTaskData = null;
130
		
131
		XPlannerServer server = XPlannerServerFacade.getDefault().getXPlannerServer(repository);
132
		ITask existingTask = TasksUiPlugin.getTaskListManager().getTaskList().getTask(repository.getUrl(), taskId);
133
		if (existingTask instanceof XPlannerTask) {
134
			repositoryTaskData = XPlannerRepositoryUtils.createRepositoryTaskData(repository, 
135
				(XPlannerTask)existingTask, server);
136
		}
137
		else {
138
			AbstractRepositoryConnector connector = TasksUiPlugin.getRepositoryManager().getRepositoryConnector(
139
					repository.getKind());
140
			ITask newTask = connector.createTaskFromExistingKey(repository, taskId);
141
			repositoryTaskData = XPlannerRepositoryUtils.createRepositoryTaskData(repository, 
142
					(XPlannerTask)newTask, server);
143
		}
144
		return repositoryTaskData;
145
	}
146
	
147
}
(-)src/org/eclipse/mylyn/xplanner/ui/editor/XPlannerUserStoryEditor.java (-54 / +27 lines)
Lines 5-11 Link Here
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
package org.eclipse.mylar.xplanner.ui.editor;
8
package org.eclipse.mylyn.xplanner.ui.editor;
9
9
10
import java.rmi.RemoteException;
10
import java.rmi.RemoteException;
11
import java.text.MessageFormat;
11
import java.text.MessageFormat;
Lines 15-50 Link Here
15
import org.eclipse.core.runtime.IProgressMonitor;
15
import org.eclipse.core.runtime.IProgressMonitor;
16
import org.eclipse.jface.layout.GridDataFactory;
16
import org.eclipse.jface.layout.GridDataFactory;
17
import org.eclipse.jface.resource.JFaceResources;
17
import org.eclipse.jface.resource.JFaceResources;
18
import org.eclipse.mylar.core.MylarStatusHandler;
18
import org.eclipse.mylyn.monitor.core.StatusHandler;
19
import org.eclipse.mylar.tasks.core.TaskRepository;
19
import org.eclipse.mylyn.tasks.core.RepositoryTaskData;
20
import org.eclipse.mylar.tasks.ui.TasksUiPlugin;
20
import org.eclipse.mylyn.tasks.core.TaskRepository;
21
import org.eclipse.mylar.tasks.ui.editors.RepositoryTaskEditorInput;
21
import org.eclipse.mylyn.tasks.ui.TasksUiPlugin;
22
import org.eclipse.mylar.xplanner.core.service.XPlannerServer;
22
import org.eclipse.mylyn.tasks.ui.editors.RepositoryTaskEditorInput;
23
import org.eclipse.mylar.xplanner.ui.XPlannerAttributeFactory;
23
import org.eclipse.mylyn.xplanner.core.service.XPlannerClient;
24
import org.eclipse.mylar.xplanner.ui.XPlannerMylarUIPlugin;
24
import org.eclipse.mylyn.xplanner.ui.*;
25
import org.eclipse.mylar.xplanner.ui.XPlannerServerFacade;
26
import org.eclipse.mylar.xplanner.ui.XPlannerTask;
27
import org.eclipse.swt.SWT;
25
import org.eclipse.swt.SWT;
28
import org.eclipse.swt.layout.GridLayout;
26
import org.eclipse.swt.layout.GridLayout;
29
import org.eclipse.swt.widgets.Button;
27
import org.eclipse.swt.widgets.*;
30
import org.eclipse.swt.widgets.Composite;
31
import org.eclipse.swt.widgets.Label;
32
import org.eclipse.swt.widgets.Text;
33
import org.eclipse.swt.widgets.Tree;
34
import org.eclipse.swt.widgets.TreeItem;
35
import org.eclipse.ui.IEditorInput;
28
import org.eclipse.ui.IEditorInput;
36
import org.eclipse.ui.IEditorSite;
29
import org.eclipse.ui.IEditorSite;
37
import org.eclipse.ui.forms.IManagedForm;
30
import org.eclipse.ui.forms.IManagedForm;
38
import org.eclipse.ui.forms.editor.FormEditor;
31
import org.eclipse.ui.forms.editor.FormEditor;
39
import org.eclipse.ui.forms.editor.FormPage;
32
import org.eclipse.ui.forms.editor.FormPage;
40
import org.eclipse.ui.forms.widgets.ExpandableComposite;
33
import org.eclipse.ui.forms.widgets.*;
41
import org.eclipse.ui.forms.widgets.FormToolkit;
34
import org.xplanner.soap.*;
42
import org.eclipse.ui.forms.widgets.ScrolledForm;
43
import org.eclipse.ui.forms.widgets.Section;
44
import org.xplanner.soap.IterationData;
45
import org.xplanner.soap.PersonData;
46
import org.xplanner.soap.ProjectData;
47
import org.xplanner.soap.UserStoryData;
48
35
49
/**
36
/**
50
 * @author Ravi Kumar
37
 * @author Ravi Kumar
Lines 60-66 Link Here
60
47
61
	private boolean isDirty = false;
48
	private boolean isDirty = false;
62
49
63
	private XPlannerServer server;
50
	private XPlannerClient client;
64
51
65
	private UserStoryData userStoryData;
52
	private UserStoryData userStoryData;
66
53
Lines 86-92 Link Here
86
		}
73
		}
87
		
74
		
88
		RepositoryTaskEditorInput  repositoryInput = (RepositoryTaskEditorInput) input;
75
		RepositoryTaskEditorInput  repositoryInput = (RepositoryTaskEditorInput) input;
89
		if (!XPlannerMylarUIPlugin.REPOSITORY_KIND.equals(repositoryInput.getRepository().getKind())) {
76
		if (!XPlannerMylynUIPlugin.REPOSITORY_KIND.equals(repositoryInput.getRepository().getConnectorKind())) {
90
			return;
77
			return;
91
		}
78
		}
92
		
79
		
Lines 94-121 Link Here
94
		setSite(site);
81
		setSite(site);
95
		setInput(input);
82
		setInput(input);
96
		setPartName(this.input.getName());
83
		setPartName(this.input.getName());
97
		XPlannerTask task = (XPlannerTask) repositoryInput.getRepositoryTask();
84
		RepositoryTaskData taskData = repositoryInput.getTaskData();
98
		TaskRepository repository = TasksUiPlugin.getRepositoryManager().getRepository(task.getRepositoryKind(),
85
		TaskRepository repository = TasksUiPlugin.getRepositoryManager().getRepository(taskData.getRepositoryKind(),
99
				task.getRepositoryUrl());
86
				taskData.getRepositoryUrl());
100
		try {
87
		try {
101
			server = XPlannerServerFacade.getDefault().getXPlannerServer(repository);
88
			client = XPlannerClientFacade.getDefault().getXPlannerClient(repository);
102
			String key = task.getKey();
89
			String id = taskData.getId();
103
			if (key == null || key.trim().equals("")) {  //$NON-NLS-1$
90
			if (id == null || id.trim().equals("")) {  //$NON-NLS-1$
104
				MylarStatusHandler.log(Messages.XPlannerTaskEditor_NO_TASK_KEY_EXCEPTION,
91
				StatusHandler.log(Messages.XPlannerTaskEditor_NO_TASK_KEY_EXCEPTION,
105
					null);
92
					null);
106
			} 
93
			} 
107
			else {
94
			else {
108
				setUserStoryData(key);
95
				setUserStoryData(id);
109
			}
96
			}
110
		}
97
		}
111
		catch (CoreException e) {
98
		catch (CoreException e) {
112
			MylarStatusHandler.log(e,	null);
99
			StatusHandler.log(e,	null);
113
		}
100
		}
114
	}
101
	}
115
102
116
	public void setUserStoryData(String key) {
103
	public void setUserStoryData(String key) {
117
		try {
104
		try {
118
			this.userStoryData = server.getUserStory(Integer.valueOf(key).intValue());
105
			this.userStoryData = client.getUserStory(Integer.valueOf(key).intValue());
119
		} 
106
		} 
120
		catch (NumberFormatException e) {
107
		catch (NumberFormatException e) {
121
			e.printStackTrace();
108
			e.printStackTrace();
Lines 129-148 Link Here
129
		return this.userStoryData;
116
		return this.userStoryData;
130
	}
117
	}
131
	
118
	
132
	public UserStoryData getUserStoryData(XPlannerTask task) throws Exception {
133
		UserStoryData userStoryDataFromTask = null;
134
		
135
		String key = task.getKey();
136
		if (key == null || key.trim().equals("")) {  //$NON-NLS-1$
137
			throw new Exception(Messages.XPlannerTaskEditor_NO_TASK_KEY_EXCEPTION);
138
		} 
139
		else {
140
			userStoryDataFromTask = server.getUserStory(Integer.valueOf(key).intValue());
141
		}
142
		
143
		return userStoryDataFromTask;
144
	}
145
146
	public boolean isDirty() {
119
	public boolean isDirty() {
147
		return isDirty;
120
		return isDirty;
148
	}
121
	}
Lines 316-324 Link Here
316
	  String projectName = NO_PROJECT_NAME;
289
	  String projectName = NO_PROJECT_NAME;
317
	  
290
	  
318
		try {
291
		try {
319
	    IterationData iteration = server.getIteration(userStoryData.getIterationId());
292
	    IterationData iteration = client.getIteration(userStoryData.getIterationId());
320
	    if (iteration != null) {
293
	    if (iteration != null) {
321
	      ProjectData project = server.getProject(iteration.getProjectId());
294
	      ProjectData project = client.getProject(iteration.getProjectId());
322
	      if (project != null) {
295
	      if (project != null) {
323
	        projectName = project.getName();
296
	        projectName = project.getName();
324
	      }  
297
	      }  
Lines 335-341 Link Here
335
	  String iterationName = NO_ITERATION_NAME;
308
	  String iterationName = NO_ITERATION_NAME;
336
	  
309
	  
337
		try {
310
		try {
338
	    IterationData iteration = server.getIteration(userStoryData.getIterationId());
311
	    IterationData iteration = client.getIteration(userStoryData.getIterationId());
339
	    if (iteration != null) {
312
	    if (iteration != null) {
340
	      iterationName = iteration.getName();
313
	      iterationName = iteration.getName();
341
	    }
314
	    }
Lines 364-370 Link Here
364
		String acceptorName = NO_TRACKER_NAME;
337
		String acceptorName = NO_TRACKER_NAME;
365
		
338
		
366
		try {
339
		try {
367
		  PersonData personData = server.getPerson(getUserStoryData().getTrackerId());
340
		  PersonData personData = client.getPerson(getUserStoryData().getTrackerId());
368
		  if (personData != null) {
341
		  if (personData != null) {
369
		  	acceptorName = personData.getName();
342
		  	acceptorName = personData.getName();
370
		  }
343
		  }
(-)src/org/eclipse/mylyn/xplanner/ui/editor/XPlannerTaskEditorFactory.java (-51 / +32 lines)
Lines 5-22 Link Here
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
package org.eclipse.mylar.xplanner.ui.editor;
8
package org.eclipse.mylyn.xplanner.ui.editor;
9
9
10
import org.eclipse.mylar.core.MylarStatusHandler;
10
import org.eclipse.mylyn.monitor.core.StatusHandler;
11
import org.eclipse.mylar.tasks.core.ITask;
11
import org.eclipse.mylyn.tasks.core.*;
12
import org.eclipse.mylar.tasks.core.TaskRepository;
12
import org.eclipse.mylyn.tasks.ui.TasksUiPlugin;
13
import org.eclipse.mylar.tasks.ui.TasksUiPlugin;
13
import org.eclipse.mylyn.tasks.ui.editors.*;
14
import org.eclipse.mylar.tasks.ui.editors.ITaskEditorFactory;
14
import org.eclipse.mylyn.xplanner.ui.XPlannerMylynUIPlugin;
15
import org.eclipse.mylar.tasks.ui.editors.RepositoryTaskEditorInput;
15
import org.eclipse.mylyn.xplanner.ui.XPlannerTask;
16
import org.eclipse.mylar.tasks.ui.editors.TaskEditor;
17
import org.eclipse.mylar.tasks.ui.editors.TaskEditorInput;
18
import org.eclipse.mylar.xplanner.ui.XPlannerMylarUIPlugin;
19
import org.eclipse.mylar.xplanner.ui.XPlannerTask;
20
import org.eclipse.ui.IEditorInput;
16
import org.eclipse.ui.IEditorInput;
21
import org.eclipse.ui.IEditorPart;
17
import org.eclipse.ui.IEditorPart;
22
18
Lines 24-78 Link Here
24
 * @author Ravi Kumar
20
 * @author Ravi Kumar
25
 * @author Helen Bershadskaya
21
 * @author Helen Bershadskaya
26
 */
22
 */
27
public class XPlannerTaskEditorFactory implements ITaskEditorFactory {
23
public class XPlannerTaskEditorFactory extends AbstractTaskEditorFactory {
28
24
29
	/* (non-Javadoc)
25
	public boolean canCreateEditorFor(AbstractTask task) {
30
	 * @see org.eclipse.mylar.internal.tasklist.ui.ITaskEditorFactory#canCreateEditorFor(org.eclipse.mylar.provisional.tasklist.ITask)
31
	 */
32
	public boolean canCreateEditorFor(ITask task) {
33
		return task instanceof XPlannerTask;
26
		return task instanceof XPlannerTask;
34
	}
27
	}
35
28
36
	/* (non-Javadoc)
37
	 * @see org.eclipse.mylar.internal.tasklist.ui.ITaskEditorFactory#createEditor(org.eclipse.mylar.internal.tasklist.ui.editors.MylarTaskEditor)
38
	 */
39
	public IEditorPart createEditor(TaskEditor parentEditor, IEditorInput editorInput) {
29
	public IEditorPart createEditor(TaskEditor parentEditor, IEditorInput editorInput) {
40
		IEditorPart editor = null;
30
		IEditorPart editor = null;
31
32
		String kind = null;
33
		if (editorInput instanceof RepositoryTaskEditorInput) {
34
			RepositoryTaskData taskData = ((RepositoryTaskEditorInput)editorInput).getTaskData();
35
			kind = taskData.getTaskKind();
36
		}
37
		else if (editorInput instanceof TaskEditorInput) {
38
			AbstractTask task = ((TaskEditorInput)editorInput).getTask();
39
			kind = task.getTaskKind();
40
		}
41
		
41
		
42
		if (editorInput instanceof TaskEditorInput) {
42
	  if (XPlannerTask.Kind.TASK.toString().equals(kind)) {
43
		  ITask task = ((TaskEditorInput)editorInput).getTask();
43
		  editor = new XPlannerTaskEditor(parentEditor);
44
		  if (XPlannerTask.Kind.TASK.toString().equals(task.getTaskKind())) {
44
		  if (editor != null) {
45
			  editor = new XPlannerTaskEditor(parentEditor);
45
		  	((XPlannerTaskEditor)editor).setParentEditor(parentEditor);
46
			  if (editor != null) {
47
			  	((XPlannerTaskEditor)editor).setParentEditor(parentEditor);
48
			  }
49
		  }
50
		  else if (XPlannerTask.Kind.USER_STORY.toString().equals(task.getTaskKind())) {
51
		  	editor = new XPlannerUserStoryEditor(parentEditor);
52
		  }
46
		  }
53
		}
47
	  }
48
	  else if (XPlannerTask.Kind.USER_STORY.toString().equals(kind)) {
49
	  	editor = new XPlannerUserStoryEditor(parentEditor);
50
	  }
54
		
51
		
55
	  return editor;
52
	  return editor;
56
	}
53
	}
57
54
58
	/* (non-Javadoc)
55
	public IEditorInput createEditorInput(AbstractTask task) {
59
	 * @see org.eclipse.mylar.internal.tasklist.ui.ITaskEditorFactory#createEditorInput(org.eclipse.mylar.provisional.tasklist.ITask)
60
	 */
61
	public IEditorInput createEditorInput(ITask task) {
62
		IEditorInput input = null;
56
		IEditorInput input = null;
63
		
57
		
64
		if (task instanceof XPlannerTask) {
58
		if (task instanceof XPlannerTask) {
65
			XPlannerTask xplannerTask = (XPlannerTask) task;
59
			XPlannerTask xplannerTask = (XPlannerTask) task;
66
			
60
			
67
			final TaskRepository repository = TasksUiPlugin.getRepositoryManager().getRepository(
61
			final TaskRepository repository = TasksUiPlugin.getRepositoryManager().getRepository(
68
					xplannerTask.getRepositoryKind(), xplannerTask.getRepositoryUrl());
62
					xplannerTask.getConnectorKind(), xplannerTask.getRepositoryUrl());
69
			try {
63
			try {
70
				input = new RepositoryTaskEditorInput(repository, 
64
				input = new RepositoryTaskEditorInput(repository, 
71
					xplannerTask.getHandleIdentifier(), xplannerTask.getTaskUrl(), 
65
					xplannerTask.getTaskId(), xplannerTask.getUrl()); 
72
					xplannerTask.getTaskId());
73
			} 
66
			} 
74
			catch (Exception e) {
67
			catch (Exception e) {
75
				MylarStatusHandler.fail(e, Messages.XPlannerTaskEditorFactory_COULD_NOT_CREATE_EDITOR_INPUT, true);
68
				StatusHandler.fail(e, Messages.XPlannerTaskEditorFactory_COULD_NOT_CREATE_EDITOR_INPUT, true);
76
			}
69
			}
77
		
70
		
78
		}
71
		}
Lines 80-101 Link Here
80
		return input;
73
		return input;
81
	}
74
	}
82
75
83
	/* (non-Javadoc)
84
	 * @see org.eclipse.mylar.internal.tasklist.ui.ITaskEditorFactory#getTitle()
85
	 */
86
	public String getTitle() {
76
	public String getTitle() {
87
		return Messages.XPlannerTaskEditorFactory_TITLE;
77
		return Messages.XPlannerTaskEditorFactory_TITLE;
88
	}
78
	}
89
79
90
	/* (non-Javadoc)
91
	 * @see org.eclipse.mylar.internal.tasklist.ui.ITaskEditorFactory#notifyEditorActivationChange(org.eclipse.ui.IEditorPart)
92
	 */
93
	public void notifyEditorActivationChange(IEditorPart editor) {
94
	}
95
96
	/* (non-Javadoc)
97
	 * @see org.eclipse.mylar.internal.tasklist.ui.ITaskEditorFactory#providesOutline()
98
	 */
99
	public boolean providesOutline() {
80
	public boolean providesOutline() {
100
		return true;
81
		return true;
101
	}
82
	}
Lines 104-110 Link Here
104
		if (input instanceof RepositoryTaskEditorInput) {
85
		if (input instanceof RepositoryTaskEditorInput) {
105
			RepositoryTaskEditorInput existingInput = (RepositoryTaskEditorInput) input;
86
			RepositoryTaskEditorInput existingInput = (RepositoryTaskEditorInput) input;
106
			return existingInput.getTaskData() != null
87
			return existingInput.getTaskData() != null
107
					&& XPlannerMylarUIPlugin.REPOSITORY_KIND.equals(existingInput.getRepository().getKind());
88
					&& XPlannerMylynUIPlugin.REPOSITORY_KIND.equals(existingInput.getRepository().getConnectorKind());
108
		} 
89
		} 
109
		return false;
90
		return false;
110
	}
91
	}
(-)src/org/eclipse/mylyn/xplanner/ui/editor/messages.properties (-1 / +1 lines)
Lines 9-15 Link Here
9
XPlannerUserStoryEditor_TRACKER_LABEL=Tracker:
9
XPlannerUserStoryEditor_TRACKER_LABEL=Tracker:
10
XPlannerTaskEditor_ACCEPTOR_TEXT=Acceptor :
10
XPlannerTaskEditor_ACCEPTOR_TEXT=Acceptor :
11
XPlannerTaskEditor_ESTIMATED_HOURS_TEXT=Estimated Hours :
11
XPlannerTaskEditor_ESTIMATED_HOURS_TEXT=Estimated Hours :
12
XPlannerTaskEditor_HelpSearchExpression=Mylar or XPlanner
12
XPlannerTaskEditor_HelpSearchExpression=Mylyn or XPlanner
13
XPlannerUserStoryEditor_NO_TRACKER_NAME=<no tracker name>
13
XPlannerUserStoryEditor_NO_TRACKER_NAME=<no tracker name>
14
XPlannerUserStoryEditor_PRIORITY_LABEL=Priority:
14
XPlannerUserStoryEditor_PRIORITY_LABEL=Priority:
15
XPlannerTaskEditorFactory_TITLE=XPlanner
15
XPlannerTaskEditorFactory_TITLE=XPlanner
(-)src/org/eclipse/mylyn/xplanner/ui/editor/Messages.java (-2 / +2 lines)
Lines 5-11 Link Here
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
package org.eclipse.mylar.xplanner.ui.editor;
8
package org.eclipse.mylyn.xplanner.ui.editor;
9
9
10
import org.eclipse.osgi.util.NLS;
10
import org.eclipse.osgi.util.NLS;
11
11
Lines 14-20 Link Here
14
 * @author Helen Bershadskaya 
14
 * @author Helen Bershadskaya 
15
 */
15
 */
16
public class Messages extends NLS {
16
public class Messages extends NLS {
17
	private static final String BUNDLE_NAME = "org.eclipse.mylar.xplanner.ui.editor.messages"; //$NON-NLS-1$
17
	private static final String BUNDLE_NAME = "org.eclipse.mylyn.xplanner.ui.editor.messages"; //$NON-NLS-1$
18
18
19
	public static String XPlannerTaskEditor_ACCEPTOR_TEXT;
19
	public static String XPlannerTaskEditor_ACCEPTOR_TEXT;
20
20
(-)src/org/eclipse/mylyn/xplanner/ui/editor/XPlannerTaskEditor.java (-44 / +32 lines)
Lines 5-42 Link Here
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
package org.eclipse.mylar.xplanner.ui.editor;
8
package org.eclipse.mylyn.xplanner.ui.editor;
9
9
10
import java.text.MessageFormat;
10
import java.text.MessageFormat;
11
11
12
import org.eclipse.jface.layout.GridDataFactory;
12
import org.eclipse.jface.layout.GridDataFactory;
13
import org.eclipse.jface.resource.JFaceResources;
13
import org.eclipse.jface.resource.JFaceResources;
14
import org.eclipse.mylar.tasks.core.ITask;
14
import org.eclipse.mylyn.tasks.core.*;
15
import org.eclipse.mylar.tasks.core.RepositoryTaskAttribute;
15
import org.eclipse.mylyn.tasks.ui.editors.AbstractRepositoryTaskEditor;
16
import org.eclipse.mylar.tasks.core.RepositoryTaskData;
16
import org.eclipse.mylyn.xplanner.ui.*;
17
import org.eclipse.mylar.tasks.ui.editors.AbstractRepositoryTaskEditor;
18
import org.eclipse.mylar.xplanner.ui.XPlannerMylarUIPlugin;
19
import org.eclipse.mylar.xplanner.ui.XPlannerAttributeFactory;
20
import org.eclipse.mylar.xplanner.ui.XPlannerRepositoryUtils;
21
import org.eclipse.swt.SWT;
17
import org.eclipse.swt.SWT;
22
import org.eclipse.swt.events.ModifyEvent;
18
import org.eclipse.swt.events.*;
23
import org.eclipse.swt.events.ModifyListener;
24
import org.eclipse.swt.events.SelectionEvent;
25
import org.eclipse.swt.events.SelectionListener;
26
import org.eclipse.swt.layout.GridData;
27
import org.eclipse.swt.layout.GridLayout;
19
import org.eclipse.swt.layout.GridLayout;
28
import org.eclipse.swt.widgets.Button;
20
import org.eclipse.swt.widgets.*;
29
import org.eclipse.swt.widgets.Composite;
30
import org.eclipse.swt.widgets.Label;
31
import org.eclipse.swt.widgets.Text;
32
import org.eclipse.swt.widgets.Tree;
33
import org.eclipse.swt.widgets.TreeItem;
34
import org.eclipse.ui.IEditorInput;
21
import org.eclipse.ui.IEditorInput;
35
import org.eclipse.ui.IEditorSite;
22
import org.eclipse.ui.IEditorSite;
36
import org.eclipse.ui.forms.editor.FormEditor;
23
import org.eclipse.ui.forms.editor.FormEditor;
37
import org.eclipse.ui.forms.widgets.ExpandableComposite;
24
import org.eclipse.ui.forms.widgets.*;
38
import org.eclipse.ui.forms.widgets.FormToolkit;
39
import org.eclipse.ui.forms.widgets.Section;
40
25
41
/**
26
/**
42
 * @author Ravi Kumar
27
 * @author Ravi Kumar
Lines 77-101 Link Here
77
		submitButton.setEnabled(isValid);
62
		submitButton.setEnabled(isValid);
78
	}
63
	}
79
64
80
	protected Composite createAttributeLayout(Composite composite) {
65
//HeB -- testing
81
		FormToolkit toolkit = new FormToolkit(composite.getDisplay());
66
	protected void createAttributeLayout(Composite composite) {
82
		Section section = createSection(composite, Messages.XPlannerTaskEditor_ATTRIBUTES_TITLE);
67
//		super.createAttributeLayout(composite);
83
		section.setExpanded(true);
68
//		FormToolkit toolkit = new FormToolkit(composite.getDisplay());
84
		// Attributes Composite- this holds all the combo fields and text fields
69
//		Section section = createSection(composite, Messages.XPlannerTaskEditor_ATTRIBUTES_TITLE);
85
		Composite attributesComposite = toolkit.createComposite(section);
70
//		section.setExpanded(true);
86
		GridLayout attributesLayout = new GridLayout();
71
//		// Attributes Composite- this holds all the combo fields and text fields
87
		attributesComposite.setLayout(attributesLayout);
72
//		Composite attributesComposite = toolkit.createComposite(section);
88
		GridData attributesData = new GridData(GridData.FILL_BOTH);
73
//		GridLayout attributesLayout = new GridLayout();
89
		attributesData.horizontalSpan = 1;
74
//		attributesComposite.setLayout(attributesLayout);
90
		attributesData.grabExcessVerticalSpace = false;
75
//		GridData attributesData = new GridData(GridData.FILL_BOTH);
91
		attributesComposite.setLayoutData(attributesData);
76
//		attributesData.horizontalSpan = 1;
92
		section.setClient(attributesComposite);
77
//		attributesData.grabExcessVerticalSpace = false;
93
		
78
//		attributesComposite.setLayoutData(attributesData);
94
		return attributesComposite;
79
//		section.setClient(attributesComposite);
95
	}
80
	}
96
	
81
	
97
	@Override
82
	@Override
98
	protected void addAttachContextButton(Composite buttonComposite, ITask task) {
83
	protected void addAttachContextButton(Composite buttonComposite, AbstractTask task) {
99
		// disabled, see bug 155151
84
		// disabled, see bug 155151
100
	}
85
	}
101
86
Lines 116-130 Link Here
116
101
117
	@Override
102
	@Override
118
	protected void createCustomAttributeLayout(Composite composite) {
103
	protected void createCustomAttributeLayout(Composite composite) {
104
		// make sure we only use one column
105
		if (composite.getLayout() instanceof GridLayout) {
106
			GridLayout layout = (GridLayout)composite.getLayout();
107
			layout.numColumns = 1;
108
		}
109
119
		createPartControlCustom(composite);
110
		createPartControlCustom(composite);
120
	}
111
	}
121
112
113
	  // just in case, leave in method -- before had to get from editorInput
122
	public RepositoryTaskData getRepositoryTaskData() {
114
	public RepositoryTaskData getRepositoryTaskData() {
123
		return editorInput.getTaskData();
115
		return taskData;
124
	}
125
126
	protected void updateBug() {
127
		getRepositoryTaskData().setHasLocalChanges(true);
128
	}
116
	}
129
117
130
	public boolean isDirty() {
118
	public boolean isDirty() {
Lines 289-294 Link Here
289
	}
277
	}
290
278
291
	public String getPluginId() {
279
	public String getPluginId() {
292
		return XPlannerMylarUIPlugin.PLUGIN_ID;
280
		return XPlannerMylynUIPlugin.PLUGIN_ID;
293
	}
281
	}
294
}
282
}
(-)src/org/eclipse/mylyn/xplanner/ui/wizard/ProjectsViewerLabelProvider.java (-5 / +3 lines)
Lines 5-18 Link Here
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
package org.eclipse.mylar.xplanner.ui.wizard;
8
package org.eclipse.mylyn.xplanner.ui.wizard;
9
9
10
import org.eclipse.jface.viewers.LabelProvider;
10
import org.eclipse.jface.viewers.LabelProvider;
11
import org.eclipse.mylar.xplanner.ui.XPlannerImages;
11
import org.eclipse.mylyn.xplanner.ui.XPlannerImages;
12
import org.eclipse.swt.graphics.Image;
12
import org.eclipse.swt.graphics.Image;
13
import org.xplanner.soap.IterationData;
13
import org.xplanner.soap.*;
14
import org.xplanner.soap.ProjectData;
15
import org.xplanner.soap.UserStoryData;
16
14
17
15
18
/**
16
/**
(-)src/org/eclipse/mylyn/xplanner/ui/wizard/XPlannerRepositorySettingsPage.java (-12 / +10 lines)
Lines 5-24 Link Here
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
package org.eclipse.mylar.xplanner.ui.wizard;
8
package org.eclipse.mylyn.xplanner.ui.wizard;
9
9
10
import java.net.MalformedURLException;
10
import java.net.MalformedURLException;
11
import java.net.URL;
11
import java.net.URL;
12
12
13
import org.eclipse.core.runtime.CoreException;
13
import org.eclipse.core.runtime.*;
14
import org.eclipse.core.runtime.IProgressMonitor;
14
import org.eclipse.mylyn.tasks.core.TaskRepository;
15
import org.eclipse.core.runtime.IStatus;
15
import org.eclipse.mylyn.tasks.ui.AbstractRepositoryConnectorUi;
16
import org.eclipse.core.runtime.Status;
16
import org.eclipse.mylyn.tasks.ui.wizards.AbstractRepositorySettingsPage;
17
import org.eclipse.mylar.tasks.core.TaskRepository;
17
import org.eclipse.mylyn.xplanner.ui.XPlannerMylynUIPlugin;
18
import org.eclipse.mylar.tasks.ui.AbstractRepositoryConnectorUi;
18
import org.eclipse.mylyn.xplanner.ui.XPlannerRepositoryUtils;
19
import org.eclipse.mylar.tasks.ui.wizards.AbstractRepositorySettingsPage;
20
import org.eclipse.mylar.xplanner.ui.XPlannerMylarUIPlugin;
21
import org.eclipse.mylar.xplanner.ui.XPlannerRepositoryUtils;
22
import org.eclipse.swt.widgets.Composite;
19
import org.eclipse.swt.widgets.Composite;
23
20
24
21
Lines 39-45 Link Here
39
36
40
	public XPlannerRepositorySettingsPage(AbstractRepositoryConnectorUi connectorUi) {
37
	public XPlannerRepositorySettingsPage(AbstractRepositoryConnectorUi connectorUi) {
41
		super(TITLE, DESCRIPTION, connectorUi);
38
		super(TITLE, DESCRIPTION, connectorUi);
42
		setNeedsProxy(false);
39
		setNeedsProxy(true);
40
		setNeedsHttpAuth(true);
43
	}
41
	}
44
42
45
	protected void createAdditionalControls(Composite parent) {
43
	protected void createAdditionalControls(Composite parent) {
Lines 76-82 Link Here
76
		public void run(IProgressMonitor monitor) throws CoreException {
74
		public void run(IProgressMonitor monitor) throws CoreException {
77
			XPlannerRepositoryUtils.validateRepository(repository);
75
			XPlannerRepositoryUtils.validateRepository(repository);
78
	
76
	
79
			setStatus(new Status(IStatus.OK, XPlannerMylarUIPlugin.PLUGIN_ID, IStatus.OK,
77
			setStatus(new Status(IStatus.OK, XPlannerMylynUIPlugin.PLUGIN_ID, IStatus.OK,
80
					Messages.XPlannerRepositorySettingsPage_VALID_SETTINGS_FOUND, null));
78
					Messages.XPlannerRepositorySettingsPage_VALID_SETTINGS_FOUND, null));
81
		}
79
		}
82
	}
80
	}
(-)src/org/eclipse/mylyn/xplanner/ui/wizard/MultipleQueryPage.java (-2 / +2 lines)
Lines 5-15 Link Here
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
package org.eclipse.mylar.xplanner.ui.wizard;
8
package org.eclipse.mylyn.xplanner.ui.wizard;
9
9
10
import java.util.List;
10
import java.util.List;
11
11
12
import org.eclipse.mylar.tasks.core.AbstractRepositoryQuery;
12
import org.eclipse.mylyn.tasks.core.AbstractRepositoryQuery;
13
13
14
/**
14
/**
15
 * @author Ravi Kumar
15
 * @author Ravi Kumar
(-)src/org/eclipse/mylyn/xplanner/ui/wizard/ExistingXPlannerTaskWizardPage.java (-2 / +2 lines)
Lines 5-13 Link Here
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
package org.eclipse.mylar.xplanner.ui.wizard;
8
package org.eclipse.mylyn.xplanner.ui.wizard;
9
9
10
import org.eclipse.mylar.internal.tasks.ui.wizards.ExistingTaskWizardPage;
10
import org.eclipse.mylyn.internal.tasks.ui.wizards.ExistingTaskWizardPage;
11
11
12
/**
12
/**
13
 * @author Ravi Kumar 
13
 * @author Ravi Kumar 
(-)src/org/eclipse/mylyn/xplanner/ui/wizard/EditXPlannerQueryWizard.java (-9 / +8 lines)
Lines 5-21 Link Here
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
package org.eclipse.mylar.xplanner.ui.wizard;
8
package org.eclipse.mylyn.xplanner.ui.wizard;
9
9
10
import java.util.ArrayList;
10
import java.util.ArrayList;
11
import java.util.List;
11
import java.util.List;
12
12
13
import org.eclipse.mylar.tasks.core.AbstractRepositoryConnector;
13
import org.eclipse.mylyn.tasks.core.*;
14
import org.eclipse.mylar.tasks.core.AbstractRepositoryQuery;
14
import org.eclipse.mylyn.tasks.ui.TasksUiPlugin;
15
import org.eclipse.mylar.tasks.core.TaskRepository;
15
import org.eclipse.mylyn.tasks.ui.wizards.AbstractEditQueryWizard;
16
import org.eclipse.mylar.tasks.ui.TasksUiPlugin;
16
import org.eclipse.mylyn.xplanner.ui.XPlannerCustomQuery;
17
import org.eclipse.mylar.tasks.ui.wizards.AbstractEditQueryWizard;
18
import org.eclipse.mylar.xplanner.ui.XPlannerCustomQuery;
19
17
20
18
21
/**
19
/**
Lines 74-82 Link Here
74
		}
72
		}
75
		TasksUiPlugin.getTaskListManager().getTaskList().addQuery(query);
73
		TasksUiPlugin.getTaskListManager().getTaskList().addQuery(query);
76
		
74
		
77
		AbstractRepositoryConnector connector = TasksUiPlugin.getRepositoryManager().getRepositoryConnector(repository.getKind());
75
		AbstractRepositoryConnector connector = TasksUiPlugin.getRepositoryManager().getRepositoryConnector(repository.getConnectorKind());
78
		if (connector != null) {
76
		if (connector != null) {
79
			TasksUiPlugin.getSynchronizationManager().synchronize(connector, query, null);
77
			TasksUiPlugin.getSynchronizationManager().synchronize(
78
					connector, query, null, true);
80
		}
79
		}
81
	}
80
	}
82
	
81
	
(-)src/org/eclipse/mylyn/xplanner/ui/wizard/ProjectsViewerContentProvider.java (-14 / +12 lines)
Lines 5-22 Link Here
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
package org.eclipse.mylar.xplanner.ui.wizard;
8
package org.eclipse.mylyn.xplanner.ui.wizard;
9
9
10
import java.rmi.RemoteException;
10
import java.rmi.RemoteException;
11
import java.util.HashMap;
11
import java.util.HashMap;
12
12
13
import org.eclipse.jface.viewers.ITreeContentProvider;
13
import org.eclipse.jface.viewers.ITreeContentProvider;
14
import org.eclipse.jface.viewers.Viewer;
14
import org.eclipse.jface.viewers.Viewer;
15
import org.eclipse.mylar.xplanner.core.service.XPlannerServer;
15
import org.eclipse.mylyn.xplanner.core.service.XPlannerClient;
16
import org.eclipse.mylar.xplanner.ui.XPlannerMylarUIPlugin;
16
import org.eclipse.mylyn.xplanner.ui.XPlannerMylynUIPlugin;
17
import org.xplanner.soap.IterationData;
17
import org.xplanner.soap.*;
18
import org.xplanner.soap.ProjectData;
19
import org.xplanner.soap.UserStoryData;
20
18
21
/**
19
/**
22
 * @author Ravi Kumar
20
 * @author Ravi Kumar
Lines 42-52 Link Here
42
		try {
40
		try {
43
			if (element instanceof IterationData) {
41
			if (element instanceof IterationData) {
44
				IterationData iteration = (IterationData) element;
42
				IterationData iteration = (IterationData) element;
45
				parent = customQueryPage.getServer().getProject(iteration.getProjectId());
43
				parent = customQueryPage.getClient().getProject(iteration.getProjectId());
46
			}
44
			}
47
			else if (element instanceof UserStoryData) {
45
			else if (element instanceof UserStoryData) {
48
				UserStoryData userStory = (UserStoryData) element;
46
				UserStoryData userStory = (UserStoryData) element;
49
				parent = customQueryPage.getServer().getIteration(userStory.getIterationId());
47
				parent = customQueryPage.getClient().getIteration(userStory.getIterationId());
50
			}
48
			}
51
		}
49
		}
52
		catch (RemoteException e) {
50
		catch (RemoteException e) {
Lines 86-92 Link Here
86
	private ProjectData[] getProjects() {
84
	private ProjectData[] getProjects() {
87
		if (projects == null) {
85
		if (projects == null) {
88
			try {
86
			try {
89
				projects = customQueryPage.getServer().getProjects();
87
				projects = customQueryPage.getClient().getProjects();
90
			}
88
			}
91
			catch (RemoteException e) {
89
			catch (RemoteException e) {
92
				e.printStackTrace();
90
				e.printStackTrace();
Lines 101-107 Link Here
101
		
99
		
102
		if (iterations == null) {
100
		if (iterations == null) {
103
			try {
101
			try {
104
				iterations = customQueryPage.getServer().getIterations(project.getId());
102
				iterations = customQueryPage.getClient().getIterations(project.getId());
105
				projectsToIterationsMap.put(project, iterations);
103
				projectsToIterationsMap.put(project, iterations);
106
			}
104
			}
107
			catch (RemoteException e) {
105
			catch (RemoteException e) {
Lines 119-125 Link Here
119
			userStories = iterationsToUserStoriesMap.get(iteration);
117
			userStories = iterationsToUserStoriesMap.get(iteration);
120
			if (userStories == null) {
118
			if (userStories == null) {
121
				try {
119
				try {
122
					userStories = customQueryPage.getServer().getUserStories(iteration.getId());
120
					userStories = customQueryPage.getClient().getUserStories(iteration.getId());
123
					iterationsToUserStoriesMap.put(iteration, userStories);
121
					iterationsToUserStoriesMap.put(iteration, userStories);
124
				}
122
				}
125
				catch (RemoteException e) {
123
				catch (RemoteException e) {
Lines 150-159 Link Here
150
		  customQueryPage.getProjectsViewer().replace(parent, index, element);
148
		  customQueryPage.getProjectsViewer().replace(parent, index, element);
151
		  customQueryPage.getProjectsViewer().setChildCount(parent, getChildCount(parent));
149
		  customQueryPage.getProjectsViewer().setChildCount(parent, getChildCount(parent));
152
		  try {
150
		  try {
153
			  	customQueryPage.getProjectsViewer().setChildCount(element, getChildCount(element));
151
			  customQueryPage.getProjectsViewer().setChildCount(element, getChildCount(element));
154
			}
152
			}
155
			catch (Exception e) {
153
			catch (Exception e) {
156
				XPlannerMylarUIPlugin.log(e.getCause(), "Could not update project element child count", true);
154
				XPlannerMylynUIPlugin.log(e.getCause(), Messages.ProjectsViewerContentProvider_COULD_NOT_UPDATE_PROJECT_ELEMENT_CHILD_COUNT, true);
157
			}
155
			}
158
		}  
156
		}  
159
	}
157
	}
Lines 172-178 Link Here
172
	private Object[] getXPlannerChildren(Object element) {
170
	private Object[] getXPlannerChildren(Object element) {
173
	  Object[] children = new Object[0];
171
	  Object[] children = new Object[0];
174
	  
172
	  
175
		if (element == null || element instanceof XPlannerServer) {
173
		if (element == null || element instanceof XPlannerClient) {
176
		  children = getProjects();	
174
		  children = getProjects();	
177
		}
175
		}
178
		else if (element instanceof ProjectData) {
176
		else if (element instanceof ProjectData) {
(-)src/org/eclipse/mylyn/xplanner/ui/wizard/messages.properties (+1 lines)
Lines 30-32 Link Here
30
ExistingXPlannerTaskWizardPage_ENTER_XPLANNER_IDENTIFIER=Enter the XPlanner identifier for the iteration, user story or task.
30
ExistingXPlannerTaskWizardPage_ENTER_XPLANNER_IDENTIFIER=Enter the XPlanner identifier for the iteration, user story or task.
31
ProjectsViewerLabelProvider_NO_NAME=<no name>
31
ProjectsViewerLabelProvider_NO_NAME=<no name>
32
AbstractXPlannerQueryWizardPage_NEW_XPLANNER_QUERY=New XPlanner Query
32
AbstractXPlannerQueryWizardPage_NEW_XPLANNER_QUERY=New XPlanner Query
33
ProjectsViewerContentProvider_COULD_NOT_UPDATE_PROJECT_ELEMENT_CHILD_COUNT=Could not update project element child count
(-)src/org/eclipse/mylyn/xplanner/ui/wizard/NewXPlannerQueryWizard.java (-13 / +11 lines)
Lines 5-26 Link Here
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
package org.eclipse.mylar.xplanner.ui.wizard;
8
package org.eclipse.mylyn.xplanner.ui.wizard;
9
 
9
 
10
import java.util.HashSet;
10
import java.util.HashSet;
11
import java.util.List;
11
import java.util.List;
12
12
13
import org.eclipse.core.runtime.jobs.Job;
13
import org.eclipse.core.runtime.jobs.Job;
14
import org.eclipse.jface.wizard.Wizard;
14
import org.eclipse.jface.wizard.Wizard;
15
import org.eclipse.mylar.internal.tasks.ui.TasksUiImages;
15
import org.eclipse.mylyn.internal.tasks.ui.TasksUiImages;
16
import org.eclipse.mylar.tasks.core.AbstractRepositoryConnector;
16
import org.eclipse.mylyn.tasks.core.*;
17
import org.eclipse.mylar.tasks.core.AbstractRepositoryQuery;
17
import org.eclipse.mylyn.tasks.ui.TasksUiPlugin;
18
import org.eclipse.mylar.tasks.core.TaskRepository;
19
import org.eclipse.mylar.tasks.ui.TasksUiPlugin;
20
18
21
/**
19
/**
22
 * Wizard that allows the user to select one of their named XPlanner filters on the
20
 * Wizard that allows the user to create an XPlanner query for tasks
23
 * server
24
 * 
21
 * 
25
 * @author Ravi Kumar
22
 * @author Ravi Kumar
26
 * @author Helen Bershadskaya
23
 * @author Helen Bershadskaya
Lines 54-63 Link Here
54
			}
51
			}
55
			
52
			
56
			// need to synchronize multiple queries with single call, otherwise get ConcurrencyModificationException
53
			// need to synchronize multiple queries with single call, otherwise get ConcurrencyModificationException
57
			AbstractRepositoryConnector connector = TasksUiPlugin.getRepositoryManager().getRepositoryConnector(repository.getKind());
54
			AbstractRepositoryConnector connector = TasksUiPlugin.getRepositoryManager().getRepositoryConnector(repository.getConnectorKind());
58
			if (connector != null) {
55
			if (connector != null) {
59
				TasksUiPlugin.getSynchronizationManager().synchronize(connector,
56
				TasksUiPlugin.getSynchronizationManager().synchronize(
60
						new HashSet<AbstractRepositoryQuery>(queries), null, Job.SHORT, 0, true);
57
						connector, repository,
58
						new HashSet<AbstractRepositoryQuery>(queries), null, Job.LONG, 0, true);
61
			}
59
			}
62
		}
60
		}
63
		else {
61
		else {
Lines 71-79 Link Here
71
  public static void addQuery(AbstractRepositoryQuery query, TaskRepository repository) {
69
  public static void addQuery(AbstractRepositoryQuery query, TaskRepository repository) {
72
		if (query != null) {
70
		if (query != null) {
73
			TasksUiPlugin.getTaskListManager().getTaskList().addQuery(query);
71
			TasksUiPlugin.getTaskListManager().getTaskList().addQuery(query);
74
			AbstractRepositoryConnector connector = TasksUiPlugin.getRepositoryManager().getRepositoryConnector(repository.getKind());
72
			AbstractRepositoryConnector connector = TasksUiPlugin.getRepositoryManager().getRepositoryConnector(repository.getConnectorKind());
75
			if (connector != null) {
73
			if (connector != null) {
76
				TasksUiPlugin.getSynchronizationManager().synchronize(connector, query, null);
74
				TasksUiPlugin.getSynchronizationManager().synchronize(connector, query, null, true);
77
			}
75
			}
78
		} 
76
		} 
79
  }
77
  }
(-)src/org/eclipse/mylyn/xplanner/ui/wizard/XPlannerQuerySelectionWizardPage.java (-6 / +5 lines)
Lines 5-16 Link Here
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
package org.eclipse.mylar.xplanner.ui.wizard;
8
package org.eclipse.mylyn.xplanner.ui.wizard;
9
9
10
import org.eclipse.jface.wizard.IWizardPage;
10
import org.eclipse.jface.wizard.IWizardPage;
11
import org.eclipse.mylar.tasks.core.AbstractRepositoryQuery;
11
import org.eclipse.mylyn.tasks.core.AbstractRepositoryQuery;
12
import org.eclipse.mylar.tasks.core.TaskRepository;
12
import org.eclipse.mylyn.tasks.core.TaskRepository;
13
import org.eclipse.mylar.xplanner.ui.XPlannerCustomQuery;
13
import org.eclipse.mylyn.xplanner.ui.XPlannerCustomQuery;
14
import org.eclipse.swt.SWT;
14
import org.eclipse.swt.SWT;
15
import org.eclipse.swt.layout.GridData;
15
import org.eclipse.swt.layout.GridData;
16
import org.eclipse.swt.layout.GridLayout;
16
import org.eclipse.swt.layout.GridLayout;
Lines 19-26 Link Here
19
19
20
20
21
/**
21
/**
22
 * Wizard page that allows the user to select a named XPlanner filter they have
22
 * Wizard page that allows the user to select a query of tasks from the XPlanner server.
23
 * defined on the server.
24
 *
23
 *
25
 * @author Ravi Kumar
24
 * @author Ravi Kumar
26
 * @author Helen Bershadskaya
25
 * @author Helen Bershadskaya
(-)src/org/eclipse/mylyn/xplanner/ui/wizard/XPlannerQueryWizardUtils.java (-5 / +5 lines)
Lines 5-17 Link Here
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
package org.eclipse.mylar.xplanner.ui.wizard;
8
package org.eclipse.mylyn.xplanner.ui.wizard;
9
9
10
import org.eclipse.core.runtime.CoreException;
10
import org.eclipse.core.runtime.CoreException;
11
import org.eclipse.jface.wizard.Wizard;
11
import org.eclipse.jface.wizard.Wizard;
12
import org.eclipse.mylar.tasks.core.TaskRepository;
12
import org.eclipse.mylyn.tasks.core.TaskRepository;
13
import org.eclipse.mylar.xplanner.ui.XPlannerMylarUIPlugin;
13
import org.eclipse.mylyn.xplanner.ui.XPlannerCustomQuery;
14
import org.eclipse.mylar.xplanner.ui.XPlannerCustomQuery;
14
import org.eclipse.mylyn.xplanner.ui.XPlannerMylynUIPlugin;
15
15
16
16
17
/**
17
/**
Lines 46-52 Link Here
46
		}
46
		}
47
		catch (RuntimeException e) {
47
		catch (RuntimeException e) {
48
			if (e.getCause() instanceof CoreException) { 
48
			if (e.getCause() instanceof CoreException) { 
49
				XPlannerMylarUIPlugin.log(e.getCause(), Messages.XPlannerQueryWizardUtils_COULD_NOT_CREATE_QUERY_PAGE_MESSAGE, true);
49
				XPlannerMylynUIPlugin.log(e.getCause(), Messages.XPlannerQueryWizardUtils_COULD_NOT_CREATE_QUERY_PAGE_MESSAGE, true);
50
			}
50
			}
51
			else {
51
			else {
52
				throw e;
52
				throw e;
(-)src/org/eclipse/mylyn/xplanner/ui/wizard/AbstractXPlannerQueryWizardPage.java (-5 / +5 lines)
Lines 5-16 Link Here
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
package org.eclipse.mylar.xplanner.ui.wizard;
8
package org.eclipse.mylyn.xplanner.ui.wizard;
9
9
10
import org.eclipse.mylar.tasks.core.AbstractRepositoryQuery;
10
import org.eclipse.mylyn.tasks.core.AbstractRepositoryQuery;
11
import org.eclipse.mylar.tasks.core.TaskRepository;
11
import org.eclipse.mylyn.tasks.core.TaskRepository;
12
import org.eclipse.mylar.tasks.ui.search.AbstractRepositoryQueryPage;
12
import org.eclipse.mylyn.tasks.ui.search.AbstractRepositoryQueryPage;
13
import org.eclipse.mylar.xplanner.ui.XPlannerCustomQuery;
13
import org.eclipse.mylyn.xplanner.ui.XPlannerCustomQuery;
14
import org.eclipse.ui.PlatformUI;
14
import org.eclipse.ui.PlatformUI;
15
15
16
16
(-)src/org/eclipse/mylyn/xplanner/ui/wizard/Messages.java (-2 / +4 lines)
Lines 5-11 Link Here
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
package org.eclipse.mylar.xplanner.ui.wizard;
8
package org.eclipse.mylyn.xplanner.ui.wizard;
9
9
10
import org.eclipse.osgi.util.NLS;
10
import org.eclipse.osgi.util.NLS;
11
11
Lines 14-20 Link Here
14
 * @author Helen Bershadskaya
14
 * @author Helen Bershadskaya
15
 */
15
 */
16
public class Messages extends NLS {
16
public class Messages extends NLS {
17
	private static final String BUNDLE_NAME = "org.eclipse.mylar.xplanner.ui.wizard.messages"; //$NON-NLS-1$
17
	private static final String BUNDLE_NAME = "org.eclipse.mylyn.xplanner.ui.wizard.messages"; //$NON-NLS-1$
18
18
19
	public static String AbstractXPlannerQueryWizardPage_NEW_XPLANNER_QUERY;
19
	public static String AbstractXPlannerQueryWizardPage_NEW_XPLANNER_QUERY;
20
20
Lines 34-39 Link Here
34
34
35
	public static String NewXPlannerTaskPage_ONCE_SUBMITTED_SYNCHRONIZE_QUERIES;
35
	public static String NewXPlannerTaskPage_ONCE_SUBMITTED_SYNCHRONIZE_QUERIES;
36
36
37
	public static String ProjectsViewerContentProvider_COULD_NOT_UPDATE_PROJECT_ELEMENT_CHILD_COUNT;
38
37
	public static String ProjectsViewerLabelProvider_NO_NAME;
39
	public static String ProjectsViewerLabelProvider_NO_NAME;
38
40
39
	public static String XPlannerCustomQueryPage_ALL_BUTTON;
41
	public static String XPlannerCustomQueryPage_ALL_BUTTON;
(-)src/org/eclipse/mylyn/xplanner/ui/wizard/NewXPlannerTaskPage.java (-1 / +1 lines)
Lines 5-11 Link Here
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
package org.eclipse.mylar.xplanner.ui.wizard;
8
package org.eclipse.mylyn.xplanner.ui.wizard;
9
9
10
import org.eclipse.jface.wizard.WizardPage;
10
import org.eclipse.jface.wizard.WizardPage;
11
import org.eclipse.swt.SWT;
11
import org.eclipse.swt.SWT;
(-)src/org/eclipse/mylyn/xplanner/ui/wizard/XPlannerCustomQueryPage.java (-51 / +31 lines)
Lines 5-47 Link Here
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
package org.eclipse.mylar.xplanner.ui.wizard;
8
package org.eclipse.mylyn.xplanner.ui.wizard;
9
 
9
 
10
import java.rmi.RemoteException;
10
import java.rmi.RemoteException;
11
import java.util.ArrayList;
11
import java.util.*;
12
import java.util.Arrays;
13
import java.util.Iterator;
14
import java.util.List;
12
import java.util.List;
15
13
16
import org.eclipse.core.runtime.CoreException;
14
import org.eclipse.core.runtime.CoreException;
17
import org.eclipse.jface.viewers.ISelectionChangedListener;
15
import org.eclipse.jface.viewers.*;
18
import org.eclipse.jface.viewers.SelectionChangedEvent;
19
import org.eclipse.jface.viewers.StructuredSelection;
20
import org.eclipse.jface.viewers.TreeViewer;
21
import org.eclipse.jface.wizard.IWizardPage;
16
import org.eclipse.jface.wizard.IWizardPage;
22
import org.eclipse.mylar.tasks.core.AbstractRepositoryQuery;
17
import org.eclipse.mylyn.tasks.core.AbstractRepositoryQuery;
23
import org.eclipse.mylar.tasks.core.TaskRepository;
18
import org.eclipse.mylyn.tasks.core.TaskRepository;
24
import org.eclipse.mylar.tasks.ui.TasksUiPlugin;
19
import org.eclipse.mylyn.xplanner.core.service.XPlannerClient;
25
import org.eclipse.mylar.xplanner.core.service.XPlannerServer;
20
import org.eclipse.mylyn.xplanner.ui.XPlannerCustomQuery;
26
import org.eclipse.mylar.xplanner.ui.XPlannerCustomQuery;
21
import org.eclipse.mylyn.xplanner.ui.XPlannerClientFacade;
27
import org.eclipse.mylar.xplanner.ui.XPlannerServerFacade;
28
import org.eclipse.swt.SWT;
22
import org.eclipse.swt.SWT;
29
import org.eclipse.swt.events.FocusAdapter;
23
import org.eclipse.swt.events.*;
30
import org.eclipse.swt.events.FocusEvent;
31
import org.eclipse.swt.events.ModifyEvent;
32
import org.eclipse.swt.events.ModifyListener;
33
import org.eclipse.swt.events.SelectionEvent;
34
import org.eclipse.swt.events.SelectionListener;
35
import org.eclipse.swt.layout.GridData;
24
import org.eclipse.swt.layout.GridData;
36
import org.eclipse.swt.layout.GridLayout;
25
import org.eclipse.swt.layout.GridLayout;
37
import org.eclipse.swt.widgets.Button;
26
import org.eclipse.swt.widgets.*;
38
import org.eclipse.swt.widgets.Composite;
27
import org.xplanner.soap.*;
39
import org.eclipse.swt.widgets.Label;
40
import org.eclipse.swt.widgets.Text;
41
import org.xplanner.soap.IterationData;
42
import org.xplanner.soap.ProjectData;
43
import org.xplanner.soap.TaskData;
44
import org.xplanner.soap.UserStoryData;
45
28
46
/**
29
/**
47
 * @author Ravi Kumar
30
 * @author Ravi Kumar
Lines 54-60 Link Here
54
37
55
	private static final boolean DEFAULT_SELECT_MY_CURRENT_TASKS = true;
38
	private static final boolean DEFAULT_SELECT_MY_CURRENT_TASKS = true;
56
39
57
	private final XPlannerServer server;
40
	private final XPlannerClient client;
58
41
59
	private Text nameText;
42
	private Text nameText;
60
	
43
	
Lines 83-94 Link Here
83
	/**
66
	/**
84
	 * @param pageName
67
	 * @param pageName
85
	 * @param title
68
	 * @param title
86
	 * @param titleImage
69
	 * @param titleImage 
87
	 */
70
	 */
88
	public XPlannerCustomQueryPage(TaskRepository repository, XPlannerCustomQuery existingQuery) {
71
	public XPlannerCustomQueryPage(TaskRepository repository, XPlannerCustomQuery existingQuery) {
89
		super(repository, existingQuery);
72
		super(repository, existingQuery);
90
		try {
73
		try {
91
			this.server = XPlannerServerFacade.getDefault().getXPlannerServer(repository);
74
			this.client = XPlannerClientFacade.getDefault().getXPlannerClient(repository);
92
			setPageComplete(false);
75
			setPageComplete(false);
93
		}
76
		}
94
		catch (CoreException e) {
77
		catch (CoreException e) {
Lines 131-138 Link Here
131
	  setControl(dataComposite);
114
	  setControl(dataComposite);
132
	}
115
	}
133
116
134
	protected XPlannerServer getServer() {
117
	protected XPlannerClient getClient() {
135
		return this.server;
118
		return this.client;
136
	}
119
	}
137
	
120
	
138
	protected boolean isContentTypeTask() {
121
	protected boolean isContentTypeTask() {
Lines 254-260 Link Here
254
		projectsViewerGridData.widthHint = 200;
237
		projectsViewerGridData.widthHint = 200;
255
		
238
		
256
		projectsViewer.getTree().setLayoutData(projectsViewerGridData);
239
		projectsViewer.getTree().setLayoutData(projectsViewerGridData);
257
		projectsViewer.setInput(server);
240
		projectsViewer.setInput(client);
258
		projectsViewer.refresh();
241
		projectsViewer.refresh();
259
		projectsViewer.addSelectionChangedListener(new ISelectionChangedListener() {
242
		projectsViewer.addSelectionChangedListener(new ISelectionChangedListener() {
260
			public void selectionChanged(SelectionChangedEvent e) {
243
			public void selectionChanged(SelectionChangedEvent e) {
Lines 484-496 Link Here
484
		for (int contentId : contentIds) {
467
		for (int contentId : contentIds) {
485
			try {
468
			try {
486
				if (contentIdType == XPlannerCustomQuery.ContentIdType.PROJECT) {
469
				if (contentIdType == XPlannerCustomQuery.ContentIdType.PROJECT) {
487
					selection.add(server.getProject(contentId));
470
					selection.add(client.getProject(contentId));
488
				}
471
				}
489
				else if (contentIdType == XPlannerCustomQuery.ContentIdType.ITERATION) {
472
				else if (contentIdType == XPlannerCustomQuery.ContentIdType.ITERATION) {
490
					selection.add(server.getIteration(contentId));
473
					selection.add(client.getIteration(contentId));
491
				}
474
				}
492
				else if (contentIdType == XPlannerCustomQuery.ContentIdType.USER_STORY) {
475
				else if (contentIdType == XPlannerCustomQuery.ContentIdType.USER_STORY) {
493
					selection.add(server.getUserStory(contentId));
476
					selection.add(client.getUserStory(contentId));
494
				}
477
				}
495
			}
478
			}
496
			catch (RemoteException e) {
479
			catch (RemoteException e) {
Lines 501-507 Link Here
501
		return selection;
484
		return selection;
502
	}
485
	}
503
486
504
	//TODO -- should be in server interface
487
	//TODO -- should be in client interface
505
	private boolean isUseAll() {
488
	private boolean isUseAll() {
506
		return allTasksOrStoriesButton.getSelection();
489
		return allTasksOrStoriesButton.getSelection();
507
	}
490
	}
Lines 525-531 Link Here
525
			
508
			
526
			// use all?
509
			// use all?
527
			if (!isUseAll()) {
510
			if (!isUseAll()) {
528
				query.setPersonId(server.getCurrentPersonId());
511
				query.setPersonId(client.getCurrentPersonId());
529
			}
512
			}
530
			else {
513
			else {
531
				query.setPersonId(XPlannerCustomQuery.INVALID_ID);
514
				query.setPersonId(XPlannerCustomQuery.INVALID_ID);
Lines 596-602 Link Here
596
//			int userStoryId = ((UserStoryData)selectedElement).getId();
579
//			int userStoryId = ((UserStoryData)selectedElement).getId();
597
//			if (userStoryId != XPlannerCustomQuery.INVALID_ID) {
580
//			if (userStoryId != XPlannerCustomQuery.INVALID_ID) {
598
//				try {
581
//				try {
599
//					userStory = server.getUserStory(userStoryId);
582
//					userStory = client.getUserStory(userStoryId);
600
//				}
583
//				}
601
//				catch (RemoteException e) {
584
//				catch (RemoteException e) {
602
//					e.printStackTrace();
585
//					e.printStackTrace();
Lines 613-620 Link Here
613
	
596
	
614
	public AbstractRepositoryQuery getQuery() {
597
	public AbstractRepositoryQuery getQuery() {
615
		if (getExistingQuery() == null) {
598
		if (getExistingQuery() == null) {
616
			setExistingQuery(new XPlannerCustomQuery(getRepository().getUrl(), getNameText(), 
599
			setExistingQuery(new XPlannerCustomQuery(getRepository().getUrl(), getNameText())); 
617
				TasksUiPlugin.getTaskListManager().getTaskList()));
618
		}
600
		}
619
		
601
		
620
		applyChanges(getExistingQuery());
602
		applyChanges(getExistingQuery());
Lines 631-638 Link Here
631
		if (isContentTypeTask()) {
613
		if (isContentTypeTask()) {
632
			// if don't have existing query, create one
614
			// if don't have existing query, create one
633
			if (getExistingQuery() == null) {
615
			if (getExistingQuery() == null) {
634
				setExistingQuery(new XPlannerCustomQuery(getRepository().getUrl(), getNameText(), 
616
				setExistingQuery(new XPlannerCustomQuery(getRepository().getUrl(), getNameText())); 
635
					TasksUiPlugin.getTaskListManager().getTaskList()));
636
			}
617
			}
637
618
638
			applyChanges(getExistingQuery());
619
			applyChanges(getExistingQuery());
Lines 654-667 Link Here
654
635
655
		try {
636
		try {
656
			if (selectedElement instanceof ProjectData) {
637
			if (selectedElement instanceof ProjectData) {
657
				IterationData[] iterations = server.getIterations(
638
				IterationData[] iterations = client.getIterations(
658
						((ProjectData)selectedElement).getId());
639
						((ProjectData)selectedElement).getId());
659
				for (IterationData iteration : iterations) {
640
				for (IterationData iteration : iterations) {
660
					userStories.addAll(Arrays.asList(server.getUserStories(iteration.getId())));
641
					userStories.addAll(Arrays.asList(client.getUserStories(iteration.getId())));
661
				}
642
				}
662
			}
643
			}
663
			else if (selectedElement instanceof IterationData) {
644
			else if (selectedElement instanceof IterationData) {
664
				userStories.addAll(Arrays.asList(server.getUserStories(
645
				userStories.addAll(Arrays.asList(client.getUserStories(
665
						((IterationData)selectedElement).getId())));
646
						((IterationData)selectedElement).getId())));
666
			}
647
			}
667
			else if (selectedElement instanceof UserStoryData) {
648
			else if (selectedElement instanceof UserStoryData) {
Lines 684-696 Link Here
684
		}
665
		}
685
		
666
		
686
		ArrayList<AbstractRepositoryQuery> queries = new ArrayList<AbstractRepositoryQuery>();
667
		ArrayList<AbstractRepositoryQuery> queries = new ArrayList<AbstractRepositoryQuery>();
687
		int personId = server.getCurrentPersonId();
668
		int personId = client.getCurrentPersonId();
688
		for (UserStoryData userStory : userStories) {
669
		for (UserStoryData userStory : userStories) {
689
			boolean createQuery = true;
670
			boolean createQuery = true;
690
			// if want user specific tasks, only create queries for stories with tasks for
671
			// if want user specific tasks, only create queries for stories with tasks for
691
			// that person
672
			// that person
692
			if (!isUseAll()) {
673
			if (!isUseAll()) {
693
				TaskData[] personUserStoryTasks = server.getUserStoryTasksForPerson(personId, userStory.getId());
674
				TaskData[] personUserStoryTasks = client.getUserStoryTasksForPerson(personId, userStory.getId());
694
				if (personUserStoryTasks == null || personUserStoryTasks.length == 0) {
675
				if (personUserStoryTasks == null || personUserStoryTasks.length == 0) {
695
					createQuery = false;
676
					createQuery = false;
696
				}
677
				}
Lines 704-711 Link Here
704
				}	
685
				}	
705
				
686
				
706
				XPlannerCustomQuery query = new XPlannerCustomQuery(
687
				XPlannerCustomQuery query = new XPlannerCustomQuery(
707
					getRepository().getUrl(), queryName,	
688
					getRepository().getUrl(), queryName);	
708
					TasksUiPlugin.getTaskListManager().getTaskList());
709
				
689
				
710
				applyChanges(query);
690
				applyChanges(query);
711
				query.setQueryName(queryName);
691
				query.setQueryName(queryName);
(-)plugin.xml (-26 / +13 lines)
Lines 3-56 Link Here
3
<plugin>
3
<plugin>
4
4
5
   <extension
5
   <extension
6
         id="org.eclipse.mylar.xplanner.repository"
6
         id="org.eclipse.mylyn.xplanner.repository"
7
         name="%repositoryName"
7
         name="%repositoryName"
8
         point="org.eclipse.mylar.tasks.ui.repositories">
8
         point="org.eclipse.mylyn.tasks.ui.repositories">
9
9
10
      <connectorCore
10
      <connectorCore
11
            class="org.eclipse.mylar.xplanner.ui.XPlannerRepositoryConnector"
11
            class="org.eclipse.mylyn.xplanner.ui.XPlannerRepositoryConnector"
12
            id="org.eclipse.mylar.xplanner.tasklist.repositories"
12
            id="org.eclipse.mylyn.xplanner.tasklist.repositories"
13
            name="%connectorName"
13
            name="%connectorName"
14
            type="xPlanner"/>
14
            type="xPlanner"/>
15
	  <connectorUi
15
	  <connectorUi
16
         brandingIcon="icons/eview16/xplanner-logo.gif"
16
         brandingIcon="icons/eview16/xplanner-logo.gif"
17
         class="org.eclipse.mylar.xplanner.ui.XPlannerRepositoryUi"
17
         class="org.eclipse.mylyn.xplanner.ui.XPlannerRepositoryUi"
18
         name="%connectorUiName"
18
         name="%connectorUiName"
19
         overlayIcon="icons/eview16/overlay-xplanner.gif"/>
19
         overlayIcon="icons/eview16/overlay-xplanner.gif"/>
20
            
20
            
21
      <externalizer 
21
      <taskListFactory
22
            class="org.eclipse.mylar.xplanner.ui.XPlannerTaskExternalizer"
22
            class="org.eclipse.mylyn.xplanner.ui.XPlannerTaskListFactory"
23
            id="org.eclipse.mylar.xplanner.tasklist.externalizer"/>
23
            id="org.eclipse.mylyn.xplanner.tasklist.taskListFactory"/>
24
   </extension>  
24
   </extension>  
25
   
25
   
26
   <extension point="org.eclipse.ui.decorators">
27
      <decorator
28
            class="org.eclipse.mylar.xplanner.ui.XPlannerTaskDecorator"
29
            id="org.eclipse.mylar.xplanner.ui.decorator.task"
30
            label="%decoratorLabelTask"
31
            lightweight="true"
32
            state="true">
33
         <description>%decoratorDescriptionTask</description>
34
         <enablement>
35
            <objectClass name="org.eclipse.mylar.tasks.core.ITaskListElement"/>
36
         </enablement>
37
      </decorator>
38
   </extension>
39
   <!--
26
   <!--
40
   <extension
27
   <extension
41
         point="org.eclipse.ui.editors">
28
         point="org.eclipse.ui.editors">
42
      <editor
29
      <editor
43
            class="org.eclipse.mylar.xplanner.ui.XPlannerTaskEditor"
30
            class="org.eclipse.mylyn.xplanner.ui.XPlannerTaskEditor"
44
            default="false"
31
            default="false"
45
            id="org.eclipse.mylar.xplanner.task.editor"
32
            id="org.eclipse.mylyn.xplanner.task.editor"
46
            name="%editorNameTask"/>
33
            name="%editorNameTask"/>
47
   </extension>
34
   </extension>
48
   -->
35
   -->
49
   <extension
36
   <extension
50
         point="org.eclipse.mylar.tasks.ui.editors">
37
         point="org.eclipse.mylyn.tasks.ui.editors">
51
      <editorFactory
38
      <editorFactory
52
            class="org.eclipse.mylar.xplanner.ui.editor.XPlannerTaskEditorFactory"
39
            class="org.eclipse.mylyn.xplanner.ui.editor.XPlannerTaskEditorFactory"
53
            id="org.eclipse.mylar.xplanner.ui.XPlannerTaskEditorFactory"/>
40
            id="org.eclipse.mylyn.xplanner.ui.XPlannerTaskEditorFactory"/>
54
   </extension>
41
   </extension>
55
42
56
</plugin>
43
</plugin>
(-)plugin.properties (-3 / +3 lines)
Lines 1-8 Link Here
1
bundleName=Mylar Connector for XPlanner
1
bundleName=Mylyn XPlanner UI Plug-in
2
bundleVendor=Eclipse.org
2
bundleVendor=Eclipse.org
3
repositoryName=XPlanner Repository
3
repositoryName=XPlanner Repository
4
connectorName=XPlanner Repository Connector
4
connectorName=XPlanner Repository Connector
5
connectorUiName=XPlanner Repository UI
5
connectorUiName=XPlanner Repository UI
6
decoratorLabelTask=Mylar XPlanner Task Decorator
6
decoratorLabelTask=Mylyn XPlanner Task Decorator
7
decoratorDescriptionTask=Mylar XPlanner Task Decorator
7
decoratorDescriptionTask=Mylyn XPlanner Task Decorator
8
editorNameTask=XPlanner Task Editor
8
editorNameTask=XPlanner Task Editor
(-).project (+2 lines)
Lines 22-28 Link Here
22
		</buildCommand>
22
		</buildCommand>
23
	</buildSpec>
23
	</buildSpec>
24
	<natures>
24
	<natures>
25
		<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
25
		<nature>org.eclipse.pde.PluginNature</nature>
26
		<nature>org.eclipse.pde.PluginNature</nature>
26
		<nature>org.eclipse.jdt.core.javanature</nature>
27
		<nature>org.eclipse.jdt.core.javanature</nature>
28
		<nature>org.eclipse.jem.beaninfo.BeanInfoNature</nature>
27
	</natures>
29
	</natures>
28
</projectDescription>
30
</projectDescription>
(-)META-INF/MANIFEST.MF (-9 / +10 lines)
Lines 1-9 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
Bundle-ManifestVersion: 2
2
Bundle-ManifestVersion: 2
3
Bundle-Name: %bundleName
3
Bundle-Name: %bundleName
4
Bundle-SymbolicName: org.eclipse.mylar.xplanner.ui;singleton:=true
4
Bundle-SymbolicName: org.eclipse.mylyn.xplanner.ui;singleton:=true
5
Bundle-Version: 2.0.0.qualifier
5
Bundle-Version: 2.0.0.qualifier
6
Bundle-Activator: org.eclipse.mylar.xplanner.ui.XPlannerMylarUIPlugin
6
Bundle-Activator: org.eclipse.mylyn.xplanner.ui.XPlannerMylynUIPlugin
7
Bundle-Vendor: %bundleVendor
7
Bundle-Vendor: %bundleVendor
8
Bundle-Localization: plugin
8
Bundle-Localization: plugin
9
Require-Bundle: org.eclipse.ui,
9
Require-Bundle: org.eclipse.ui,
Lines 13-23 Link Here
13
 org.eclipse.search,
13
 org.eclipse.search,
14
 org.eclipse.ui.forms,
14
 org.eclipse.ui.forms,
15
 org.eclipse.help,
15
 org.eclipse.help,
16
 org.eclipse.mylar.xplanner.core,
16
 org.eclipse.mylyn.xplanner.core,
17
 org.eclipse.mylar.tasks.ui,
17
 org.eclipse.mylyn.tasks.ui,
18
 org.eclipse.mylar.context.core,
18
 org.eclipse.mylyn.context.core,
19
 org.eclipse.mylar.tasks.core,
19
 org.eclipse.mylyn.tasks.core,
20
 org.eclipse.mylar
20
 org.eclipse.mylyn,
21
 org.eclipse.mylyn.monitor.core
21
Eclipse-LazyStart: true
22
Eclipse-LazyStart: true
22
Export-Package: org.eclipse.mylar.xplanner.ui,
23
Export-Package: org.eclipse.mylyn.xplanner.ui,
23
 org.eclipse.mylar.xplanner.ui.wizard
24
 org.eclipse.mylyn.xplanner.ui.wizard
(-)src/org/eclipse/mylyn/xplanner/ui/XPlannerTaskListFactory.java (+278 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 - 2007 CodeGear 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
package org.eclipse.mylyn.xplanner.ui;
9
10
import java.util.*;
11
12
import org.eclipse.mylyn.tasks.core.*;
13
import org.w3c.dom.Element;
14
import org.w3c.dom.Node;
15
16
/**
17
 * @author Ravi Kumar 
18
 * @author Helen Bershadskaya 
19
 */
20
public class XPlannerTaskListFactory extends AbstractTaskListFactory {
21
22
	private static final String TOKEN_SEPARATOR = ";"; //$NON-NLS-1$
23
24
	private static final String KEY_XPLANNER = "XPlanner"; //$NON-NLS-1$
25
26
	private static final String KEY_CUSTOM = "XPlannerCustom"; //$NON-NLS-1$
27
28
	private static final String KEY_XPLANNER_QUERY = KEY_XPLANNER + KEY_QUERY;
29
30
	private static final String KEY_XPLANNER_CUSTOM = KEY_XPLANNER + KEY_CUSTOM + KEY_QUERY;
31
32
	private static final String KEY_XPLANNER_ITEM = "XPlannerItem"; //$NON-NLS-1$
33
34
	private static final String KEY_QUERY_CONTENT_ID_TYPE = "QueryContentIdType"; //$NON-NLS-1$
35
36
	private static final String KEY_QUERY_IS_TASKS = "QueryIsTasks"; //$NON-NLS-1$
37
38
	private static final String KEY_QUERY_CONTENT_ID = "QueryConentId"; //$NON-NLS-1$
39
40
	private static final String KEY_QUERY_PERSON_ID = "QueryPersonId"; //$NON-NLS-1$
41
42
	private static final String KEY_QUERY_MY_CURRENT_TASKS = "QueryMyCurrentTasks"; //$NON-NLS-1$
43
44
	public boolean canReadQuery(Node node) {
45
		return node.getNodeName().equals(KEY_XPLANNER_QUERY) || node.getNodeName().equals(KEY_XPLANNER_CUSTOM);
46
	}
47
48
	public boolean canCreateElementFor(AbstractRepositoryQuery category) {
49
		return category instanceof XPlannerCustomQuery;
50
	}
51
52
	public boolean canCreateElementFor(AbstractTask task) {
53
		return task instanceof XPlannerTask;
54
	}
55
56
	@Override
57
	public AbstractRepositoryQuery createQuery(String repositoryUrl, String queryString, String label, Element element) {
58
		AbstractRepositoryQuery query = null;
59
		query = new XPlannerCustomQuery(repositoryUrl, label);
60
		initializeQuery((XPlannerCustomQuery)query, element);
61
62
		return query;
63
	}
64
65
	private void initializeQuery(XPlannerCustomQuery query, Element element) {
66
		String myCurrentTasks = element.getAttribute(KEY_QUERY_MY_CURRENT_TASKS);
67
		if (myCurrentTasks != null && Boolean.valueOf(myCurrentTasks)) {
68
			query.setMyCurrentTasks(true);
69
		}
70
		else {
71
			// selected content type
72
			String contentIdType = element.getAttribute(KEY_QUERY_CONTENT_ID_TYPE);
73
			if (contentIdType != null) {
74
				query.setContentIdType((XPlannerCustomQuery.ContentIdType.valueOf(contentIdType)));
75
			}
76
77
			// use tasks?
78
			String useTasks = element.getAttribute(KEY_QUERY_IS_TASKS);
79
			if (useTasks != null) {
80
			  query.setUseTasks(Boolean.valueOf(useTasks));
81
			}  
82
			
83
			// use all?
84
			String personId = element.getAttribute(KEY_QUERY_PERSON_ID);
85
			if (personId != null) {
86
			  query.setPersonId(Integer.valueOf(personId));
87
			}  
88
			
89
			// content id
90
			String contentIds = element.getAttribute(KEY_QUERY_CONTENT_ID);
91
			if (contentIds != null) {
92
				query.setContentIds(decodeIds(contentIds));
93
			}
94
		}	
95
	}
96
	
97
	private String encodeIds(List<Integer> contentIds) {
98
		StringBuilder result = new StringBuilder();
99
		for (Iterator<Integer> iter = contentIds.iterator(); iter.hasNext();) {
100
			Integer id = iter.next();
101
			result.append(id);
102
			if (iter.hasNext()) {
103
				result.append(TOKEN_SEPARATOR);
104
			}
105
		}
106
107
		return result.toString();
108
	}
109
110
	private List<Integer> decodeIds(String encoded) {
111
		if (encoded == null) {
112
			return XPlannerCustomQuery.INVALID_IDS;
113
		}
114
		
115
		StringTokenizer tokens = new StringTokenizer(encoded, TOKEN_SEPARATOR);
116
		ArrayList<Integer> ids = new ArrayList<Integer>();
117
		while (tokens.hasMoreTokens()) {
118
			ids.add(Integer.valueOf(tokens.nextToken()));
119
		}
120
		
121
		return ids;
122
	}
123
124
	
125
	public Set<String> getQueryElementNames() {
126
		Set<String> names = new HashSet<String>();
127
		names.add(KEY_XPLANNER_CUSTOM);
128
		return names;
129
	}
130
131
	public void setAdditionalAttributes(AbstractRepositoryQuery query, Element node) {
132
//		String queryTagName = getQueryTagNameForElement(query);
133
134
//		node.setAttribute(KEY_NAME, query.getSummary());
135
//		node.setAttribute(KEY_QUERY_STRING, query.getUrl());
136
//		node.setAttribute(KEY_REPOSITORY_URL, query.getRepositoryUrl());
137
138
		XPlannerCustomQuery xplannerCustomQuery = (XPlannerCustomQuery) query;
139
		
140
		// name
141
//		String queryName = xplannerCustomQuery.getQueryName();
142
//		node.setAttribute(KEY_QUERY_NAME, queryName);
143
		
144
		boolean isMyCurrentTasks = xplannerCustomQuery.isMyCurrentTasks();
145
		if (isMyCurrentTasks) {
146
			// show only my current tasks
147
			node.setAttribute(KEY_QUERY_MY_CURRENT_TASKS, Boolean.toString(true));
148
		}
149
		else {
150
			// don't show only my current tasks
151
			node.setAttribute(KEY_QUERY_MY_CURRENT_TASKS, Boolean.toString(false));
152
			
153
			// selected content type
154
			String contentIdType = xplannerCustomQuery.getContentIdType().name();
155
			node.setAttribute(KEY_QUERY_CONTENT_ID_TYPE, contentIdType);
156
157
			// is tasks
158
			boolean isUseTasks = xplannerCustomQuery.isUseTasks();
159
			node.setAttribute(KEY_QUERY_IS_TASKS, Boolean.toString(isUseTasks));
160
			
161
			// content id
162
			List<Integer> contentIds = xplannerCustomQuery.getContentIds();
163
			node.setAttribute(KEY_QUERY_CONTENT_ID, encodeIds(contentIds));
164
			
165
			// person id
166
			int personId = xplannerCustomQuery.getPersonId();
167
			node.setAttribute(KEY_QUERY_PERSON_ID, Integer.toString(personId));
168
		}
169
//		
170
//		for (AbstractTask hit : query.getHits()) {
171
//				try {
172
//					Element element = null;
173
//					for (ITaskListExternalizer externalizer : super.getDelegateExternalizers()) {
174
//						if (externalizer.canCreateElementFor(hit)) {
175
//							element = createQueryHitElement(hit, doc, node);
176
//						}
177
//					}
178
//					if (element == null) {
179
//						createQueryHitElement(hit, doc, node);
180
//					}	
181
//				} 
182
//				catch (Exception e) {
183
//					StatusManager.log(e, e.getMessage());
184
//				}
185
//		}
186
//		parent.appendChild(node);
187
//		return node;
188
	}
189
190
//	public Element createQueryElement(AbstractRepositoryQuery query, Document doc, Element parent) {
191
//		String queryTagName = getQueryTagNameForElement(query);
192
//		Element node = doc.createElement(queryTagName);
193
//
194
//		node.setAttribute(KEY_NAME, query.getSummary());
195
//		node.setAttribute(KEY_QUERY_STRING, query.getUrl());
196
//		node.setAttribute(KEY_REPOSITORY_URL, query.getRepositoryUrl());
197
//
198
//		XPlannerCustomQuery xplannerCustomQuery = (XPlannerCustomQuery) query;
199
//		
200
//		// name
201
//		String queryName = xplannerCustomQuery.getQueryName();
202
//		node.setAttribute(KEY_QUERY_NAME, queryName);
203
//		
204
//		boolean isMyCurrentTasks = xplannerCustomQuery.isMyCurrentTasks();
205
//		if (isMyCurrentTasks) {
206
//			// show only my current tasks
207
//			node.setAttribute(KEY_QUERY_MY_CURRENT_TASKS, Boolean.toString(true));
208
//		}
209
//		else {
210
//			// don't show only my current tasks
211
//			node.setAttribute(KEY_QUERY_MY_CURRENT_TASKS, Boolean.toString(false));
212
//			
213
//			// selected content type
214
//			String contentIdType = xplannerCustomQuery.getContentIdType().name();
215
//			node.setAttribute(KEY_QUERY_CONTENT_ID_TYPE, contentIdType);
216
//
217
//			// is tasks
218
//			boolean isUseTasks = xplannerCustomQuery.isUseTasks();
219
//			node.setAttribute(KEY_QUERY_IS_TASKS, Boolean.toString(isUseTasks));
220
//			
221
//			// content id
222
//			List<Integer> contentIds = xplannerCustomQuery.getContentIds();
223
//			node.setAttribute(KEY_QUERY_CONTENT_ID, encodeIds(contentIds));
224
//			
225
//			// person id
226
//			int personId = xplannerCustomQuery.getPersonId();
227
//			node.setAttribute(KEY_QUERY_PERSON_ID, Integer.toString(personId));
228
//		}
229
//		
230
//		for (AbstractTask hit : query.getHits()) {
231
//				try {
232
//					Element element = null;
233
//					for (ITaskListExternalizer externalizer : super.getDelegateExternalizers()) {
234
//						if (externalizer.canCreateElementFor(hit)) {
235
//							element = createQueryHitElement(hit, doc, node);
236
//						}
237
//					}
238
//					if (element == null) {
239
//						createQueryHitElement(hit, doc, node);
240
//					}	
241
//				} 
242
//				catch (Exception e) {
243
//					StatusManager.log(e, e.getMessage());
244
//				}
245
//		}
246
//		parent.appendChild(node);
247
//		return node;
248
//	}
249
250
	@Override
251
	public String getTaskElementName() {
252
		return KEY_XPLANNER_ITEM;
253
	}
254
255
	@Override
256
	public AbstractTask createTask(String repositoryUrl, String taskId, String summary, Element element) {
257
		return new XPlannerTask(repositoryUrl, taskId, summary);
258
	}
259
260
	@Override
261
	public String getQueryElementName(AbstractRepositoryQuery query) {
262
		if (query instanceof XPlannerCustomQuery) {
263
			return KEY_XPLANNER_CUSTOM;
264
		}
265
		return ""; //$NON-NLS-1$
266
	}
267
268
	@Override
269
	public boolean canCreate(AbstractRepositoryQuery category) {
270
		return category instanceof XPlannerCustomQuery;
271
	}
272
273
	@Override
274
	public boolean canCreate(AbstractTask task) {
275
		return task instanceof XPlannerTask;
276
	}
277
278
}
(-)src/org/eclipse/mylyn/xplanner/ui/XPlannerClientFacade.java (+190 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 - 2007 CodeGear 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
package org.eclipse.mylyn.xplanner.ui;
9
10
import java.net.*;
11
12
import org.eclipse.core.runtime.CoreException;
13
import org.eclipse.mylyn.monitor.core.StatusHandler;
14
import org.eclipse.mylyn.tasks.core.ITaskRepositoryListener;
15
import org.eclipse.mylyn.tasks.core.TaskRepository;
16
import org.eclipse.mylyn.tasks.ui.TasksUiPlugin;
17
import org.eclipse.mylyn.xplanner.core.XPlannerClientManager;
18
import org.eclipse.mylyn.xplanner.core.XPlannerCorePlugin;
19
import org.eclipse.mylyn.xplanner.core.service.XPlannerClient;
20
import org.eclipse.mylyn.xplanner.core.service.exceptions.AuthenticationException;
21
import org.eclipse.mylyn.xplanner.core.service.exceptions.ServiceUnavailableException;
22
23
/**
24
 * This class acts as a layer of indirection between clients in this project and
25
 * the server API implemented by the XPlanner Dashboard, and also abstracts some
26
 * Mylyn implementation details. It initializes an XPlannerClient object and serves
27
 * as the central location to get a reference to it.
28
 * 
29
 * @author Ravi Kumar 
30
 * @author Helen Bershadskaya 
31
 * 
32
 */
33
public class XPlannerClientFacade implements ITaskRepositoryListener {
34
35
	private XPlannerClientManager clientManager = null;
36
37
	private static XPlannerClientFacade instance = null;
38
39
	public XPlannerClientFacade() {
40
		TasksUiPlugin.getRepositoryManager().addListener(this);
41
		clientManager = XPlannerCorePlugin.getDefault().getClientManager();
42
	}
43
44
	/**
45
	 * Lazily creates client.
46
	 */
47
	public XPlannerClient getXPlannerClient(TaskRepository repository) throws CoreException {
48
		try {
49
			XPlannerRepositoryUtils.checkRepositoryValidated(repository.getUrl());
50
			String serverHostname = getServerHost(repository);
51
		XPlannerClient client = clientManager.getClient(serverHostname);
52
//TODO: add this check back once the listeners for client property change are hooked up
53
// Also handle the case when serviceDelegate in the cachedClient is null
54
55
//			if (client == null) {
56
				client = clientManager.createClient(serverHostname, repository.getUrl(), false,
57
						repository.getUserName(), repository.getPassword(), false, repository.getProxy(),
58
						repository.getHttpUser(), repository.getHttpPassword());
59
				clientManager.addClient(client);
60
//			}
61
			if (client == null) {
62
				throw new ServiceUnavailableException(serverHostname + " " + repository.getUrl()); //$NON-NLS-1$
63
			}
64
			return client;
65
		} 
66
		catch (CoreException ce) {
67
			StatusHandler.log(Messages.XPlannerClientFacade_SERVER_CONNECTION_ERROR, this);
68
			throw ce;
69
		}
70
		catch (ServiceUnavailableException sue) {
71
			throw sue;
72
		} 
73
		catch (RuntimeException e) {
74
			StatusHandler.log(Messages.XPlannerClientFacade_SERVER_CONNECTION_ERROR, this);
75
			throw e;
76
		}
77
	}
78
79
	public static XPlannerClientFacade getDefault() {
80
		if (instance == null) {
81
			instance = new XPlannerClientFacade();
82
		}
83
		return instance;
84
	}
85
86
	public void logOutFromAll() {
87
		try {
88
			XPlannerClient[] allClients = clientManager.getAllClients();
89
			for (int i = 0; i < allClients.length; i++) {
90
				allClients[i].logout();
91
			}
92
		} catch (Exception e) {
93
			// ignore
94
		}
95
	}
96
97
	public void repositoriesRead() {
98
		// ignore
99
	}
100
101
	public void repositoryAdded(TaskRepository repository) {
102
		if (repository.getConnectorKind().equals(XPlannerMylynUIPlugin.REPOSITORY_KIND)) {
103
			try {
104
				getXPlannerClient(repository);
105
			}
106
			catch (CoreException e) {
107
				StatusHandler.log(e.getMessage(), this); 
108
			}
109
		}
110
	}
111
112
	public void repositoryRemoved(TaskRepository repository) {
113
		if (repository.getConnectorKind().equals(XPlannerMylynUIPlugin.REPOSITORY_KIND)) {
114
			String serverHostname = getServerHost(repository);
115
			XPlannerClient client = clientManager.getClient(serverHostname);
116
			removeClient(client);
117
			XPlannerRepositoryUtils.removeValidatedRepositoryUrl(repository.getUrl());
118
		}
119
	}
120
	
121
	public void repositorySettingsChanged(TaskRepository repository) {
122
		repositoryRemoved(repository);
123
		repositoryAdded(repository);
124
	}
125
126
	public void refreshClientSettings(TaskRepository repository) {
127
		String serverHostname = getServerHost(repository);
128
		XPlannerClient client = clientManager.getClient(serverHostname);
129
		if (client != null) {
130
			client.refreshDetails();
131
		}
132
	}
133
	
134
	
135
	private void removeClient(XPlannerClient client) {
136
		if (client != null) {
137
			client.logout();
138
			clientManager.removeClient(client);
139
		}
140
	} 
141
142
	/**
143
	 * Validate the server URL and user credentials
144
	 * @param serverUrl Location of the XPlanner Server
145
	 * @param user Username
146
	 * @param password Password
147
	 * @param proxy Proxy
148
	 * @param httpUser http user name
149
	 * @param httpPassword http password
150
	 * @return String describing validation failure or null if the details are valid
151
	 */
152
	public void validateServerAndCredentials(String serverUrl, String user, 
153
		String password, Proxy proxy, String httpUser, String httpPassword) throws Exception {
154
		
155
		XPlannerRepositoryUtils.removeValidatedRepositoryUrl(serverUrl);
156
		clientManager.testConnection(serverUrl, user, password, proxy, httpUser, httpPassword);
157
		XPlannerRepositoryUtils.addValidatedRepositoryUrl(serverUrl);
158
	}
159
160
	private static String getServerHost(TaskRepository repository) {
161
		try {
162
			return new URL(repository.getUrl()).getHost();
163
		} catch (MalformedURLException ex) {
164
			throw new RuntimeException(Messages.XPlannerClientFacade_INVALID_URL_EXCEPTION+repository.getUrl(), ex);
165
		}
166
	}
167
	
168
	/**
169
	 * TODO: refactor
170
	 */
171
	public static void handleConnectionException(Exception e) {
172
		if (e instanceof ServiceUnavailableException) {
173
			StatusHandler.fail(e, Messages.XPlannerClientFacade_CONNECTION_FAILURE_ERROR
174
					+ Messages.XPlannerClientFacade_NETWORK_CONNECTION_FAILURE,
175
					true);
176
		} 
177
		else if (e instanceof AuthenticationException) {
178
			StatusHandler.fail(e, Messages.XPlannerClientFacade_AUTHENTICATION_FAILED
179
					+ Messages.XPlannerClientFacade_USERNAME_PASSWORD_ERROR, true);
180
		} 
181
		else if (e instanceof RuntimeException) {
182
			StatusHandler.fail(e, Messages.XPlannerClientFacade_NO_REPOSITORY_FOUND
183
					+ Messages.XPlannerClientFacade_VERIFY_VALID_REPOSITORY, true);
184
		} 
185
		else {
186
			StatusHandler.fail(e, Messages.XPlannerClientFacade_COULD_NOT_CONNECT_TO_REPOSITORY
187
					+ Messages.XPlannerClientFacade_CHECK_CREDENTIALS, true);
188
		}
189
	}	
190
}
(-)src/org/eclipse/mylyn/xplanner/ui/XPlannerTaskDataHandler.java (+140 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 - 2007 CodeGear 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
package org.eclipse.mylyn.xplanner.ui;
9
10
import java.net.Proxy;
11
import java.rmi.RemoteException;
12
import java.util.HashSet;
13
import java.util.Set;
14
15
import javax.security.auth.login.LoginException;
16
17
import org.eclipse.core.runtime.*;
18
import org.eclipse.mylyn.tasks.core.*;
19
import org.eclipse.mylyn.tasks.ui.TasksUiPlugin;
20
import org.eclipse.mylyn.xplanner.core.XPlannerCorePlugin;
21
import org.eclipse.mylyn.xplanner.core.service.XPlannerClient;
22
import org.xplanner.soap.TaskData;
23
import org.xplanner.soap.UserStoryData;
24
25
/**
26
 * @author Ravi Kumar
27
 * @author Helen Bershadskaya
28
 */
29
public class XPlannerTaskDataHandler extends AbstractTaskDataHandler {
30
	private AbstractAttributeFactory attributeFactory = new XPlannerAttributeFactory();
31
	
32
	public XPlannerTaskDataHandler(TaskList taskList) {
33
		//TODO -- tasklist?
34
	}
35
	
36
	public RepositoryTaskData downloadTaskData(AbstractTask repositoryTask, TaskRepository repository, Proxy proxySettings) 
37
		throws CoreException, LoginException {
38
		
39
		if (!(repositoryTask instanceof XPlannerTask)) {
40
			return null;
41
		}
42
		
43
		RepositoryTaskData repositoryTaskData = null;
44
		XPlannerTask xplannerTask = (XPlannerTask)repositoryTask;
45
		
46
		XPlannerClient client = XPlannerClientFacade.getDefault().getXPlannerClient(repository);
47
		repositoryTaskData = XPlannerRepositoryUtils.createRepositoryTaskData(repository, xplannerTask, client); 
48
		
49
		return repositoryTaskData;
50
	}
51
52
	public boolean initializeTaskData(TaskRepository repository, RepositoryTaskData data, IProgressMonitor monitor)
53
		throws CoreException {
54
		
55
		// currently don't create new tasks
56
		return false;
57
	}
58
59
	public AbstractAttributeFactory getAttributeFactory(String repositoryUrl, String repositoryKind, String taskKind) {
60
		return attributeFactory;
61
	}
62
	
63
	public AbstractAttributeFactory getAttributeFactory(RepositoryTaskData taskData) {
64
		return getAttributeFactory(taskData.getRepositoryUrl(), taskData.getRepositoryKind(), taskData.getTaskKind());
65
	}
66
67
	public String postTaskData(TaskRepository repository, RepositoryTaskData taskData, IProgressMonitor monitor)
68
		throws CoreException {
69
		String resultId = null;
70
		
71
		try {
72
			resultId = postChangesToRepository(taskData);
73
		} 
74
		catch (Exception e) {
75
			throw new CoreException(new Status(Status.ERROR,
76
					XPlannerCorePlugin.ID, Status.ERROR, Messages.XPlannerOfflineTaskHandler_CANNOT_POST_DATA_TO_SERVER, null));
77
		}
78
		
79
		return resultId;
80
	}
81
82
	private String postChangesToRepository(RepositoryTaskData repositoryTaskData) throws CoreException {
83
		String error = null;
84
		
85
		TaskRepository repository = TasksUiPlugin.getRepositoryManager().getRepository(
86
				repositoryTaskData.getRepositoryKind(), repositoryTaskData.getRepositoryUrl());
87
		
88
		XPlannerClient client = XPlannerClientFacade.getDefault().getXPlannerClient(repository);
89
		if (client != null) {
90
			try {
91
				// first check if taskdata exists
92
				TaskData taskData = client.getTask(Integer.valueOf(repositoryTaskData.getId()).intValue());
93
				if (taskData != null) {
94
					taskData.setName(repositoryTaskData.getSummary());
95
					taskData.setDescription(XPlannerRepositoryUtils.getDescription(repositoryTaskData));
96
					taskData.setEstimatedHours(Double.valueOf(
97
							repositoryTaskData.getAttribute(XPlannerAttributeFactory.ATTRIBUTE_EST_HOURS_NAME).getValue()));
98
					taskData.setCompleted(XPlannerRepositoryUtils.isCompleted(repositoryTaskData));
99
					client.update(taskData);
100
				}
101
				else {
102
					// otherwise check if a user story exists
103
					UserStoryData userStory = client.getUserStory(Integer.valueOf(repositoryTaskData.getId()).intValue());
104
					if (userStory != null) {
105
						userStory.setName(repositoryTaskData.getSummary());
106
						userStory.setDescription(XPlannerRepositoryUtils.getDescription(repositoryTaskData));
107
						userStory.setActualHours(Double.valueOf(
108
								repositoryTaskData.getAttribute(XPlannerAttributeFactory.ATTRIBUTE_ACT_HOURS_NAME).getValue()));
109
						client.update(userStory);
110
					}
111
				}
112
			} 
113
			catch (NumberFormatException e) {
114
				XPlannerMylynUIPlugin.log(e.getCause(), "", false); //$NON-NLS-1$
115
				error = e.getMessage();
116
			} 
117
			catch (RemoteException e) {
118
				XPlannerMylynUIPlugin.log(e.getCause(), "", false); //$NON-NLS-1$
119
				error = e.getMessage();
120
			}
121
		}
122
		
123
		return error;
124
	}
125
126
	public RepositoryTaskData getTaskData(TaskRepository repository, String taskId, IProgressMonitor monitor)
127
		throws CoreException {
128
		
129
		return XPlannerRepositoryUtils.createRepositoryTaskData(repository, taskId);
130
	}
131
	
132
	public Set<String> getSubTaskIds(RepositoryTaskData taskData) {
133
		Set<String> subIds = new HashSet<String>();
134
		RepositoryTaskAttribute attribute = taskData.getAttribute(XPlannerAttributeFactory.Attribute.SUBTASK_IDS.getCommonAttributeKey());
135
		if (attribute != null) {
136
			subIds.addAll(attribute.getValues());
137
		}
138
		return subIds;
139
	}
140
}
(-)src/org/eclipse/mylyn/xplanner/ui/XPlannerMylynUIPlugin.java (+97 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 - 2007 CodeGear 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
package org.eclipse.mylyn.xplanner.ui;
9
10
import org.eclipse.core.runtime.*;
11
import org.eclipse.jface.dialogs.MessageDialog;
12
import org.eclipse.jface.resource.ImageDescriptor;
13
import org.eclipse.mylyn.monitor.core.StatusHandler;
14
import org.eclipse.swt.widgets.Shell;
15
import org.eclipse.ui.PlatformUI;
16
import org.eclipse.ui.plugin.AbstractUIPlugin;
17
import org.osgi.framework.BundleContext;
18
19
/**
20
 * @author Ravi Kumar 
21
 * @author Helen Bershadskaya 
22
 */
23
public class XPlannerMylynUIPlugin extends AbstractUIPlugin {
24
25
	private static XPlannerMylynUIPlugin INSTANCE;
26
27
	public static final String PLUGIN_ID = "org.eclipse.mylyn.xplanner.ui"; //$NON-NLS-1$
28
29
	public final static String REPOSITORY_KIND = "xplanner"; //$NON-NLS-1$
30
31
	public final static String XPLANNER_CLIENT_LABEL = Messages.MylynXPlannerPlugin_CLIENT_LABEL;
32
33
	public final static String TITLE_MESSAGE_DIALOG = Messages.MylynXPlannerPlugin_CLIENT_DIALOG_TITLE;
34
35
	public static final String DELIM_URL_PREFIX = "/do/view/"; //$NON-NLS-1$
36
37
	public final static String DELIM_URL_SUFFIX = "?oid="; //$NON-NLS-1$
38
39
	public final static String TASK_URL_PREFIX = DELIM_URL_PREFIX + "task" + DELIM_URL_SUFFIX; //$NON-NLS-1$
40
41
	public final static String USER_STORY_URL_PREFIX = DELIM_URL_PREFIX + "userstory" + DELIM_URL_SUFFIX; //$NON-NLS-1$
42
43
	public final static String ITERATION_URL_PREFIX = DELIM_URL_PREFIX + "iteration" + DELIM_URL_SUFFIX; //$NON-NLS-1$
44
45
	public final static IStatus NO_LICENSE_STATUS = new Status(IStatus.INFO, XPlannerMylynUIPlugin.PLUGIN_ID,
46
			0, Messages.MylynXPlannerPlugin_NOT_AVAILABLE_IN_SKU, null);
47
48
	public XPlannerMylynUIPlugin() {
49
		INSTANCE = this;
50
	}
51
52
	public void stop(BundleContext context) throws Exception {
53
		super.stop(context);
54
		INSTANCE = null;
55
		XPlannerClientFacade.getDefault().logOutFromAll();
56
	}
57
58
	public static void log(final Throwable e, final String message, boolean informUser) {
59
		if (Platform.isRunning() && informUser) {
60
			try {
61
				PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
62
					public void run() {
63
						Shell shell = null;
64
						if (PlatformUI.getWorkbench() != null
65
								&& PlatformUI.getWorkbench().getActiveWorkbenchWindow() != null) {
66
							shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
67
						}
68
						String displayMessage = message == null ? e.getMessage() : message + "\n" + e.getMessage(); //$NON-NLS-1$
69
						MessageDialog.openError(shell, Messages.MylynXPlannerPlugin_XPLANNER_ERROR_TITLE, displayMessage); 
70
					}
71
				});
72
			} 
73
			catch (Throwable t) {
74
				t.printStackTrace();
75
			}
76
		}
77
		else {
78
			StatusHandler.log(e, message == null ? Messages.MylynXPlannerPlugin_XPLANNER_ERROR_TITLE : message);
79
		}
80
	}
81
82
	public static XPlannerMylynUIPlugin getDefault() {
83
		return INSTANCE;
84
	}
85
86
	/**
87
	 * Returns an image descriptor for the image file at the given plug-in
88
	 * relative path.
89
	 * 
90
	 * @param path
91
	 *            the path
92
	 * @return the image descriptor
93
	 */
94
	public static ImageDescriptor getImageDescriptor(String path) {
95
		return AbstractUIPlugin.imageDescriptorFromPlugin(PLUGIN_ID, path);
96
	}
97
}
(-)src/org/eclipse/mylyn/xplanner/ui/MylynXPlannerUtils.java (+32 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 - 2007 CodeGear 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
package org.eclipse.mylyn.xplanner.ui;
9
10
import org.eclipse.mylyn.tasks.core.TaskRepository;
11
import org.eclipse.mylyn.xplanner.ui.wizard.NewXPlannerQueryWizard;
12
13
/**
14
 * @author Ravi Kumar
15
 * @author Helen Bershadskaya
16
 */
17
public class MylynXPlannerUtils {
18
	private MylynXPlannerUtils() {
19
		
20
	}
21
	
22
	public static void addNewMyTasksQuery(TaskRepository repository,
23
		String name) {
24
		
25
		XPlannerCustomQuery myTasksQuery = 
26
			new XPlannerCustomQuery(repository.getUrl(), name);
27
		
28
		myTasksQuery.setMyCurrentTasks(true);
29
		NewXPlannerQueryWizard.addQuery(myTasksQuery, repository);
30
	}
31
			
32
}
(-)src/org/eclipse/mylyn/xplanner/tests/XPlannerRepositoryConnectorTest.java (-26 / +25 lines)
Lines 5-33 Link Here
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
package org.eclipse.mylar.xplanner.tests;
8
package org.eclipse.mylyn.xplanner.tests;
9
9
10
import junit.framework.TestCase;
10
import junit.framework.TestCase;
11
11
12
import org.eclipse.mylar.tasks.core.AbstractRepositoryConnector;
12
import org.eclipse.core.runtime.NullProgressMonitor;
13
import org.eclipse.mylar.tasks.core.AbstractRepositoryTask;
13
import org.eclipse.mylyn.tasks.core.*;
14
import org.eclipse.mylar.tasks.core.TaskRepository;
14
import org.eclipse.mylyn.tasks.ui.TasksUiPlugin;
15
import org.eclipse.mylar.tasks.ui.TasksUiPlugin;
15
import org.eclipse.mylyn.xplanner.core.service.XPlannerClient;
16
import org.eclipse.mylar.xplanner.core.service.XPlannerServer;
16
import org.eclipse.mylyn.xplanner.ui.XPlannerRepositoryConnector;
17
import org.eclipse.mylar.xplanner.ui.XPlannerRepositoryConnector;
17
import org.eclipse.mylyn.xplanner.ui.XPlannerTask;
18
import org.eclipse.mylar.xplanner.ui.XPlannerTask;
19
import org.xplanner.soap.TaskData;
18
import org.xplanner.soap.TaskData;
20
import org.xplanner.soap.UserStoryData;
19
import org.xplanner.soap.UserStoryData;
21
20
22
public class XPlannerRepositoryConnectorTest extends TestCase {
21
public class XPlannerRepositoryConnectorTest extends TestCase {
23
	private static XPlannerServer server;
22
	private static XPlannerClient client;
24
	
23
	
25
	protected void setUp() throws Exception {
24
	protected void setUp() throws Exception {
26
		super.setUp();
25
		super.setUp();
27
		if (server == null) { // only create data once per run
26
		if (client == null) { // only create data once per run
28
			server = XPlannerTestUtils.getXPlannerServer();
27
			client = XPlannerTestUtils.getXPlannerClient();
29
			XPlannerTestUtils.clearTestData(server);
28
			XPlannerTestUtils.clearTestData(client);
30
			XPlannerTestUtils.setUpTestData(server);
29
			XPlannerTestUtils.setUpTestData(client);
31
		}
30
		}
32
	}
31
	}
33
32
Lines 38-50 Link Here
38
	public void testCreateTaskFromExistingKeyForUserStory() throws Exception {
37
	public void testCreateTaskFromExistingKeyForUserStory() throws Exception {
39
		TaskRepository repository = XPlannerTestUtils.getRepository();
38
		TaskRepository repository = XPlannerTestUtils.getRepository();
40
		AbstractRepositoryConnector connector = 
39
		AbstractRepositoryConnector connector = 
41
			TasksUiPlugin.getRepositoryManager().getRepositoryConnector(repository.getKind());
40
			TasksUiPlugin.getRepositoryManager().getRepositoryConnector(repository.getConnectorKind());
42
		UserStoryData testUserStory = XPlannerTestUtils.findTestUserStory(server);
41
		UserStoryData testUserStory = XPlannerTestUtils.findTestUserStory(client);
43
42
44
		assertTrue(testUserStory != null);
43
		assertTrue(testUserStory != null);
45
		
44
		
46
		AbstractRepositoryTask repositoryTask = 
45
		AbstractTask repositoryTask = 
47
			connector.createTaskFromExistingKey(repository, "" + testUserStory.getId());
46
			connector.createTaskFromExistingId(repository, "" + testUserStory.getId(), new NullProgressMonitor());
48
		
47
		
49
		assertTrue(repositoryTask instanceof XPlannerTask);
48
		assertTrue(repositoryTask instanceof XPlannerTask);
50
		assertTrue(((XPlannerTask)repositoryTask).getSummary().equals(testUserStory.getName()));
49
		assertTrue(((XPlannerTask)repositoryTask).getSummary().equals(testUserStory.getName()));
Lines 53-65 Link Here
53
	public void testCreateTaskFromExistingKeyForTask() throws Exception {
52
	public void testCreateTaskFromExistingKeyForTask() throws Exception {
54
		TaskRepository repository = XPlannerTestUtils.getRepository();
53
		TaskRepository repository = XPlannerTestUtils.getRepository();
55
		AbstractRepositoryConnector connector = 
54
		AbstractRepositoryConnector connector = 
56
			TasksUiPlugin.getRepositoryManager().getRepositoryConnector(repository.getKind());
55
			TasksUiPlugin.getRepositoryManager().getRepositoryConnector(repository.getConnectorKind());
57
		TaskData testTask = XPlannerTestUtils.findTestTask(server);
56
		TaskData testTask = XPlannerTestUtils.findTestTask(client);
58
57
59
		assertTrue(testTask != null);
58
		assertTrue(testTask != null);
60
		
59
		
61
		AbstractRepositoryTask repositoryTask = 
60
		AbstractTask repositoryTask = 
62
			connector.createTaskFromExistingKey(repository, "" + testTask.getId());
61
			connector.createTaskFromExistingId(repository, "" + testTask.getId(), new NullProgressMonitor());
63
		
62
		
64
		assertTrue(repositoryTask instanceof XPlannerTask);
63
		assertTrue(repositoryTask instanceof XPlannerTask);
65
		assertTrue(((XPlannerTask)repositoryTask).getSummary().equals(testTask.getName()));
64
		assertTrue(((XPlannerTask)repositoryTask).getSummary().equals(testTask.getName()));
Lines 68-79 Link Here
68
	public void testUpdateTaskDetailsCompleted() throws Exception {
67
	public void testUpdateTaskDetailsCompleted() throws Exception {
69
		TaskRepository repository = XPlannerTestUtils.getRepository();
68
		TaskRepository repository = XPlannerTestUtils.getRepository();
70
		AbstractRepositoryConnector connector = 
69
		AbstractRepositoryConnector connector = 
71
			TasksUiPlugin.getRepositoryManager().getRepositoryConnector(repository.getKind());
70
			TasksUiPlugin.getRepositoryManager().getRepositoryConnector(repository.getConnectorKind());
72
		
71
		
73
		assertTrue(connector instanceof XPlannerRepositoryConnector);
72
		assertTrue(connector instanceof XPlannerRepositoryConnector);
74
		XPlannerRepositoryConnector xplannerConnector = (XPlannerRepositoryConnector) connector;
73
		XPlannerRepositoryConnector xplannerConnector = (XPlannerRepositoryConnector) connector;
75
		TaskData testTask = XPlannerTestUtils.findTestTask(server);
74
		TaskData testTask = XPlannerTestUtils.findTestTask(client);
76
		XPlannerTask repositoryTask = XPlannerTestUtils.getTestXPlannerTask(server);
75
		XPlannerTask repositoryTask = XPlannerTestUtils.getTestXPlannerTask(client);
77
76
78
		assertTrue(testTask != null);
77
		assertTrue(testTask != null);
79
		assertTrue(repositoryTask != null);
78
		assertTrue(repositoryTask != null);
Lines 84-97 Link Here
84
		
83
		
85
		// mark testTask as completed
84
		// mark testTask as completed
86
		testTask.setCompleted(true);
85
		testTask.setCompleted(true);
87
		server.update(testTask);
86
		client.update(testTask);
88
		
87
		
89
		xplannerConnector.updateTaskDetails(repository.getUrl(), repositoryTask, testTask, false);
88
		xplannerConnector.updateTaskDetails(repository.getUrl(), repositoryTask, testTask, false);
90
		assertTrue(repositoryTask.isCompleted());
89
		assertTrue(repositoryTask.isCompleted());
91
		
90
		
92
		//restore testTask's completion state
91
		//restore testTask's completion state
93
		testTask.setCompleted(originalCompleted);
92
		testTask.setCompleted(originalCompleted);
94
		server.update(testTask);
93
		client.update(testTask);
95
	}
94
	}
96
95
97
}
96
}
(-)src/org/eclipse/mylyn/xplanner/tests/XPlannerCustomQueryTest.java (-26 / +25 lines)
Lines 5-37 Link Here
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
package org.eclipse.mylar.xplanner.tests;
8
package org.eclipse.mylyn.xplanner.tests;
9
9
10
import java.rmi.RemoteException;
10
import java.rmi.RemoteException;
11
import java.util.List;
11
import java.util.Set;
12
12
13
import junit.framework.TestCase;
13
import junit.framework.TestCase;
14
14
15
import org.eclipse.core.runtime.NullProgressMonitor;
15
import org.eclipse.core.runtime.NullProgressMonitor;
16
import org.eclipse.mylar.tasks.core.AbstractQueryHit;
16
import org.eclipse.mylyn.tasks.core.*;
17
import org.eclipse.mylar.tasks.core.AbstractRepositoryConnector;
17
import org.eclipse.mylyn.tasks.ui.TaskFactory;
18
import org.eclipse.mylar.tasks.core.QueryHitCollector;
18
import org.eclipse.mylyn.tasks.ui.TasksUiPlugin;
19
import org.eclipse.mylar.tasks.core.TaskList;
19
import org.eclipse.mylyn.tasks.ui.search.SearchHitCollector;
20
import org.eclipse.mylar.tasks.core.TaskRepository;
20
import org.eclipse.mylyn.xplanner.core.service.XPlannerClient;
21
import org.eclipse.mylar.tasks.ui.TasksUiPlugin;
21
import org.eclipse.mylyn.xplanner.ui.XPlannerCustomQuery;
22
import org.eclipse.mylar.xplanner.core.service.XPlannerServer;
23
import org.eclipse.mylar.xplanner.ui.XPlannerCustomQuery;
24
22
25
public class XPlannerCustomQueryTest extends TestCase {
23
public class XPlannerCustomQueryTest extends TestCase {
26
24
27
	private static XPlannerServer server;
25
	private static XPlannerClient client;
28
	
26
	
29
	protected void setUp() throws Exception {
27
	protected void setUp() throws Exception {
30
		super.setUp();
28
		super.setUp();
31
		if (server == null) { // only create data once per run
29
		if (client == null) { // only create data once per run
32
			server = XPlannerTestUtils.getXPlannerServer();
30
			client = XPlannerTestUtils.getXPlannerClient();
33
			XPlannerTestUtils.clearTestData(server);
31
			XPlannerTestUtils.clearTestData(client);
34
			XPlannerTestUtils.setUpTestData(server);
32
			XPlannerTestUtils.setUpTestData(client);
35
		}
33
		}
36
	}
34
	}
37
35
Lines 42-61 Link Here
42
	public void testNoItemsQuery() {
40
	public void testNoItemsQuery() {
43
		TaskList taskList = XPlannerTestUtils.getTaskList();
41
		TaskList taskList = XPlannerTestUtils.getTaskList();
44
		XPlannerCustomQuery query = new XPlannerCustomQuery(XPlannerTestUtils.SERVER_URL,
42
		XPlannerCustomQuery query = new XPlannerCustomQuery(XPlannerTestUtils.SERVER_URL,
45
			"no items", taskList);
43
			"no items");
46
		query.setPersonId(-1);
44
		query.setPersonId(-1);
47
		
45
		 
48
		List<AbstractQueryHit> hits = performTestQuery(taskList, query);
46
		Set<AbstractTask> hits = performTestQuery(taskList, query);
49
		assert(hits.size() == 0);
47
		assert(hits.size() == 0);
50
	}
48
	}
51
49
52
	public void testAdminItemsQuery() {
50
	public void testAdminItemsQuery() {
53
		TaskList taskList = XPlannerTestUtils.getTaskList();
51
		TaskList taskList = XPlannerTestUtils.getTaskList();
54
		XPlannerCustomQuery query = new XPlannerCustomQuery(XPlannerTestUtils.SERVER_URL,
52
		XPlannerCustomQuery query = new XPlannerCustomQuery(
55
			"admin items", taskList);
53
			XPlannerTestUtils.SERVER_URL,	"admin items");
56
		try {
54
		try {
57
			query.setPersonId(XPlannerTestUtils.getAdminId(server));
55
			query.setPersonId(XPlannerTestUtils.getAdminId(client));
58
			List<AbstractQueryHit> hits = performTestQuery(taskList, query);
56
			Set<AbstractTask> hits = performTestQuery(taskList, query);
59
			assert(hits.size() == 1);
57
			assert(hits.size() == 1);
60
		}
58
		}
61
		catch (RemoteException e) {
59
		catch (RemoteException e) {
Lines 64-78 Link Here
64
		
62
		
65
	}
63
	}
66
64
67
	private List<AbstractQueryHit> performTestQuery(TaskList taskList, XPlannerCustomQuery query) {
65
	private Set<AbstractTask> performTestQuery(TaskList taskList, XPlannerCustomQuery query) {
68
		TaskRepository repository = XPlannerTestUtils.getRepository();
66
		TaskRepository repository = XPlannerTestUtils.getRepository();
69
		AbstractRepositoryConnector connector = 
67
		AbstractRepositoryConnector connector = 
70
			TasksUiPlugin.getRepositoryManager().getRepositoryConnector(repository.getKind());
68
			TasksUiPlugin.getRepositoryManager().getRepositoryConnector(repository.getConnectorKind());
71
		
69
		
72
		QueryHitCollector collector = new QueryHitCollector(taskList);
70
		TaskFactory taskFactory = new TaskFactory(repository, false, false);
71
		SearchHitCollector collector = new SearchHitCollector(taskList, repository, query, taskFactory);
73
		connector.performQuery(query, repository, new NullProgressMonitor(), collector);
72
		connector.performQuery(query, repository, new NullProgressMonitor(), collector);
74
		
73
		
75
		List<AbstractQueryHit> hits = collector.getHits();
74
		Set<AbstractTask> hits = collector.getTasks();
76
		return hits;
75
		return hits;
77
	}
76
	}
78
	
77
	
(-)src/org/eclipse/mylyn/xplanner/tests/XPlannerRepositoryUtilsTest.java (-22 / +24 lines)
Lines 5-35 Link Here
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
package org.eclipse.mylar.xplanner.tests;
8
package org.eclipse.mylyn.xplanner.tests;
9
9
10
import junit.framework.TestCase;
10
import junit.framework.TestCase;
11
11
12
import org.eclipse.core.runtime.CoreException;
12
import org.eclipse.core.runtime.CoreException;
13
import org.eclipse.mylar.tasks.core.RepositoryTaskAttribute;
13
import org.eclipse.mylyn.tasks.core.*;
14
import org.eclipse.mylar.tasks.core.RepositoryTaskData;
14
import org.eclipse.mylyn.tasks.ui.TasksUiPlugin;
15
import org.eclipse.mylar.tasks.core.TaskRepository;
15
import org.eclipse.mylyn.xplanner.core.service.XPlannerClient;
16
import org.eclipse.mylar.xplanner.core.service.XPlannerServer;
16
import org.eclipse.mylyn.xplanner.ui.*;
17
import org.eclipse.mylar.xplanner.ui.XPlannerAttributeFactory;
18
import org.eclipse.mylar.xplanner.ui.XPlannerRepositoryUtils;
19
import org.eclipse.mylar.xplanner.ui.XPlannerTask;
20
import org.xplanner.soap.TaskData;
17
import org.xplanner.soap.TaskData;
21
import org.xplanner.soap.UserStoryData;
18
import org.xplanner.soap.UserStoryData;
22
19
23
public class XPlannerRepositoryUtilsTest extends TestCase {
20
public class XPlannerRepositoryUtilsTest extends TestCase {
24
21
25
	private static XPlannerServer server;
22
	private static XPlannerClient client;
26
	
23
	
27
	protected void setUp() throws Exception {
24
	protected void setUp() throws Exception {
28
		super.setUp();
25
		super.setUp();
29
		if (server == null) { // only create data once per run
26
		if (client == null) { // only create data once per run
30
			server = XPlannerTestUtils.getXPlannerServer();
27
			client = XPlannerTestUtils.getXPlannerClient();
31
			XPlannerTestUtils.clearTestData(server);
28
			XPlannerTestUtils.clearTestData(client);
32
			XPlannerTestUtils.setUpTestData(server);
29
			XPlannerTestUtils.setUpTestData(client);
33
		}
30
		}
34
	}
31
	}
35
32
Lines 39-47 Link Here
39
36
40
	public void testSetupTaskAttributes() {
37
	public void testSetupTaskAttributes() {
41
		try {
38
		try {
42
			TaskData taskData =  XPlannerTestUtils.findTestTask(server);
39
			TaskData taskData =  XPlannerTestUtils.findTestTask(client);
43
			XPlannerTask task = XPlannerTestUtils.getTestXPlannerTask(server);
40
			XPlannerTask task = XPlannerTestUtils.getTestXPlannerTask(client);
44
			RepositoryTaskData repositoryTaskData = task.getTaskData();
41
			RepositoryTaskData repositoryTaskData = 
42
				TasksUiPlugin.getTaskDataManager().getNewTaskData(task.getRepositoryUrl(),
43
				task.getTaskId()); 
45
			XPlannerRepositoryUtils.setupTaskAttributes(taskData, repositoryTaskData);
44
			XPlannerRepositoryUtils.setupTaskAttributes(taskData, repositoryTaskData);
46
			
45
			
47
			assert(taskData.getDescription().equals(
46
			assert(taskData.getDescription().equals(
Lines 54-62 Link Here
54
53
55
	public void testSetupUserStoryAttributes() {
54
	public void testSetupUserStoryAttributes() {
56
		try {
55
		try {
57
			UserStoryData userStory =  XPlannerTestUtils.findTestUserStory(server);
56
			UserStoryData userStory =  XPlannerTestUtils.findTestUserStory(client);
58
			XPlannerTask task = XPlannerTestUtils.getTestXPlannerUserStoryTask(server);
57
			XPlannerTask task = XPlannerTestUtils.getTestXPlannerUserStoryTask(client);
59
			RepositoryTaskData repositoryTaskData = task.getTaskData();
58
			RepositoryTaskData repositoryTaskData = 
59
				TasksUiPlugin.getTaskDataManager().getNewTaskData(task.getRepositoryUrl(),
60
					task.getTaskId()); 
60
			XPlannerRepositoryUtils.setupUserStoryAttributes(userStory, repositoryTaskData);
61
			XPlannerRepositoryUtils.setupUserStoryAttributes(userStory, repositoryTaskData);
61
			
62
			
62
			assert(userStory.getName().equals(
63
			assert(userStory.getName().equals(
Lines 68-77 Link Here
68
	}
69
	}
69
70
70
	public void testIsCompleted() {
71
	public void testIsCompleted() {
71
		XPlannerTask xplannerTask;
72
		try {
72
		try {
73
			xplannerTask = XPlannerTestUtils.getTestXPlannerTask(server);
73
			XPlannerTask task = XPlannerTestUtils.getTestXPlannerTask(client);
74
			RepositoryTaskData repositoryTaskData = xplannerTask.getTaskData();
74
			RepositoryTaskData repositoryTaskData = 
75
				TasksUiPlugin.getTaskDataManager().getNewTaskData(task.getRepositoryUrl(),
76
					task.getTaskId()); 
75
			assert(!XPlannerRepositoryUtils.isCompleted(repositoryTaskData));
77
			assert(!XPlannerRepositoryUtils.isCompleted(repositoryTaskData));
76
		}
78
		}
77
		catch (Exception e) {
79
		catch (Exception e) {
(-)src/org/eclipse/mylyn/xplanner/tests/AllXPlannerTests.java (-2 / +2 lines)
Lines 5-11 Link Here
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
package org.eclipse.mylar.xplanner.tests;
8
package org.eclipse.mylyn.xplanner.tests;
9
9
10
import junit.framework.Test;
10
import junit.framework.Test;
11
import junit.framework.TestSuite;
11
import junit.framework.TestSuite;
Lines 17-23 Link Here
17
public class AllXPlannerTests {
17
public class AllXPlannerTests {
18
18
19
	public static Test suite() {
19
	public static Test suite() {
20
		TestSuite suite = new TestSuite("Test for mylar.xplanner.tests");
20
		TestSuite suite = new TestSuite("Test for mylyn.xplanner.tests");
21
21
22
		// $JUnit-BEGIN$
22
		// $JUnit-BEGIN$
23
		suite.addTestSuite(XPlannerRepositoryUtilsTest.class);
23
		suite.addTestSuite(XPlannerRepositoryUtilsTest.class);
(-)src/org/eclipse/mylyn/xplanner/tests/XPlannerTestUtils.java (-69 / +61 lines)
Lines 5-31 Link Here
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
package org.eclipse.mylar.xplanner.tests;
8
package org.eclipse.mylyn.xplanner.tests;
9
9
10
import java.rmi.RemoteException;
10
import java.rmi.RemoteException;
11
import java.util.Calendar;
11
import java.util.Calendar;
12
import java.util.Date;
12
import java.util.Date;
13
13
14
import org.eclipse.core.runtime.CoreException;
14
import org.eclipse.core.runtime.CoreException;
15
import org.eclipse.mylar.tasks.core.AbstractRepositoryConnector;
15
import org.eclipse.core.runtime.NullProgressMonitor;
16
import org.eclipse.mylar.tasks.core.Task;
16
import org.eclipse.mylyn.tasks.core.*;
17
import org.eclipse.mylar.tasks.core.TaskList;
17
import org.eclipse.mylyn.tasks.ui.TasksUiPlugin;
18
import org.eclipse.mylar.tasks.core.TaskRepository;
18
import org.eclipse.mylyn.xplanner.core.service.XPlannerClient;
19
import org.eclipse.mylar.tasks.ui.TasksUiPlugin;
19
import org.eclipse.mylyn.xplanner.ui.*;
20
import org.eclipse.mylar.xplanner.core.service.XPlannerServer;
20
import org.xplanner.soap.*;
21
import org.eclipse.mylar.xplanner.ui.XPlannerMylarUIPlugin;
22
import org.eclipse.mylar.xplanner.ui.XPlannerServerFacade;
23
import org.eclipse.mylar.xplanner.ui.XPlannerTask;
24
import org.xplanner.soap.IterationData;
25
import org.xplanner.soap.PersonData;
26
import org.xplanner.soap.ProjectData;
27
import org.xplanner.soap.TaskData;
28
import org.xplanner.soap.UserStoryData;
29
21
30
/**
22
/**
31
 * Requirements for tests:
23
 * Requirements for tests:
Lines 52-58 Link Here
52
		
44
		
53
		repository = TasksUiPlugin.getRepositoryManager().getRepository(SERVER_URL);
45
		repository = TasksUiPlugin.getRepositoryManager().getRepository(SERVER_URL);
54
		if (repository == null) {
46
		if (repository == null) {
55
			repository = new TaskRepository(XPlannerMylarUIPlugin.REPOSITORY_KIND, SERVER_URL);
47
			repository = new TaskRepository(XPlannerMylynUIPlugin.REPOSITORY_KIND, SERVER_URL);
56
			repository.setAuthenticationCredentials(USER, PASSWORD);
48
			repository.setAuthenticationCredentials(USER, PASSWORD);
57
			TasksUiPlugin.getRepositoryManager().addRepository(repository, TasksUiPlugin.getDefault().getRepositoriesFilePath());
49
			TasksUiPlugin.getRepositoryManager().addRepository(repository, TasksUiPlugin.getDefault().getRepositoriesFilePath());
58
			TasksUiPlugin.getTaskListManager().resetTaskList();
50
			TasksUiPlugin.getTaskListManager().resetTaskList();
Lines 66-99 Link Here
66
			repository, TasksUiPlugin.getDefault().getRepositoriesFilePath());
58
			repository, TasksUiPlugin.getDefault().getRepositoriesFilePath());
67
	}
59
	}
68
	
60
	
69
	public static XPlannerServer getXPlannerServer() throws CoreException {
61
	public static XPlannerClient getXPlannerClient() throws CoreException {
70
		TaskRepository repository = getRepository();
62
		TaskRepository repository = getRepository();
71
63
72
		return XPlannerServerFacade.getDefault().getXPlannerServer(repository);
64
		return XPlannerClientFacade.getDefault().getXPlannerClient(repository);
73
	}
65
	}
74
	
66
	
75
	public static void clearTestData(XPlannerServer server) throws Exception {
67
	public static void clearTestData(XPlannerClient client) throws Exception {
76
		if (server != null) {
68
		if (client != null) {
77
			ProjectData testProject = findTestProject(server);
69
			ProjectData testProject = findTestProject(client);
78
			if (testProject != null) {
70
			if (testProject != null) {
79
				server.removeProject(testProject.getId());
71
				client.removeProject(testProject.getId());
80
			}
72
			}
81
		}
73
		}
82
	}
74
	}
83
	
75
	
84
	public static void setUpTestData(XPlannerServer server) throws Exception {
76
	public static void setUpTestData(XPlannerClient client) throws Exception {
85
		if (server != null) {
77
		if (client != null) {
86
			ProjectData testProject = getTestProject(server);
78
			ProjectData testProject = getTestProject(client);
87
			IterationData testIteration = getTestIteration(server, testProject);
79
			IterationData testIteration = getTestIteration(client, testProject);
88
			UserStoryData testUserStory = getTestUserStory(server, testIteration);
80
			UserStoryData testUserStory = getTestUserStory(client, testIteration);
89
			getTestTask(server, testUserStory);
81
			getTestTask(client, testUserStory);
90
		}
82
		}
91
	}
83
	}
92
	
84
	
93
	public static ProjectData findTestProject(XPlannerServer server) throws RemoteException {
85
	public static ProjectData findTestProject(XPlannerClient client) throws RemoteException {
94
		ProjectData testProject = null;
86
		ProjectData testProject = null;
95
		
87
		
96
		ProjectData[] projects = server.getProjects();
88
		ProjectData[] projects = client.getProjects();
97
		for (int i = 0; i < projects.length && testProject == null; i++) {
89
		for (int i = 0; i < projects.length && testProject == null; i++) {
98
			if (TEST_PROJECT_NAME.equals(projects[i].getName())) {
90
			if (TEST_PROJECT_NAME.equals(projects[i].getName())) {
99
				testProject = projects[i];
91
				testProject = projects[i];
Lines 103-125 Link Here
103
		return testProject;
95
		return testProject;
104
	}
96
	}
105
	
97
	
106
	private static ProjectData getTestProject(XPlannerServer server) throws RemoteException {
98
	private static ProjectData getTestProject(XPlannerClient client) throws RemoteException {
107
		ProjectData testProject = findTestProject(server);
99
		ProjectData testProject = findTestProject(client);
108
		
100
		
109
		if (testProject == null) {
101
		if (testProject == null) {
110
			testProject = new ProjectData();
102
			testProject = new ProjectData();
111
			testProject.setName(TEST_PROJECT_NAME);
103
			testProject.setName(TEST_PROJECT_NAME);
112
			testProject.setDescription(TEST_PROJECT_NAME);
104
			testProject.setDescription(TEST_PROJECT_NAME);
113
			testProject = server.addProject(testProject);
105
			testProject = client.addProject(testProject);
114
		}
106
		}
115
		
107
		
116
		return testProject;
108
		return testProject;
117
	}
109
	}
118
110
119
	public static IterationData findTestIteration(XPlannerServer server, ProjectData testProject) throws RemoteException {
111
	public static IterationData findTestIteration(XPlannerClient client, ProjectData testProject) throws RemoteException {
120
		IterationData testIteration = null;
112
		IterationData testIteration = null;
121
113
122
		IterationData[] iterations = server.getIterations(testProject.getId());
114
		IterationData[] iterations = client.getIterations(testProject.getId());
123
		if (iterations != null) {
115
		if (iterations != null) {
124
			for (int i = 0; i < iterations.length && testIteration == null; i++) {
116
			for (int i = 0; i < iterations.length && testIteration == null; i++) {
125
				if (TEST_ITERATION_NAME.equals(iterations[i].getName())) {
117
				if (TEST_ITERATION_NAME.equals(iterations[i].getName())) {
Lines 131-138 Link Here
131
		return testIteration;
123
		return testIteration;
132
	}
124
	}
133
	
125
	
134
	private static IterationData getTestIteration(XPlannerServer server, ProjectData project) throws RemoteException {
126
	private static IterationData getTestIteration(XPlannerClient client, ProjectData project) throws RemoteException {
135
		IterationData testIteration = findTestIteration(server, project);
127
		IterationData testIteration = findTestIteration(client, project);
136
		
128
		
137
		if (testIteration == null) {
129
		if (testIteration == null) {
138
			testIteration = new IterationData();
130
			testIteration = new IterationData();
Lines 157-174 Link Here
157
    	testIteration.setEndDate(endDate);
149
    	testIteration.setEndDate(endDate);
158
    	testIteration.setName(TEST_ITERATION_NAME);
150
    	testIteration.setName(TEST_ITERATION_NAME);
159
    	testIteration.setDescription(TEST_ITERATION_NAME);
151
    	testIteration.setDescription(TEST_ITERATION_NAME);
160
    	testIteration = server.addIteration(testIteration);
152
    	testIteration = client.addIteration(testIteration);
161
    	
153
    	
162
			server.refreshDetails();
154
			client.refreshDetails();
163
		}
155
		}
164
		
156
		
165
		return testIteration;
157
		return testIteration;
166
	}
158
	}
167
159
168
	public static UserStoryData findTestUserStory(XPlannerServer server, IterationData testIteration) throws RemoteException {
160
	public static UserStoryData findTestUserStory(XPlannerClient client, IterationData testIteration) throws RemoteException {
169
		UserStoryData testUserStory = null;
161
		UserStoryData testUserStory = null;
170
		
162
		
171
		UserStoryData[] userStories = server.getUserStories(testIteration.getId());
163
		UserStoryData[] userStories = client.getUserStories(testIteration.getId());
172
		if (userStories != null) {
164
		if (userStories != null) {
173
			for (int i = 0; i < userStories.length && testUserStory == null; i++) {
165
			for (int i = 0; i < userStories.length && testUserStory == null; i++) {
174
				if (TEST_USER_STORY_NAME.equals(userStories[i].getName())) {
166
				if (TEST_USER_STORY_NAME.equals(userStories[i].getName())) {
Lines 180-187 Link Here
180
		return testUserStory;
172
		return testUserStory;
181
	}
173
	}
182
	
174
	
183
	private static UserStoryData getTestUserStory(XPlannerServer server, IterationData iteration) throws RemoteException {
175
	private static UserStoryData getTestUserStory(XPlannerClient client, IterationData iteration) throws RemoteException {
184
		UserStoryData testUserStory = findTestUserStory(server, iteration);
176
		UserStoryData testUserStory = findTestUserStory(client, iteration);
185
		
177
		
186
		if (testUserStory == null) {
178
		if (testUserStory == null) {
187
			testUserStory = new UserStoryData();
179
			testUserStory = new UserStoryData();
Lines 194-211 Link Here
194
			testUserStory.setRemainingHours(0);
186
			testUserStory.setRemainingHours(0);
195
			testUserStory.setPriority(5);
187
			testUserStory.setPriority(5);
196
		  
188
		  
197
			testUserStory = server.addUserStory(testUserStory);
189
			testUserStory = client.addUserStory(testUserStory);
198
			
190
			
199
			server.refreshDetails();
191
			client.refreshDetails();
200
		}
192
		}
201
		
193
		
202
		return testUserStory;
194
		return testUserStory;
203
	}
195
	}
204
196
205
	public static TaskData findTestTask(XPlannerServer server, UserStoryData testUserStory) throws RemoteException {
197
	public static TaskData findTestTask(XPlannerClient client, UserStoryData testUserStory) throws RemoteException {
206
		TaskData testTask = null;
198
		TaskData testTask = null;
207
		
199
		
208
		TaskData[] tasks = server.getTasks(testUserStory.getId());
200
		TaskData[] tasks = client.getTasks(testUserStory.getId());
209
		for (int i = 0; i < tasks.length && testTask == null; i++) {
201
		for (int i = 0; i < tasks.length && testTask == null; i++) {
210
			if (TEST_TASK_NAME.equals(tasks[i].getName())) {
202
			if (TEST_TASK_NAME.equals(tasks[i].getName())) {
211
				testTask = tasks[i];
203
				testTask = tasks[i];
Lines 215-224 Link Here
215
		return testTask;
207
		return testTask;
216
	}
208
	}
217
209
218
	public static int getAdminId(XPlannerServer server) throws RemoteException {
210
	public static int getAdminId(XPlannerClient client) throws RemoteException {
219
		int adminId = -1;
211
		int adminId = -1;
220
		
212
		
221
		PersonData[] people = server.getPeople();
213
		PersonData[] people = client.getPeople();
222
		for (int i = 0; i < people.length && adminId == -1; i++) {
214
		for (int i = 0; i < people.length && adminId == -1; i++) {
223
			if (USER.equals(people[i].getUserId())) {
215
			if (USER.equals(people[i].getUserId())) {
224
				adminId = people[i].getId();
216
				adminId = people[i].getId();
Lines 228-235 Link Here
228
		return adminId;
220
		return adminId;
229
	}
221
	}
230
	
222
	
231
	private static TaskData getTestTask(XPlannerServer server, UserStoryData userStory) throws RemoteException {
223
	private static TaskData getTestTask(XPlannerClient client, UserStoryData userStory) throws RemoteException {
232
		TaskData testTask = findTestTask(server, userStory);
224
		TaskData testTask = findTestTask(client, userStory);
233
		
225
		
234
		if (testTask == null) {
226
		if (testTask == null) {
235
			testTask = new TaskData();
227
			testTask = new TaskData();
Lines 240-254 Link Here
240
    	testTask.setEstimatedHours(24.0);
232
    	testTask.setEstimatedHours(24.0);
241
    	testTask.setActualHours(7.0);
233
    	testTask.setActualHours(7.0);
242
    	testTask.setDispositionName("planned");  //$NON-NLS-1$
234
    	testTask.setDispositionName("planned");  //$NON-NLS-1$
243
    	testTask.setAcceptorId(getAdminId(server));
235
    	testTask.setAcceptorId(getAdminId(client));
244
    	
236
    	
245
    	Calendar taskCreate = Calendar.getInstance();
237
    	Calendar taskCreate = Calendar.getInstance();
246
    	taskCreate.setTime(new Date());
238
    	taskCreate.setTime(new Date());
247
		  testTask.setCreatedDate(taskCreate);
239
		  testTask.setCreatedDate(taskCreate);
248
		  
240
		  
249
			testTask = server.addTask(testTask);
241
			testTask = client.addTask(testTask);
250
			
242
			
251
			server.refreshDetails();
243
			client.refreshDetails();
252
		}
244
		}
253
		
245
		
254
		return testTask;
246
		return testTask;
Lines 261-286 Link Here
261
		return taskList;
253
		return taskList;
262
	}
254
	}
263
	
255
	
264
	public static UserStoryData findTestUserStory(XPlannerServer server) throws RemoteException {
256
	public static UserStoryData findTestUserStory(XPlannerClient client) throws RemoteException {
265
		UserStoryData testUserStory = null;
257
		UserStoryData testUserStory = null;
266
		
258
		
267
		ProjectData testProject = findTestProject(server);
259
		ProjectData testProject = findTestProject(client);
268
		if (testProject != null) {
260
		if (testProject != null) {
269
			IterationData testIteration = findTestIteration(server, testProject);
261
			IterationData testIteration = findTestIteration(client, testProject);
270
			if (testIteration != null) {
262
			if (testIteration != null) {
271
				testUserStory = findTestUserStory(server, testIteration);
263
				testUserStory = findTestUserStory(client, testIteration);
272
			}
264
			}
273
		}
265
		}
274
		
266
		
275
		return testUserStory;
267
		return testUserStory;
276
	}
268
	}
277
	
269
	
278
	public static TaskData findTestTask(XPlannerServer server) throws RemoteException {
270
	public static TaskData findTestTask(XPlannerClient client) throws RemoteException {
279
		TaskData testTask = null;
271
		TaskData testTask = null;
280
272
281
		UserStoryData testUserStory = findTestUserStory(server);
273
		UserStoryData testUserStory = findTestUserStory(client);
282
		if (testUserStory != null) {
274
		if (testUserStory != null) {
283
			testTask = findTestTask(server, testUserStory);
275
			testTask = findTestTask(client, testUserStory);
284
		}
276
		}
285
		
277
		
286
		return testTask;
278
		return testTask;
Lines 289-314 Link Here
289
	/**
281
	/**
290
	 * setUpTestData() needs to be called before this method
282
	 * setUpTestData() needs to be called before this method
291
	 */
283
	 */
292
	public static XPlannerTask getTestXPlannerTask(XPlannerServer server) throws Exception {
284
	public static XPlannerTask getTestXPlannerTask(XPlannerClient client) throws Exception {
293
		TaskRepository repository = getRepository();
285
		TaskRepository repository = getRepository();
294
		AbstractRepositoryConnector connector = 
286
		AbstractRepositoryConnector connector = 
295
			TasksUiPlugin.getRepositoryManager().getRepositoryConnector(repository.getKind());
287
			TasksUiPlugin.getRepositoryManager().getRepositoryConnector(repository.getConnectorKind());
296
		
288
		
297
		TaskData testTask = findTestTask(server);
289
		TaskData testTask = findTestTask(client);
298
		Task task = connector.createTaskFromExistingKey(repository, "" + testTask.getId());
290
		AbstractTask task = connector.createTaskFromExistingId(repository, "" + testTask.getId(), new NullProgressMonitor());
299
		return (XPlannerTask) task;
291
		return (XPlannerTask) task;
300
	}
292
	}
301
293
302
	/**
294
	/**
303
	 * setUpTestData() needs to be called before this method
295
	 * setUpTestData() needs to be called before this method
304
	 */
296
	 */
305
	public static XPlannerTask getTestXPlannerUserStoryTask(XPlannerServer server) throws Exception {
297
	public static XPlannerTask getTestXPlannerUserStoryTask(XPlannerClient client) throws Exception {
306
		TaskRepository repository = getRepository();
298
		TaskRepository repository = getRepository();
307
		AbstractRepositoryConnector connector = 
299
		AbstractRepositoryConnector connector = 
308
			TasksUiPlugin.getRepositoryManager().getRepositoryConnector(repository.getKind());
300
			TasksUiPlugin.getRepositoryManager().getRepositoryConnector(repository.getConnectorKind());
309
		
301
		
310
		UserStoryData testUserStory = findTestUserStory(server);
302
		UserStoryData testUserStory = findTestUserStory(client);
311
		Task task = connector.createTaskFromExistingKey(repository, "" + testUserStory.getId());
303
		AbstractTask task = connector.createTaskFromExistingId(repository, "" + testUserStory.getId(), new NullProgressMonitor());
312
		return (XPlannerTask) task;
304
		return (XPlannerTask) task;
313
	}
305
	}
314
	
306
	
(-)META-INF/MANIFEST.MF (-6 / +7 lines)
Lines 1-13 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
Bundle-ManifestVersion: 2
2
Bundle-ManifestVersion: 2
3
Bundle-Name: @bundleName
3
Bundle-Name: @bundleName
4
Bundle-SymbolicName: org.eclipse.mylar.xplanner.tests
4
Bundle-SymbolicName: org.eclipse.mylyn.xplanner.tests
5
Bundle-Version: 1.0.0
5
Bundle-Version: 1.1.0.qualifer
6
Bundle-Localization: plugin
6
Bundle-Localization: plugin
7
Require-Bundle: org.junit,
7
Require-Bundle: org.junit,
8
 org.eclipse.core.runtime,
8
 org.eclipse.core.runtime,
9
 org.eclipse.ui,
9
 org.eclipse.ui,
10
 org.eclipse.mylar.tasks.core, 
10
 org.eclipse.mylyn.tasks.core,
11
 org.eclipse.mylar.tasks.ui,
11
 org.eclipse.mylyn.tasks.ui,
12
 org.eclipse.mylar.xplanner.core,
12
 org.eclipse.mylyn.xplanner.core,
13
 org.eclipse.mylar.xplanner.ui
13
 org.eclipse.mylyn.xplanner.ui,
14
 org.eclipse.search

Return to bug 130240