diff options
27 files changed, 1422 insertions, 1422 deletions
diff --git a/org.eclipse.mylyn.github-feature/build.properties b/org.eclipse.mylyn.github-feature/build.properties index 5f396616..2cbd8542 100644 --- a/org.eclipse.mylyn.github-feature/build.properties +++ b/org.eclipse.mylyn.github-feature/build.properties @@ -1,3 +1,3 @@ -bin.includes = feature.xml,\
- feature.properties,\
- license.html
+bin.includes = feature.xml,\ + feature.properties,\ + license.html diff --git a/org.eclipse.mylyn.github-feature/github.target b/org.eclipse.mylyn.github-feature/github.target index 185f5ae2..b654883b 100644 --- a/org.eclipse.mylyn.github-feature/github.target +++ b/org.eclipse.mylyn.github-feature/github.target @@ -1,24 +1,24 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<?pde version="3.6"?>
-
-<target includeMode="feature" name="Mylyn GitHub Connector Target">
-<locations>
-<location includeAllPlatforms="false" includeMode="planner" includeSource="true" type="InstallableUnit">
-<unit id="org.hamcrest" version="1.1.0.v20090501071000"/>
-<unit id="com.google.gson" version="1.6.0.v201101131530"/>
-<unit id="org.mockito" version="1.8.4.v201102171835"/>
-<unit id="org.objenesis" version="1.0.0.v201006030720"/>
-<unit id="org.junit" version="4.8.1.v4_8_1_v20100427-1100"/>
-<repository location="http://download.eclipse.org/tools/orbit/downloads/drops/S20110304120314/repository"/>
-</location>
-<location includeAllPlatforms="false" includeMode="planner" includeSource="true" type="InstallableUnit">
-<unit id="org.eclipse.platform.sdk" version="3.6.2.M20110210-1200"/>
-<repository location="http://download.eclipse.org/eclipse/updates/3.6"/>
-</location>
-<location includeAllPlatforms="false" includeMode="planner" includeSource="true" type="InstallableUnit">
-<unit id="org.eclipse.mylyn_feature.feature.group" version="3.5.1.v20110422-0200"/>
-<repository location="http://download.eclipse.org/mylyn/releases/latest/"/>
-</location>
-</locations>
-<targetJRE path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
-</target>
+<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<?pde version="3.6"?> + +<target includeMode="feature" name="Mylyn GitHub Connector Target"> +<locations> +<location includeAllPlatforms="false" includeMode="planner" includeSource="true" type="InstallableUnit"> +<unit id="org.hamcrest" version="1.1.0.v20090501071000"/> +<unit id="com.google.gson" version="1.6.0.v201101131530"/> +<unit id="org.mockito" version="1.8.4.v201102171835"/> +<unit id="org.objenesis" version="1.0.0.v201006030720"/> +<unit id="org.junit" version="4.8.1.v4_8_1_v20100427-1100"/> +<repository location="http://download.eclipse.org/tools/orbit/downloads/drops/S20110304120314/repository"/> +</location> +<location includeAllPlatforms="false" includeMode="planner" includeSource="true" type="InstallableUnit"> +<unit id="org.eclipse.platform.sdk" version="3.6.2.M20110210-1200"/> +<repository location="http://download.eclipse.org/eclipse/updates/3.6"/> +</location> +<location includeAllPlatforms="false" includeMode="planner" includeSource="true" type="InstallableUnit"> +<unit id="org.eclipse.mylyn_feature.feature.group" version="3.5.1.v20110422-0200"/> +<repository location="http://download.eclipse.org/mylyn/releases/latest/"/> +</location> +</locations> +<targetJRE path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/> +</target> diff --git a/org.eclipse.mylyn.github.core/.project b/org.eclipse.mylyn.github.core/.project index 3ae827bb..e143958d 100644 --- a/org.eclipse.mylyn.github.core/.project +++ b/org.eclipse.mylyn.github.core/.project @@ -1,28 +1,28 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.mylyn.github.core</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
+<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.eclipse.mylyn.github.core</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.ManifestBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.SchemaBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> diff --git a/org.eclipse.mylyn.github.core/.settings/org.eclipse.core.resources.prefs b/org.eclipse.mylyn.github.core/.settings/org.eclipse.core.resources.prefs index 315bf27c..82ce64e7 100644 --- a/org.eclipse.mylyn.github.core/.settings/org.eclipse.core.resources.prefs +++ b/org.eclipse.mylyn.github.core/.settings/org.eclipse.core.resources.prefs @@ -1,3 +1,3 @@ -#Tue Jun 09 20:22:30 CEST 2009
-eclipse.preferences.version=1
-encoding/<project>=UTF-8
+#Tue Jun 09 20:22:30 CEST 2009 +eclipse.preferences.version=1 +encoding/<project>=UTF-8 diff --git a/org.eclipse.mylyn.github.core/.settings/org.eclipse.core.runtime.prefs b/org.eclipse.mylyn.github.core/.settings/org.eclipse.core.runtime.prefs index 5b9dcff1..94514501 100644 --- a/org.eclipse.mylyn.github.core/.settings/org.eclipse.core.runtime.prefs +++ b/org.eclipse.mylyn.github.core/.settings/org.eclipse.core.runtime.prefs @@ -1,3 +1,3 @@ -#Tue Jun 09 20:22:30 CEST 2009
-eclipse.preferences.version=1
-line.separator=\n
+#Tue Jun 09 20:22:30 CEST 2009 +eclipse.preferences.version=1 +line.separator=\n diff --git a/org.eclipse.mylyn.github.core/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.mylyn.github.core/.settings/org.eclipse.jdt.core.prefs index 1d6b3c18..8b0622bf 100644 --- a/org.eclipse.mylyn.github.core/.settings/org.eclipse.jdt.core.prefs +++ b/org.eclipse.mylyn.github.core/.settings/org.eclipse.jdt.core.prefs @@ -1,12 +1,12 @@ -#Fri Jul 30 10:22:35 CEST 2010
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.5
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.5
+#Fri Jul 30 10:22:35 CEST 2010 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.5 diff --git a/org.eclipse.mylyn.github.core/build.properties b/org.eclipse.mylyn.github.core/build.properties index f4ae9701..aa1a0082 100644 --- a/org.eclipse.mylyn.github.core/build.properties +++ b/org.eclipse.mylyn.github.core/build.properties @@ -1,5 +1,5 @@ -source.. = src/
-output.. = bin/
-bin.includes = META-INF/,\
- .,\
- plugin.properties
+source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + plugin.properties diff --git a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHubRepositoryConnector.java b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHubRepositoryConnector.java index 5a7a6f29..2757f1a0 100644 --- a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHubRepositoryConnector.java +++ b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHubRepositoryConnector.java @@ -1,397 +1,397 @@ -/*******************************************************************************
- * Copyright (c) 2011 Red Hat and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * David Green <david.green@tasktop.com> - initial contribution
- * Christian Trutz <christian.trutz@gmail.com> - initial contribution
- * Chris Aniszczyk <caniszczyk@gmail.com> - initial contribution
- *******************************************************************************/
-package org.eclipse.mylyn.github.internal;
-
-import java.io.IOException;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.mylyn.commons.net.AuthenticationCredentials;
-import org.eclipse.mylyn.commons.net.AuthenticationType;
-import org.eclipse.mylyn.commons.net.Policy;
-import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
-import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
-import org.eclipse.mylyn.tasks.core.ITask;
-import org.eclipse.mylyn.tasks.core.TaskRepository;
-import org.eclipse.mylyn.tasks.core.data.AbstractTaskDataHandler;
-import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
-import org.eclipse.mylyn.tasks.core.data.TaskData;
-import org.eclipse.mylyn.tasks.core.data.TaskDataCollector;
-import org.eclipse.mylyn.tasks.core.data.TaskMapper;
-import org.eclipse.mylyn.tasks.core.sync.ISynchronizationSession;
-
-/**
- * GitHub connector.
- */
-public class GitHubRepositoryConnector extends AbstractRepositoryConnector {
-
- /**
- * GitHub kind.
- */
- public static final String KIND = GitHub.CONNECTOR_KIND;
-
- /**
- * Create client for repository
- *
- * @param repository
- * @return client
- */
- public static GitHubClient createClient(TaskRepository repository) {
- GitHubClient client = new GitHubClient();
- AuthenticationCredentials credentials = repository
- .getCredentials(AuthenticationType.REPOSITORY);
- if (credentials != null)
- client.setCredentials(credentials.getUserName(),
- credentials.getPassword());
- return client;
- }
-
- /**
- * GitHub specific {@link AbstractTaskDataHandler}.
- */
- private final GitHubTaskDataHandler taskDataHandler;
-
- private final Map<TaskRepository, List<Label>> repositoryLabels = Collections
- .synchronizedMap(new HashMap<TaskRepository, List<Label>>());
-
- private final Map<TaskRepository, List<Milestone>> repositoryMilestones = Collections
- .synchronizedMap(new HashMap<TaskRepository, List<Milestone>>());
-
- /**
- * Create GitHub issue repository connector
- */
- public GitHubRepositoryConnector() {
- taskDataHandler = new GitHubTaskDataHandler(this);
- }
-
- /**
- * Refresh labels for repository
- *
- * @param repository
- * @return labels
- * @throws CoreException
- */
- public List<Label> refreshLabels(TaskRepository repository)
- throws CoreException {
- Assert.isNotNull(repository, "Repository cannot be null"); //$NON-NLS-1$
- Repository repo = GitHub.getRepository(repository.getRepositoryUrl());
- GitHubClient client = createClient(repository);
- LabelService service = new LabelService(client);
- try {
- List<Label> labels = service.getLabels(repo.getOwner(),
- repo.getName());
- Collections.sort(labels, new LabelComparator());
- this.repositoryLabels.put(repository, labels);
- return labels;
- } catch (IOException e) {
- throw new CoreException(GitHub.createErrorStatus(e));
- }
- }
-
- /**
- * Get labels for task repository.
- *
- * @param repository
- * @return non-null but possibly empty list of labels
- */
- public List<Label> getLabels(TaskRepository repository) {
- Assert.isNotNull(repository, "Repository cannot be null"); //$NON-NLS-1$
- List<Label> labels = new LinkedList<Label>();
- List<Label> cached = this.repositoryLabels.get(repository);
- if (cached != null) {
- labels.addAll(cached);
- }
- return labels;
- }
-
- /**
- * Are there cached labels for the specified task repository?
- *
- * @param repository
- * @return true if contains labels, false otherwise
- */
- public boolean hasCachedLabels(TaskRepository repository) {
- return this.repositoryLabels.containsKey(repository);
- }
-
- /**
- * Refresh milestones for repository
- *
- * @param repository
- * @return milestones
- * @throws CoreException
- */
- public List<Milestone> refreshMilestones(TaskRepository repository)
- throws CoreException {
- Assert.isNotNull(repository, "Repository cannot be null"); //$NON-NLS-1$
- Repository repo = GitHub.getRepository(repository.getRepositoryUrl());
- GitHubClient client = createClient(repository);
- MilestoneService service = new MilestoneService(client);
- try {
- List<Milestone> milestones = new LinkedList<Milestone>();
- milestones.addAll(service.getMilestones(repo.getOwner(),
- repo.getName(), IssueService.STATE_OPEN));
- milestones.addAll(service.getMilestones(repo.getOwner(),
- repo.getName(), IssueService.STATE_CLOSED));
- this.repositoryMilestones.put(repository, milestones);
- return milestones;
- } catch (IOException e) {
- throw new CoreException(GitHub.createErrorStatus(e));
- }
- }
-
- /**
- * Get milestones for task repository.
- *
- * @param repository
- * @return non-null but possibly empty list of milestones
- */
- public List<Milestone> getMilestones(TaskRepository repository) {
- Assert.isNotNull(repository, "Repository cannot be null"); //$NON-NLS-1$
- List<Milestone> milestones = new LinkedList<Milestone>();
- List<Milestone> cached = this.repositoryMilestones.get(repository);
- if (cached != null) {
- milestones.addAll(cached);
- }
- return milestones;
- }
-
- /**
- * Are there cached milestones for the specified task repository?
- *
- * @param repository
- * @return true if contains milestones, false otherwise
- */
- public boolean hasCachedMilestones(TaskRepository repository) {
- return this.repositoryMilestones.containsKey(repository);
- }
-
- /**
- * {@inheritDoc}
- *
- * @return always {@code true}
- */
- @Override
- public boolean canCreateNewTask(TaskRepository repository) {
- return true;
- }
-
- /**
- * {@inheritDoc}
- *
- * @return always {@code true}
- */
- @Override
- public boolean canCreateTaskFromKey(TaskRepository repository) {
- return true;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see #KIND
- */
- @Override
- public String getConnectorKind() {
- return KIND;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getLabel() {
- return Messages.GitHubRepositoryConnector_LabelConnector;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public AbstractTaskDataHandler getTaskDataHandler() {
- return this.taskDataHandler;
- }
-
- @Override
- public IStatus performQuery(TaskRepository repository,
- IRepositoryQuery query, TaskDataCollector collector,
- ISynchronizationSession session, IProgressMonitor monitor) {
- IStatus result = Status.OK_STATUS;
- List<String> statuses = QueryUtils.getAttributes(
- IssueService.FILTER_STATE, query);
-
- monitor.beginTask(Messages.GitHubRepositoryConnector_TaskQuerying,
- statuses.size());
- try {
- Repository repo = GitHub.getRepository(repository
- .getRepositoryUrl());
-
- GitHubClient client = createClient(repository);
- IssueService service = new IssueService(client);
-
- Map<String, String> filterData = new HashMap<String, String>();
- String mentions = query.getAttribute(IssueService.FILTER_MENTIONED);
- if (mentions != null)
- filterData.put(IssueService.FILTER_MENTIONED, mentions);
-
- String assignee = query.getAttribute(IssueService.FILTER_ASSIGNEE);
- if (assignee != null)
- filterData.put(IssueService.FILTER_ASSIGNEE, assignee);
-
- String milestone = query
- .getAttribute(IssueService.FILTER_MILESTONE);
- if (milestone != null)
- filterData.put(IssueService.FILTER_MILESTONE, milestone);
-
- List<String> labels = QueryUtils.getAttributes(
- IssueService.FILTER_LABELS, query);
- if (!labels.isEmpty()) {
- StringBuilder labelsQuery = new StringBuilder();
- for (String label : labels)
- labelsQuery.append(label).append(',');
- filterData.put(IssueService.FILTER_LABELS,
- labelsQuery.toString());
- }
-
- for (String status : statuses) {
- filterData.put(IssueService.FILTER_STATE, status);
- List<Issue> issues = service.getIssues(repo.getOwner(),
- repo.getName(), filterData);
-
- // collect task data
- for (Issue issue : issues) {
- TaskData taskData = taskDataHandler.createTaskData(
- repository, monitor, repo.getOwner(),
- repo.getName(), issue);
- taskData.setPartial(true);
- collector.accept(taskData);
- }
- monitor.worked(1);
- }
-
- result = Status.OK_STATUS;
- } catch (IOException e) {
- result = GitHub.createErrorStatus(e);
- }
-
- monitor.done();
- return result;
- }
-
- @Override
- public TaskData getTaskData(TaskRepository repository, String taskId,
- IProgressMonitor monitor) throws CoreException {
- Repository repo = GitHub.getRepository(repository.getRepositoryUrl());
-
- try {
- GitHubClient client = createClient(repository);
- IssueService service = new IssueService(client);
- Issue issue = service.getIssue(repo.getOwner(), repo.getName(),
- taskId);
- List<Comment> comments = null;
- if (issue.getComments() > 0) {
- comments = service.getComments(repo.getOwner(), repo.getName(),
- taskId);
- }
- TaskData taskData = taskDataHandler.createTaskData(repository,
- monitor, repo.getOwner(), repo.getName(), issue, comments);
-
- return taskData;
- } catch (IOException e) {
- throw new CoreException(GitHub.createErrorStatus(e));
- }
- }
-
- @Override
- public String getRepositoryUrlFromTaskUrl(String taskFullUrl) {
- if (taskFullUrl != null) {
- Matcher matcher = Pattern.compile(
- "(http://.+?)/issues/issue/([^/]+)").matcher(taskFullUrl); //$NON-NLS-1$
- if (matcher.matches()) {
- return matcher.group(1);
- }
- }
- return null;
- }
-
- @Override
- public String getTaskIdFromTaskUrl(String taskFullUrl) {
- if (taskFullUrl != null) {
- Matcher matcher = Pattern
- .compile(".+?/issues/issue/([^/]+)").matcher(taskFullUrl); //$NON-NLS-1$
- if (matcher.matches()) {
- return matcher.group(1);
- }
- }
- return null;
- }
-
- @Override
- public String getTaskUrl(String repositoryUrl, String taskId) {
- return repositoryUrl + "/issues/issue/" + taskId; //$NON-NLS-1$
- }
-
- @Override
- public void updateRepositoryConfiguration(TaskRepository taskRepository,
- IProgressMonitor monitor) throws CoreException {
- monitor = Policy.monitorFor(monitor);
- monitor.beginTask("", 2); //$NON-NLS-1$
- monitor.setTaskName(Messages.GitHubRepositoryConnector_TaskUpdatingLabels);
- refreshLabels(taskRepository);
- monitor.worked(1);
- monitor.setTaskName(Messages.GitHubRepositoryConnector_TaskUpdatingMilestones);
- refreshMilestones(taskRepository);
- monitor.done();
- }
-
- @Override
- public boolean hasTaskChanged(TaskRepository repository, ITask task,
- TaskData taskData) {
- TaskAttribute modAttribute = taskData.getRoot().getAttribute(
- TaskAttribute.DATE_MODIFICATION);
- if (modAttribute == null)
- return false;
-
- boolean changed = true;
- Date modDate = task.getModificationDate();
- if (modDate != null) {
- Date updateDate = taskData.getAttributeMapper().getDateValue(
- modAttribute);
- if (updateDate != null)
- changed = updateDate.after(modDate);
- }
- return changed;
- }
-
- @Override
- public void updateTaskFromTaskData(TaskRepository taskRepository,
- ITask task, TaskData taskData) {
- if (!taskData.isNew()) {
- task.setUrl(getTaskUrl(taskRepository.getUrl(),
- taskData.getTaskId()));
- }
- new TaskMapper(taskData).applyTo(task);
- }
-
-}
+/******************************************************************************* + * Copyright (c) 2011 Red Hat and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * David Green <david.green@tasktop.com> - initial contribution + * Christian Trutz <christian.trutz@gmail.com> - initial contribution + * Chris Aniszczyk <caniszczyk@gmail.com> - initial contribution + *******************************************************************************/ +package org.eclipse.mylyn.github.internal; + +import java.io.IOException; +import java.util.Collections; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.mylyn.commons.net.AuthenticationCredentials; +import org.eclipse.mylyn.commons.net.AuthenticationType; +import org.eclipse.mylyn.commons.net.Policy; +import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector; +import org.eclipse.mylyn.tasks.core.IRepositoryQuery; +import org.eclipse.mylyn.tasks.core.ITask; +import org.eclipse.mylyn.tasks.core.TaskRepository; +import org.eclipse.mylyn.tasks.core.data.AbstractTaskDataHandler; +import org.eclipse.mylyn.tasks.core.data.TaskAttribute; +import org.eclipse.mylyn.tasks.core.data.TaskData; +import org.eclipse.mylyn.tasks.core.data.TaskDataCollector; +import org.eclipse.mylyn.tasks.core.data.TaskMapper; +import org.eclipse.mylyn.tasks.core.sync.ISynchronizationSession; + +/** + * GitHub connector. + */ +public class GitHubRepositoryConnector extends AbstractRepositoryConnector { + + /** + * GitHub kind. + */ + public static final String KIND = GitHub.CONNECTOR_KIND; + + /** + * Create client for repository + * + * @param repository + * @return client + */ + public static GitHubClient createClient(TaskRepository repository) { + GitHubClient client = new GitHubClient(); + AuthenticationCredentials credentials = repository + .getCredentials(AuthenticationType.REPOSITORY); + if (credentials != null) + client.setCredentials(credentials.getUserName(), + credentials.getPassword()); + return client; + } + + /** + * GitHub specific {@link AbstractTaskDataHandler}. + */ + private final GitHubTaskDataHandler taskDataHandler; + + private final Map<TaskRepository, List<Label>> repositoryLabels = Collections + .synchronizedMap(new HashMap<TaskRepository, List<Label>>()); + + private final Map<TaskRepository, List<Milestone>> repositoryMilestones = Collections + .synchronizedMap(new HashMap<TaskRepository, List<Milestone>>()); + + /** + * Create GitHub issue repository connector + */ + public GitHubRepositoryConnector() { + taskDataHandler = new GitHubTaskDataHandler(this); + } + + /** + * Refresh labels for repository + * + * @param repository + * @return labels + * @throws CoreException + */ + public List<Label> refreshLabels(TaskRepository repository) + throws CoreException { + Assert.isNotNull(repository, "Repository cannot be null"); //$NON-NLS-1$ + Repository repo = GitHub.getRepository(repository.getRepositoryUrl()); + GitHubClient client = createClient(repository); + LabelService service = new LabelService(client); + try { + List<Label> labels = service.getLabels(repo.getOwner(), + repo.getName()); + Collections.sort(labels, new LabelComparator()); + this.repositoryLabels.put(repository, labels); + return labels; + } catch (IOException e) { + throw new CoreException(GitHub.createErrorStatus(e)); + } + } + + /** + * Get labels for task repository. + * + * @param repository + * @return non-null but possibly empty list of labels + */ + public List<Label> getLabels(TaskRepository repository) { + Assert.isNotNull(repository, "Repository cannot be null"); //$NON-NLS-1$ + List<Label> labels = new LinkedList<Label>(); + List<Label> cached = this.repositoryLabels.get(repository); + if (cached != null) { + labels.addAll(cached); + } + return labels; + } + + /** + * Are there cached labels for the specified task repository? + * + * @param repository + * @return true if contains labels, false otherwise + */ + public boolean hasCachedLabels(TaskRepository repository) { + return this.repositoryLabels.containsKey(repository); + } + + /** + * Refresh milestones for repository + * + * @param repository + * @return milestones + * @throws CoreException + */ + public List<Milestone> refreshMilestones(TaskRepository repository) + throws CoreException { + Assert.isNotNull(repository, "Repository cannot be null"); //$NON-NLS-1$ + Repository repo = GitHub.getRepository(repository.getRepositoryUrl()); + GitHubClient client = createClient(repository); + MilestoneService service = new MilestoneService(client); + try { + List<Milestone> milestones = new LinkedList<Milestone>(); + milestones.addAll(service.getMilestones(repo.getOwner(), + repo.getName(), IssueService.STATE_OPEN)); + milestones.addAll(service.getMilestones(repo.getOwner(), + repo.getName(), IssueService.STATE_CLOSED)); + this.repositoryMilestones.put(repository, milestones); + return milestones; + } catch (IOException e) { + throw new CoreException(GitHub.createErrorStatus(e)); + } + } + + /** + * Get milestones for task repository. + * + * @param repository + * @return non-null but possibly empty list of milestones + */ + public List<Milestone> getMilestones(TaskRepository repository) { + Assert.isNotNull(repository, "Repository cannot be null"); //$NON-NLS-1$ + List<Milestone> milestones = new LinkedList<Milestone>(); + List<Milestone> cached = this.repositoryMilestones.get(repository); + if (cached != null) { + milestones.addAll(cached); + } + return milestones; + } + + /** + * Are there cached milestones for the specified task repository? + * + * @param repository + * @return true if contains milestones, false otherwise + */ + public boolean hasCachedMilestones(TaskRepository repository) { + return this.repositoryMilestones.containsKey(repository); + } + + /** + * {@inheritDoc} + * + * @return always {@code true} + */ + @Override + public boolean canCreateNewTask(TaskRepository repository) { + return true; + } + + /** + * {@inheritDoc} + * + * @return always {@code true} + */ + @Override + public boolean canCreateTaskFromKey(TaskRepository repository) { + return true; + } + + /** + * {@inheritDoc} + * + * @see #KIND + */ + @Override + public String getConnectorKind() { + return KIND; + } + + /** + * {@inheritDoc} + */ + @Override + public String getLabel() { + return Messages.GitHubRepositoryConnector_LabelConnector; + } + + /** + * {@inheritDoc} + */ + @Override + public AbstractTaskDataHandler getTaskDataHandler() { + return this.taskDataHandler; + } + + @Override + public IStatus performQuery(TaskRepository repository, + IRepositoryQuery query, TaskDataCollector collector, + ISynchronizationSession session, IProgressMonitor monitor) { + IStatus result = Status.OK_STATUS; + List<String> statuses = QueryUtils.getAttributes( + IssueService.FILTER_STATE, query); + + monitor.beginTask(Messages.GitHubRepositoryConnector_TaskQuerying, + statuses.size()); + try { + Repository repo = GitHub.getRepository(repository + .getRepositoryUrl()); + + GitHubClient client = createClient(repository); + IssueService service = new IssueService(client); + + Map<String, String> filterData = new HashMap<String, String>(); + String mentions = query.getAttribute(IssueService.FILTER_MENTIONED); + if (mentions != null) + filterData.put(IssueService.FILTER_MENTIONED, mentions); + + String assignee = query.getAttribute(IssueService.FILTER_ASSIGNEE); + if (assignee != null) + filterData.put(IssueService.FILTER_ASSIGNEE, assignee); + + String milestone = query + .getAttribute(IssueService.FILTER_MILESTONE); + if (milestone != null) + filterData.put(IssueService.FILTER_MILESTONE, milestone); + + List<String> labels = QueryUtils.getAttributes( + IssueService.FILTER_LABELS, query); + if (!labels.isEmpty()) { + StringBuilder labelsQuery = new StringBuilder(); + for (String label : labels) + labelsQuery.append(label).append(','); + filterData.put(IssueService.FILTER_LABELS, + labelsQuery.toString()); + } + + for (String status : statuses) { + filterData.put(IssueService.FILTER_STATE, status); + List<Issue> issues = service.getIssues(repo.getOwner(), + repo.getName(), filterData); + + // collect task data + for (Issue issue : issues) { + TaskData taskData = taskDataHandler.createTaskData( + repository, monitor, repo.getOwner(), + repo.getName(), issue); + taskData.setPartial(true); + collector.accept(taskData); + } + monitor.worked(1); + } + + result = Status.OK_STATUS; + } catch (IOException e) { + result = GitHub.createErrorStatus(e); + } + + monitor.done(); + return result; + } + + @Override + public TaskData getTaskData(TaskRepository repository, String taskId, + IProgressMonitor monitor) throws CoreException { + Repository repo = GitHub.getRepository(repository.getRepositoryUrl()); + + try { + GitHubClient client = createClient(repository); + IssueService service = new IssueService(client); + Issue issue = service.getIssue(repo.getOwner(), repo.getName(), + taskId); + List<Comment> comments = null; + if (issue.getComments() > 0) { + comments = service.getComments(repo.getOwner(), repo.getName(), + taskId); + } + TaskData taskData = taskDataHandler.createTaskData(repository, + monitor, repo.getOwner(), repo.getName(), issue, comments); + + return taskData; + } catch (IOException e) { + throw new CoreException(GitHub.createErrorStatus(e)); + } + } + + @Override + public String getRepositoryUrlFromTaskUrl(String taskFullUrl) { + if (taskFullUrl != null) { + Matcher matcher = Pattern.compile( + "(http://.+?)/issues/issue/([^/]+)").matcher(taskFullUrl); //$NON-NLS-1$ + if (matcher.matches()) { + return matcher.group(1); + } + } + return null; + } + + @Override + public String getTaskIdFromTaskUrl(String taskFullUrl) { + if (taskFullUrl != null) { + Matcher matcher = Pattern + .compile(".+?/issues/issue/([^/]+)").matcher(taskFullUrl); //$NON-NLS-1$ + if (matcher.matches()) { + return matcher.group(1); + } + } + return null; + } + + @Override + public String getTaskUrl(String repositoryUrl, String taskId) { + return repositoryUrl + "/issues/issue/" + taskId; //$NON-NLS-1$ + } + + @Override + public void updateRepositoryConfiguration(TaskRepository taskRepository, + IProgressMonitor monitor) throws CoreException { + monitor = Policy.monitorFor(monitor); + monitor.beginTask("", 2); //$NON-NLS-1$ + monitor.setTaskName(Messages.GitHubRepositoryConnector_TaskUpdatingLabels); + refreshLabels(taskRepository); + monitor.worked(1); + monitor.setTaskName(Messages.GitHubRepositoryConnector_TaskUpdatingMilestones); + refreshMilestones(taskRepository); + monitor.done(); + } + + @Override + public boolean hasTaskChanged(TaskRepository repository, ITask task, + TaskData taskData) { + TaskAttribute modAttribute = taskData.getRoot().getAttribute( + TaskAttribute.DATE_MODIFICATION); + if (modAttribute == null) + return false; + + boolean changed = true; + Date modDate = task.getModificationDate(); + if (modDate != null) { + Date updateDate = taskData.getAttributeMapper().getDateValue( + modAttribute); + if (updateDate != null) + changed = updateDate.after(modDate); + } + return changed; + } + + @Override + public void updateTaskFromTaskData(TaskRepository taskRepository, + ITask task, TaskData taskData) { + if (!taskData.isNew()) { + task.setUrl(getTaskUrl(taskRepository.getUrl(), + taskData.getTaskId())); + } + new TaskMapper(taskData).applyTo(task); + } + +} diff --git a/org.eclipse.mylyn.github.doc/.project b/org.eclipse.mylyn.github.doc/.project index efd1c2f6..fb0d635d 100755 --- a/org.eclipse.mylyn.github.doc/.project +++ b/org.eclipse.mylyn.github.doc/.project @@ -1,22 +1,22 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.mylyn.github.doc</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- </natures>
-</projectDescription>
+<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.eclipse.mylyn.github.doc</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.pde.ManifestBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.SchemaBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.pde.PluginNature</nature> + </natures> +</projectDescription> diff --git a/org.eclipse.mylyn.github.doc/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.mylyn.github.doc/.settings/org.eclipse.jdt.core.prefs index ae6b8974..2d028d22 100755 --- a/org.eclipse.mylyn.github.doc/.settings/org.eclipse.jdt.core.prefs +++ b/org.eclipse.mylyn.github.doc/.settings/org.eclipse.jdt.core.prefs @@ -1,8 +1,8 @@ -#Wed Apr 27 22:38:44 CEST 2011
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
-org.eclipse.jdt.core.compiler.compliance=1.5
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.5
+#Wed Apr 27 22:38:44 CEST 2011 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.5 diff --git a/org.eclipse.mylyn.github.doc/build.properties b/org.eclipse.mylyn.github.doc/build.properties index b9714b19..15546e68 100755 --- a/org.eclipse.mylyn.github.doc/build.properties +++ b/org.eclipse.mylyn.github.doc/build.properties @@ -1,6 +1,6 @@ -bin.includes = META-INF/,\
- .,\
- plugin.properties,\
- plugin.xml,\
- help/,\
- images/
+bin.includes = META-INF/,\ + .,\ + plugin.properties,\ + plugin.xml,\ + help/,\ + images/ diff --git a/org.eclipse.mylyn.github.doc/help/book.css b/org.eclipse.mylyn.github.doc/help/book.css index c6b3f94a..d5d292c4 100755 --- a/org.eclipse.mylyn.github.doc/help/book.css +++ b/org.eclipse.mylyn.github.doc/help/book.css @@ -1,110 +1,110 @@ -P.Code {
- display: block;
- text-align: left;
- text-indent: 0.00pt;
- margin-top: 0.000000pt;
- margin-bottom: 0.000000pt;
- margin-right: 0.000000pt;
- margin-left: 15pt;
- font-weight: normal;
- font-style: normal;
- color: #4444CC;
- text-decoration: none;
- vertical-align: baseline;
- text-transform: none;
- font-family: "Courier New", Courier, monospace;
-}
-H6.CaptionFigColumn {
- display: block;
- text-align: left;
- text-indent: 0.000000pt;
- margin-top: 3.000000pt;
- margin-bottom: 11.000000pt;
- margin-right: 0.000000pt;
- margin-left: 0.000000pt;
- font-size: 75%;
- font-weight: bold;
- font-style: Italic;
- color: #000000;
- text-decoration: none;
- vertical-align: baseline;
- text-transform: none;
-}
-P.Note {
- display: block;
- text-align: left;
- text-indent: 0pt;
- margin-top: 19.500000pt;
- margin-bottom: 19.500000pt;
- margin-right: 0.000000pt;
- margin-left: 30pt;
- font-size: 110%;
- font-weight: normal;
- font-style: Italic;
- color: #000000;
- text-decoration: none;
- vertical-align: baseline;
- text-transform: none;
-}
-EM.UILabel {
- font-weight: Bold;
- font-style: normal;
- text-decoration: none;
- vertical-align: baseline;
- text-transform: none;
-}
-EM.CodeName {
- font-weight: Bold;
- font-style: normal;
- text-decoration: none;
- vertical-align: baseline;
- text-transform: none;
- font-family: "Courier New", Courier, monospace;
-}
-UL.NavList {
- margin-left: 1.5em;
- padding-left: 0px;
- list-style-type: none;
-}
-
-body, html { border: 0px }
-
-
-/* following font face declarations need to be removed for DBCS */
-
-body, h1, h2, h3, h4, h5, h6, p, table, td, caption, th, ul, ol, dl, li, dd, dt {font-family: Arial, Helvetica, sans-serif; color: #000000}
-pre, code { font-family: "Courier New", Courier, monospace;}
-
-/* end font face declarations */
-
-@media print {
- html { font-size: 12pt }
-}
-
-body { font-size: 83%; background: #FFFFFF; margin-bottom: 1em }
-h1 { font-size: 180%; margin-top: 5px; margin-bottom: 1px }
-h2 { font-size: 140%; margin-top: 25px; margin-bottom: 3px }
-h3 { font-size: 110%; margin-top: 20px; margin-bottom: 3px }
-h4 { font-size: 100%; margin-top: 20px; margin-bottom: 3px; font-style: italic }
-p { margin-top: 10px; margin-bottom: 10px }
-pre { font-size: 93%; margin-left: 6; color: #4444CC }
-code { font-size: 93%; }
-table { font-size: 100% } /* needed for quirks mode */
-a:link { color: #0000FF }
-a:hover { color: #000080 }
-a:visited { text-decoration: underline }
-ul { margin-top: 10px; margin-bottom: 10px; }
-li { margin-top: 5px; margin-bottom: 5px; }
-li p { margin-top: 5px; margin-bottom: 5px; }
-ol { margin-top: 10px; margin-bottom: 10px; }
-dl { margin-top: 10px; margin-bottom: 10px; }
-dt { margin-top: 5px; margin-bottom: 5px; font-weight: bold; }
-dd { margin-top: 5px; margin-bottom: 5px; }
-strong { font-weight: bold}
-em { font-style: italic}
-var { font-style: italic}
-div.revision {
- border-left-style: solid; border-left-width: thin;
- border-left-color: #7B68EE; padding-left:5
-}
-th { font-weight: bold }
+P.Code { + display: block; + text-align: left; + text-indent: 0.00pt; + margin-top: 0.000000pt; + margin-bottom: 0.000000pt; + margin-right: 0.000000pt; + margin-left: 15pt; + font-weight: normal; + font-style: normal; + color: #4444CC; + text-decoration: none; + vertical-align: baseline; + text-transform: none; + font-family: "Courier New", Courier, monospace; +} +H6.CaptionFigColumn { + display: block; + text-align: left; + text-indent: 0.000000pt; + margin-top: 3.000000pt; + margin-bottom: 11.000000pt; + margin-right: 0.000000pt; + margin-left: 0.000000pt; + font-size: 75%; + font-weight: bold; + font-style: Italic; + color: #000000; + text-decoration: none; + vertical-align: baseline; + text-transform: none; +} +P.Note { + display: block; + text-align: left; + text-indent: 0pt; + margin-top: 19.500000pt; + margin-bottom: 19.500000pt; + margin-right: 0.000000pt; + margin-left: 30pt; + font-size: 110%; + font-weight: normal; + font-style: Italic; + color: #000000; + text-decoration: none; + vertical-align: baseline; + text-transform: none; +} +EM.UILabel { + font-weight: Bold; + font-style: normal; + text-decoration: none; + vertical-align: baseline; + text-transform: none; +} +EM.CodeName { + font-weight: Bold; + font-style: normal; + text-decoration: none; + vertical-align: baseline; + text-transform: none; + font-family: "Courier New", Courier, monospace; +} +UL.NavList { + margin-left: 1.5em; + padding-left: 0px; + list-style-type: none; +} + +body, html { border: 0px } + + +/* following font face declarations need to be removed for DBCS */ + +body, h1, h2, h3, h4, h5, h6, p, table, td, caption, th, ul, ol, dl, li, dd, dt {font-family: Arial, Helvetica, sans-serif; color: #000000} +pre, code { font-family: "Courier New", Courier, monospace;} + +/* end font face declarations */ + +@media print { + html { font-size: 12pt } +} + +body { font-size: 83%; background: #FFFFFF; margin-bottom: 1em } +h1 { font-size: 180%; margin-top: 5px; margin-bottom: 1px } +h2 { font-size: 140%; margin-top: 25px; margin-bottom: 3px } +h3 { font-size: 110%; margin-top: 20px; margin-bottom: 3px } +h4 { font-size: 100%; margin-top: 20px; margin-bottom: 3px; font-style: italic } +p { margin-top: 10px; margin-bottom: 10px } +pre { font-size: 93%; margin-left: 6; color: #4444CC } +code { font-size: 93%; } +table { font-size: 100% } /* needed for quirks mode */ +a:link { color: #0000FF } +a:hover { color: #000080 } +a:visited { text-decoration: underline } +ul { margin-top: 10px; margin-bottom: 10px; } +li { margin-top: 5px; margin-bottom: 5px; } +li p { margin-top: 5px; margin-bottom: 5px; } +ol { margin-top: 10px; margin-bottom: 10px; } +dl { margin-top: 10px; margin-bottom: 10px; } +dt { margin-top: 5px; margin-bottom: 5px; font-weight: bold; } +dd { margin-top: 5px; margin-bottom: 5px; } +strong { font-weight: bold} +em { font-style: italic} +var { font-style: italic} +div.revision { + border-left-style: solid; border-left-width: thin; + border-left-color: #7B68EE; padding-left:5 +} +th { font-weight: bold } diff --git a/org.eclipse.mylyn.github.doc/pom.xml b/org.eclipse.mylyn.github.doc/pom.xml index 00354fe0..ab7eb3a0 100755 --- a/org.eclipse.mylyn.github.doc/pom.xml +++ b/org.eclipse.mylyn.github.doc/pom.xml @@ -1,58 +1,58 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<!--
-Copyright (C) 2011, Red Hat, Inc.
-Copyright (C) 2011, Chris Aniszczyk <caniszczyk@gmail.com>
- Christian Trutz <christian.trutz@gmail.com>
-
-All rights reserved. This program and the accompanying materials
-are made available under the terms of the Eclipse Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/epl-v10.html
--->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.eclipse.mylyn.github</groupId>
- <artifactId>github-parent</artifactId>
- <version>0.1.0-SNAPSHOT</version>
- </parent>
-
- <artifactId>org.eclipse.mylyn.github.doc</artifactId>
- <packaging>eclipse-plugin</packaging>
-
- <name>Eclipse EGit Mylyn GitHub Documentation (Incubation)</name>
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- <dependencies>
- <dependency>
- <groupId>ant</groupId>
- <artifactId>optional</artifactId>
- <version>1.5.4</version>
- </dependency>
- </dependencies>
- <executions>
- <execution>
- <phase>generate-sources</phase>
- <configuration>
- <tasks if="update.doc">
- <property name="compile_classpath" refid="maven.compile.classpath"/>
- <ant target="all" inheritRefs="true" antfile="build-help.xml"/>
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-</project>
-
+<?xml version="1.0" encoding="UTF-8"?> +<!-- +Copyright (C) 2011, Red Hat, Inc. +Copyright (C) 2011, Chris Aniszczyk <caniszczyk@gmail.com> + Christian Trutz <christian.trutz@gmail.com> + +All rights reserved. This program and the accompanying materials +are made available under the terms of the Eclipse Public License v1.0 +which accompanies this distribution, and is available at +http://www.eclipse.org/legal/epl-v10.html +--> + +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.eclipse.mylyn.github</groupId> + <artifactId>github-parent</artifactId> + <version>0.1.0-SNAPSHOT</version> + </parent> + + <artifactId>org.eclipse.mylyn.github.doc</artifactId> + <packaging>eclipse-plugin</packaging> + + <name>Eclipse EGit Mylyn GitHub Documentation (Incubation)</name> + + <build> + <plugins> + <plugin> + <artifactId>maven-antrun-plugin</artifactId> + <dependencies> + <dependency> + <groupId>ant</groupId> + <artifactId>optional</artifactId> + <version>1.5.4</version> + </dependency> + </dependencies> + <executions> + <execution> + <phase>generate-sources</phase> + <configuration> + <tasks if="update.doc"> + <property name="compile_classpath" refid="maven.compile.classpath"/> + <ant target="all" inheritRefs="true" antfile="build-help.xml"/> + </tasks> + </configuration> + <goals> + <goal>run</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> + diff --git a/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/CommentTest.java b/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/CommentTest.java index f22dc029..95491636 100755 --- a/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/CommentTest.java +++ b/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/CommentTest.java @@ -1,47 +1,47 @@ -/*******************************************************************************
- * Copyright (c) 2011 Christian Trutz
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Christian Trutz - initial API and implementation
- *******************************************************************************/
-package org.eclipse.mylyn.github.internal;
-
-import static org.junit.Assert.assertTrue;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.runners.MockitoJUnitRunner;
-
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-
-/**
- * Unit tests for {@link Comment}
- */
-@SuppressWarnings("restriction")
-@RunWith(MockitoJUnitRunner.class)
-public class CommentTest {
-
- private static final Gson gson = new GsonBuilder().setDateFormat(
- "yyyy-MM-dd").create();
-
- @Test
- public void getCreatedAt_ReferenceMutableObject() {
- Comment comment = gson.fromJson("{createdAt : '2003-10-10'}",
- Comment.class);
- comment.getCreatedAt().setTime(0);
- assertTrue(comment.getCreatedAt().getTime() != 0);
- }
-
- @Test
- public void getUpdatedAt_ReferenceMutableObject() {
- Comment comment = gson.fromJson("{updatedAt : '2003-10-10'}",
- Comment.class);
- comment.getUpdatedAt().setTime(0);
- assertTrue(comment.getUpdatedAt().getTime() != 0);
- }
-}
+/******************************************************************************* + * Copyright (c) 2011 Christian Trutz + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Christian Trutz - initial API and implementation + *******************************************************************************/ +package org.eclipse.mylyn.github.internal; + +import static org.junit.Assert.assertTrue; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.runners.MockitoJUnitRunner; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; + +/** + * Unit tests for {@link Comment} + */ +@SuppressWarnings("restriction") +@RunWith(MockitoJUnitRunner.class) +public class CommentTest { + + private static final Gson gson = new GsonBuilder().setDateFormat( + "yyyy-MM-dd").create(); + + @Test + public void getCreatedAt_ReferenceMutableObject() { + Comment comment = gson.fromJson("{createdAt : '2003-10-10'}", + Comment.class); + comment.getCreatedAt().setTime(0); + assertTrue(comment.getCreatedAt().getTime() != 0); + } + + @Test + public void getUpdatedAt_ReferenceMutableObject() { + Comment comment = gson.fromJson("{updatedAt : '2003-10-10'}", + Comment.class); + comment.getUpdatedAt().setTime(0); + assertTrue(comment.getUpdatedAt().getTime() != 0); + } +} diff --git a/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/GistRevisionTest.java b/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/GistRevisionTest.java index e12b261d..a8eb4296 100755 --- a/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/GistRevisionTest.java +++ b/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/GistRevisionTest.java @@ -1,39 +1,39 @@ -/*******************************************************************************
- * Copyright (c) 2011 Christian Trutz
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Christian Trutz - initial API and implementation
- *******************************************************************************/
-package org.eclipse.mylyn.github.internal;
-
-import static org.junit.Assert.assertTrue;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.runners.MockitoJUnitRunner;
-
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-
-/**
- * Unit tests for {@link GistRevision}
- */
-@SuppressWarnings("restriction")
-@RunWith(MockitoJUnitRunner.class)
-public class GistRevisionTest {
-
- private static final Gson gson = new GsonBuilder().setDateFormat(
- "yyyy-MM-dd").create();
-
- @Test
- public void getCreatedAt_ReferenceMutableObject() {
- GistRevision gistRevision = gson.fromJson(
- "{committedAt : '2003-10-10'}", GistRevision.class);
- gistRevision.getCommittedAt().setTime(0);
- assertTrue(gistRevision.getCommittedAt().getTime() != 0);
- }
-}
+/******************************************************************************* + * Copyright (c) 2011 Christian Trutz + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Christian Trutz - initial API and implementation + *******************************************************************************/ +package org.eclipse.mylyn.github.internal; + +import static org.junit.Assert.assertTrue; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.runners.MockitoJUnitRunner; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; + +/** + * Unit tests for {@link GistRevision} + */ +@SuppressWarnings("restriction") +@RunWith(MockitoJUnitRunner.class) +public class GistRevisionTest { + + private static final Gson gson = new GsonBuilder().setDateFormat( + "yyyy-MM-dd").create(); + + @Test + public void getCreatedAt_ReferenceMutableObject() { + GistRevision gistRevision = gson.fromJson( + "{committedAt : '2003-10-10'}", GistRevision.class); + gistRevision.getCommittedAt().setTime(0); + assertTrue(gistRevision.getCommittedAt().getTime() != 0); + } +} diff --git a/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/GistTest.java b/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/GistTest.java index 29d2a15f..af5a0078 100755 --- a/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/GistTest.java +++ b/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/GistTest.java @@ -1,46 +1,46 @@ -/*******************************************************************************
- * Copyright (c) 2011 Christian Trutz
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Christian Trutz - initial API and implementation
- *******************************************************************************/
-package org.eclipse.mylyn.github.internal;
-
-import static org.junit.Assert.assertTrue;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.runners.MockitoJUnitRunner;
-
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-
-/**
- * Unit tests for {@link Gist}
- */
-@SuppressWarnings("restriction")
-@RunWith(MockitoJUnitRunner.class)
-public class GistTest {
-
- private static final Gson gson = new GsonBuilder().setDateFormat(
- "yyyy-MM-dd").create();
-
- @Test
- public void getCreatedAt_ReferenceMutableObject() {
- Gist gist = gson.fromJson("{createdAt : '2003-10-10'}", Gist.class);
- gist.getCreatedAt().setTime(0);
- assertTrue(gist.getCreatedAt().getTime() != 0);
- }
-
- @Test
- public void getUpdatedAt_ReferenceMutableObject() {
- Gist gist = gson.fromJson("{updatedAt : '2003-10-10'}", Gist.class);
- gist.getUpdatedAt().setTime(0);
- assertTrue(gist.getUpdatedAt().getTime() != 0);
- }
-
-}
+/******************************************************************************* + * Copyright (c) 2011 Christian Trutz + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Christian Trutz - initial API and implementation + *******************************************************************************/ +package org.eclipse.mylyn.github.internal; + +import static org.junit.Assert.assertTrue; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.runners.MockitoJUnitRunner; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; + +/** + * Unit tests for {@link Gist} + */ +@SuppressWarnings("restriction") +@RunWith(MockitoJUnitRunner.class) +public class GistTest { + + private static final Gson gson = new GsonBuilder().setDateFormat( + "yyyy-MM-dd").create(); + + @Test + public void getCreatedAt_ReferenceMutableObject() { + Gist gist = gson.fromJson("{createdAt : '2003-10-10'}", Gist.class); + gist.getCreatedAt().setTime(0); + assertTrue(gist.getCreatedAt().getTime() != 0); + } + + @Test + public void getUpdatedAt_ReferenceMutableObject() { + Gist gist = gson.fromJson("{updatedAt : '2003-10-10'}", Gist.class); + gist.getUpdatedAt().setTime(0); + assertTrue(gist.getUpdatedAt().getTime() != 0); + } + +} diff --git a/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/GitHubClientTest.java b/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/GitHubClientTest.java index 088adb9f..a5748298 100755 --- a/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/GitHubClientTest.java +++ b/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/GitHubClientTest.java @@ -1,27 +1,27 @@ -/*******************************************************************************
- * Copyright (c) 2011 Christian Trutz
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Christian Trutz - initial API and implementation
- *******************************************************************************/
-package org.eclipse.mylyn.github.internal;
-
-import org.eclipse.core.runtime.AssertionFailedException;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.runners.MockitoJUnitRunner;
-
-@SuppressWarnings("restriction")
-@RunWith(MockitoJUnitRunner.class)
-public class GitHubClientTest {
-
- @Test(expected = AssertionFailedException.class)
- public void constructor_NullArgument() {
- new GitHubClient(null);
- }
-
-}
+/******************************************************************************* + * Copyright (c) 2011 Christian Trutz + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Christian Trutz - initial API and implementation + *******************************************************************************/ +package org.eclipse.mylyn.github.internal; + +import org.eclipse.core.runtime.AssertionFailedException; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.runners.MockitoJUnitRunner; + +@SuppressWarnings("restriction") +@RunWith(MockitoJUnitRunner.class) +public class GitHubClientTest { + + @Test(expected = AssertionFailedException.class) + public void constructor_NullArgument() { + new GitHubClient(null); + } + +} diff --git a/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/IssueTest.java b/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/IssueTest.java index f52e8887..65d0673b 100755 --- a/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/IssueTest.java +++ b/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/IssueTest.java @@ -1,53 +1,53 @@ -/*******************************************************************************
- * Copyright (c) 2011 Christian Trutz
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Christian Trutz - initial API and implementation
- *******************************************************************************/
-package org.eclipse.mylyn.github.internal;
-
-import static org.junit.Assert.assertTrue;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.runners.MockitoJUnitRunner;
-
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-
-/**
- * Unit tests for {@link Issue}
- */
-@SuppressWarnings("restriction")
-@RunWith(MockitoJUnitRunner.class)
-public class IssueTest {
-
- private static final Gson gson = new GsonBuilder().setDateFormat(
- "yyyy-MM-dd").create();
-
- @Test
- public void getCreatedAt_ReferenceMutableObject() {
- Issue issue = gson.fromJson("{createdAt : '2003-10-10'}", Issue.class);
- issue.getCreatedAt().setTime(0);
- assertTrue(issue.getCreatedAt().getTime() != 0);
- }
-
- @Test
- public void getUpdatedAt_ReferenceMutableObject() {
- Issue issue = gson.fromJson("{updatedAt : '2003-10-10'}", Issue.class);
- issue.getUpdatedAt().setTime(0);
- assertTrue(issue.getUpdatedAt().getTime() != 0);
- }
-
- @Test
- public void getClosedAt_ReferenceMutableObject() {
- Issue issue = gson.fromJson("{closedAt : '2003-10-10'}", Issue.class);
- issue.getClosedAt().setTime(0);
- assertTrue(issue.getClosedAt().getTime() != 0);
- }
-
-}
+/******************************************************************************* + * Copyright (c) 2011 Christian Trutz + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Christian Trutz - initial API and implementation + *******************************************************************************/ +package org.eclipse.mylyn.github.internal; + +import static org.junit.Assert.assertTrue; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.runners.MockitoJUnitRunner; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; + +/** + * Unit tests for {@link Issue} + */ +@SuppressWarnings("restriction") +@RunWith(MockitoJUnitRunner.class) +public class IssueTest { + + private static final Gson gson = new GsonBuilder().setDateFormat( + "yyyy-MM-dd").create(); + + @Test + public void getCreatedAt_ReferenceMutableObject() { + Issue issue = gson.fromJson("{createdAt : '2003-10-10'}", Issue.class); + issue.getCreatedAt().setTime(0); + assertTrue(issue.getCreatedAt().getTime() != 0); + } + + @Test + public void getUpdatedAt_ReferenceMutableObject() { + Issue issue = gson.fromJson("{updatedAt : '2003-10-10'}", Issue.class); + issue.getUpdatedAt().setTime(0); + assertTrue(issue.getUpdatedAt().getTime() != 0); + } + + @Test + public void getClosedAt_ReferenceMutableObject() { + Issue issue = gson.fromJson("{closedAt : '2003-10-10'}", Issue.class); + issue.getClosedAt().setTime(0); + assertTrue(issue.getClosedAt().getTime() != 0); + } + +} diff --git a/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/MilestoneTest.java b/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/MilestoneTest.java index 957b4c5c..8230e71b 100755 --- a/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/MilestoneTest.java +++ b/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/MilestoneTest.java @@ -1,48 +1,48 @@ -/*******************************************************************************
- * Copyright (c) 2011 Christian Trutz
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Christian Trutz - initial API and implementation
- *******************************************************************************/
-package org.eclipse.mylyn.github.internal;
-
-import static org.junit.Assert.assertTrue;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.runners.MockitoJUnitRunner;
-
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-
-/**
- * Unit tests for {@link Milestone}
- */
-@SuppressWarnings("restriction")
-@RunWith(MockitoJUnitRunner.class)
-public class MilestoneTest {
-
- private static final Gson gson = new GsonBuilder().setDateFormat(
- "yyyy-MM-dd").create();
-
- @Test
- public void getCreatedAt_ReferenceMutableObject() {
- Milestone milestone = gson.fromJson("{createdAt : '2003-10-10'}",
- Milestone.class);
- milestone.getCreatedAt().setTime(0);
- assertTrue(milestone.getCreatedAt().getTime() != 0);
- }
-
- @Test
- public void getDueOn_ReferenceMutableObject() {
- Milestone milestone = gson.fromJson("{dueOn : '2003-10-10'}",
- Milestone.class);
- milestone.getDueOn().setTime(0);
- assertTrue(milestone.getDueOn().getTime() != 0);
- }
-
-}
+/******************************************************************************* + * Copyright (c) 2011 Christian Trutz + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Christian Trutz - initial API and implementation + *******************************************************************************/ +package org.eclipse.mylyn.github.internal; + +import static org.junit.Assert.assertTrue; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.runners.MockitoJUnitRunner; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; + +/** + * Unit tests for {@link Milestone} + */ +@SuppressWarnings("restriction") +@RunWith(MockitoJUnitRunner.class) +public class MilestoneTest { + + private static final Gson gson = new GsonBuilder().setDateFormat( + "yyyy-MM-dd").create(); + + @Test + public void getCreatedAt_ReferenceMutableObject() { + Milestone milestone = gson.fromJson("{createdAt : '2003-10-10'}", + Milestone.class); + milestone.getCreatedAt().setTime(0); + assertTrue(milestone.getCreatedAt().getTime() != 0); + } + + @Test + public void getDueOn_ReferenceMutableObject() { + Milestone milestone = gson.fromJson("{dueOn : '2003-10-10'}", + Milestone.class); + milestone.getDueOn().setTime(0); + assertTrue(milestone.getDueOn().getTime() != 0); + } + +} diff --git a/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/PullRequestServiceTest.java b/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/PullRequestServiceTest.java index 512c0804..4938f64a 100755 --- a/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/PullRequestServiceTest.java +++ b/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/PullRequestServiceTest.java @@ -1,93 +1,93 @@ -/*******************************************************************************
- * Copyright (c) 2011 Christian Trutz
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Christian Trutz - initial API and implementation
- *******************************************************************************/
-package org.eclipse.mylyn.github.internal;
-
-import static org.mockito.Mockito.when;
-
-import java.io.IOException;
-
-import org.eclipse.core.runtime.AssertionFailedException;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
-
-/**
- * Tests for {@link PullRequestServiceTest}
- */
-@SuppressWarnings("restriction")
-@RunWith(MockitoJUnitRunner.class)
-public class PullRequestServiceTest {
-
- @Mock
- private GitHubClient gitHubClient;
-
- @Mock
- private Repository repository;
-
- private PullRequestService pullRequestService;
-
- @Before
- public void before() {
- pullRequestService = new PullRequestService(gitHubClient);
- }
-
- @Test(expected = AssertionFailedException.class)
- public void constructor_NullArgument() {
- new PullRequestService(null);
- }
-
- @Test(expected = AssertionFailedException.class)
- public void getPullRequest_NullRepository() throws IOException {
- pullRequestService.getPullRequest(null, "not null");
- }
-
- @Test(expected = AssertionFailedException.class)
- public void getPullRequest_NullId() throws IOException {
- pullRequestService.getPullRequest(repository, null);
- }
-
- @Test(expected = AssertionFailedException.class)
- public void getPullRequest_NullRepositoryId() throws IOException {
- when(repository.getId()).thenReturn(null);
- pullRequestService.getPullRequest(repository, "test_id");
- }
-
- @Test
- @Ignore
- public void getPullRequest_OK() throws IOException {
- // the OK unit test is not possible with Mockito, but with JMockit
- }
-
- @Test(expected = AssertionFailedException.class)
- public void getPullRequests_NullRepository() throws IOException {
- pullRequestService.getPullRequests(null, "not null");
- }
-
- @Test(expected = AssertionFailedException.class)
- public void getPullRequests_NullState() throws IOException {
- pullRequestService.getPullRequests(repository, null);
- }
-
- @Test(expected = AssertionFailedException.class)
- public void getPullRequests_NullRepositoryId() throws IOException {
- when(repository.getId()).thenReturn(null);
- pullRequestService.getPullRequests(repository, "test_state");
- }
-
- @Test
- @Ignore
- public void getPullRequests_OK() throws IOException {
- // the OK unit test is not possible with Mockito, but with JMockit
- }
-}
+/******************************************************************************* + * Copyright (c) 2011 Christian Trutz + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Christian Trutz - initial API and implementation + *******************************************************************************/ +package org.eclipse.mylyn.github.internal; + +import static org.mockito.Mockito.when; + +import java.io.IOException; + +import org.eclipse.core.runtime.AssertionFailedException; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.runners.MockitoJUnitRunner; + +/** + * Tests for {@link PullRequestServiceTest} + */ +@SuppressWarnings("restriction") +@RunWith(MockitoJUnitRunner.class) +public class PullRequestServiceTest { + + @Mock + private GitHubClient gitHubClient; + + @Mock + private Repository repository; + + private PullRequestService pullRequestService; + + @Before + public void before() { + pullRequestService = new PullRequestService(gitHubClient); + } + + @Test(expected = AssertionFailedException.class) + public void constructor_NullArgument() { + new PullRequestService(null); + } + + @Test(expected = AssertionFailedException.class) + public void getPullRequest_NullRepository() throws IOException { + pullRequestService.getPullRequest(null, "not null"); + } + + @Test(expected = AssertionFailedException.class) + public void getPullRequest_NullId() throws IOException { + pullRequestService.getPullRequest(repository, null); + } + + @Test(expected = AssertionFailedException.class) + public void getPullRequest_NullRepositoryId() throws IOException { + when(repository.getId()).thenReturn(null); + pullRequestService.getPullRequest(repository, "test_id"); + } + + @Test + @Ignore + public void getPullRequest_OK() throws IOException { + // the OK unit test is not possible with Mockito, but with JMockit + } + + @Test(expected = AssertionFailedException.class) + public void getPullRequests_NullRepository() throws IOException { + pullRequestService.getPullRequests(null, "not null"); + } + + @Test(expected = AssertionFailedException.class) + public void getPullRequests_NullState() throws IOException { + pullRequestService.getPullRequests(repository, null); + } + + @Test(expected = AssertionFailedException.class) + public void getPullRequests_NullRepositoryId() throws IOException { + when(repository.getId()).thenReturn(null); + pullRequestService.getPullRequests(repository, "test_state"); + } + + @Test + @Ignore + public void getPullRequests_OK() throws IOException { + // the OK unit test is not possible with Mockito, but with JMockit + } +} diff --git a/org.eclipse.mylyn.github.ui/.project b/org.eclipse.mylyn.github.ui/.project index 6b7553c4..935513b7 100644 --- a/org.eclipse.mylyn.github.ui/.project +++ b/org.eclipse.mylyn.github.ui/.project @@ -1,28 +1,28 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.mylyn.github.ui</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
+<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.eclipse.mylyn.github.ui</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.ManifestBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.SchemaBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> diff --git a/org.eclipse.mylyn.github.ui/.settings/egit-github.launch b/org.eclipse.mylyn.github.ui/.settings/egit-github.launch index bb957aba..f4771c0d 100644 --- a/org.eclipse.mylyn.github.ui/.settings/egit-github.launch +++ b/org.eclipse.mylyn.github.ui/.settings/egit-github.launch @@ -1,61 +1,61 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<launchConfiguration type="org.eclipse.pde.ui.RuntimeWorkbench">
-<setAttribute key="additional_plugins"/>
-<booleanAttribute key="append.args" value="true"/>
-<booleanAttribute key="askclear" value="true"/>
-<booleanAttribute key="automaticAdd" value="true"/>
-<booleanAttribute key="automaticValidate" value="false"/>
-<stringAttribute key="bootstrap" value=""/>
-<stringAttribute key="checked" value="[NONE]"/>
-<booleanAttribute key="clearConfig" value="false"/>
-<booleanAttribute key="clearws" value="false"/>
-<booleanAttribute key="clearwslog" value="false"/>
-<stringAttribute key="configLocation" value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/egit-github"/>
-<booleanAttribute key="default" value="false"/>
-<stringAttribute key="deselected_workspace_plugins" value="org.eclipse.mylyn.github.tests,org.mockito"/>
-<stringAttribute key="featureDefaultLocation" value="workspace"/>
-<stringAttribute key="featurePluginResolution" value="workspace"/>
-<booleanAttribute key="includeOptional" value="true"/>
-<stringAttribute key="location" value="${workspace_loc}/../runtime-egit-github"/>
-<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
-<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
-<listEntry value="org.eclipse.debug.ui.launchGroup.run"/>
-</listAttribute>
-<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
-<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog"/>
-<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
-<booleanAttribute key="pde.generated.config" value="false"/>
-<stringAttribute key="pde.version" value="3.3"/>
-<stringAttribute key="product" value="org.eclipse.platform.ide"/>
-<setAttribute key="selected_features">
-<setEntry value="org.eclipse.cvs:default"/>
-<setEntry value="org.eclipse.equinox.p2.user.ui:default"/>
-<setEntry value="org.eclipse.help:default"/>
-<setEntry value="org.eclipse.jdt:default"/>
-<setEntry value="org.eclipse.mylyn.bugzilla_feature:default"/>
-<setEntry value="org.eclipse.mylyn.commons:default"/>
-<setEntry value="org.eclipse.mylyn.context_feature:default"/>
-<setEntry value="org.eclipse.mylyn.github.feature:default"/>
-<setEntry value="org.eclipse.mylyn.ide_feature:default"/>
-<setEntry value="org.eclipse.mylyn.java_feature:default"/>
-<setEntry value="org.eclipse.mylyn.pde_feature:default"/>
-<setEntry value="org.eclipse.mylyn.sdk_feature:default"/>
-<setEntry value="org.eclipse.mylyn.team_feature:default"/>
-<setEntry value="org.eclipse.mylyn.trac_feature:default"/>
-<setEntry value="org.eclipse.mylyn.wikitext.sdk:default"/>
-<setEntry value="org.eclipse.mylyn.wikitext_feature:default"/>
-<setEntry value="org.eclipse.mylyn_feature:default"/>
-<setEntry value="org.eclipse.pde:default"/>
-<setEntry value="org.eclipse.platform:default"/>
-<setEntry value="org.eclipse.rcp:default"/>
-</setAttribute>
-<stringAttribute key="selected_target_plugins" value="org.eclipse.compare@default:default,org.objenesis@default:default,org.eclipse.ui.net@default:default,org.eclipse.equinox.p2.updatesite@default:default,org.junit*3.8.2.v3_8_2_v20100427-1100@default:default,org.eclipse.core.databinding@default:default,org.easymock@default:default,org.eclipse.ui.editors@default:default,org.eclipse.osgi.services@default:default,org.eclipse.core.runtime@default:true,org.eclipse.equinox.jsp.jasper.registry@default:default,org.mockito@default:default,org.apache.ant@default:default,org.eclipse.ui.views.properties.tabbed@default:default,org.eclipse.jface@default:default,org.eclipse.help.appserver@default:default,org.eclipse.equinox.frameworkadmin.equinox@default:default,org.eclipse.equinox.p2.director.app@default:default,org.eclipse.core.filebuffers@default:default,org.eclipse.equinox.p2.ui.sdk.scheduler@default:default,org.eclipse.equinox.util@default:default,org.eclipse.core.databinding.observable@default:default,org.eclipse.equinox.http.servlet@default:default,org.eclipse.core.commands@default:default,org.eclipse.platform@default:default,org.hamcrest.text@default:default,org.eclipse.team.core@default:default,org.eclipse.swt.win32.win32.x86_64@default:false,org.hamcrest@default:default,org.eclipse.jface.text@default:default,org.eclipse.equinox.concurrent@default:default,org.eclipse.mylyn.commons.screenshots@default:default,org.eclipse.equinox.p2.directorywatcher@default:default,org.eclipse.mylyn.context.core@default:default,org.eclipse.equinox.simpleconfigurator@default:default,org.eclipse.mylyn.discovery.core@default:default,org.eclipse.ecf.provider.filetransfer.httpclient@default:default,org.eclipse.ecf.filetransfer@default:default,org.eclipse.debug.core@default:default,org.eclipse.core.runtime.compatibility.auth@default:default,org.eclipse.help.ui@default:default,org.eclipse.ui.externaltools@default:default,org.eclipse.equinox.ds@default:true,org.eclipse.osgi,org.eclipse.equinox.p2.metadata.repository@default:default,org.eclipse.core.expressions@default:default,org.eclipse.osgi.util@default:default,org.eclipse.ant.core@default:default,org.eclipse.equinox.p2.repository.tools@default:default,org.eclipse.mylyn.monitor.ui@default:default,org.eclipse.ltk.core.refactoring@default:default,org.eclipse.equinox.security@default:default,org.eclipse.equinox.p2.director@default:default,org.junit*4.8.1.v4_8_1_v20100427-1100@default:default,org.apache.lucene@default:default,org.eclipse.compare.core@default:default,org.eclipse.ecf.identity@default:default,com.ibm.icu@default:default,org.eclipse.ui.workbench@default:default,org.eclipse.ecf.provider.filetransfer.ssl@default:false,org.eclipse.equinox.http.jetty@default:default,org.eclipse.ui.navigator.resources@default:default,org.eclipse.ui.intro.universal@default:default,org.eclipse.ui.presentations.r21@default:default,org.eclipse.update.scheduler@default:default,org.eclipse.core.databinding.property@default:default,org.eclipse.ui.ide.application@default:default,com.jcraft.jsch@default:default,org.eclipse.platform.doc.user@default:default,org.eclipse.mylyn.tasks.search@default:default,org.mortbay.jetty.util@default:default,org.eclipse.mylyn.commons.ui@default:default,org.eclipse.search@default:default,org.eclipse.equinox.p2.engine@default:default,org.eclipse.equinox.p2.metadata.generator@default:default,org.eclipse.equinox.p2.reconciler.dropins@default:default,org.eclipse.equinox.simpleconfigurator.manipulator@default:default,org.eclipse.equinox.frameworkadmin@default:default,org.eclipse.equinox.p2.ui@default:default,org.eclipse.mylyn@default:default,org.eclipse.mylyn.commons.core@default:default,org.eclipse.equinox.p2.jarprocessor@default:default,org.eclipse.platform.doc.isv@default:default,org.eclipse.core.filesystem.win32.x86_64@default:false,com.thoughtworks.qdox@default:default,org.eclipse.mylyn.discovery.ui@default:default,org.eclipse.equinox.p2.metadata@default:default,org.eclipse.equinox.p2.operations@default:default,org.eclipse.equinox.p2.publisher@default:default,org.eclipse.equinox.p2.updatechecker@default:default,org.eclipse.equinox.launcher.win32.win32.x86_64@default:false,com.google.gson@default:default,org.apache.jasper@default:default,org.eclipse.ui.cheatsheets@default:default,org.sat4j.core@default:default,org.eclipse.ui.browser@default:default,org.eclipse.ecf.ssl@default:false,org.eclipse.mylyn.tasks.core@default:default,org.eclipse.equinox.p2.repository@default:default,org.eclipse.help.webapp@default:default,org.eclipse.rcp@default:default,org.eclipse.core.net@default:default,org.eclipse.equinox.http.registry@default:default,org.sat4j.pb@default:default,org.eclipse.mylyn.commons.net@default:default,org.hamcrest.core@default:default,org.eclipse.core.databinding.beans@default:default,org.apache.commons.codec@default:default,org.eclipse.core.filesystem@default:default,javax.servlet.jsp@default:default,org.eclipse.ui.win32@default:false,org.eclipse.ecf.provider.filetransfer.httpclient.ssl@default:false,org.eclipse.ltk.ui.refactoring@default:default,org.eclipse.core.contenttype@default:default,org.apache.commons.lang@default:default,org.eclipse.core.jobs@default:default,org.eclipse.help@default:default,org.eclipse.help.base@default:default,org.eclipse.core.boot@default:default,org.eclipse.ui.forms@default:default,org.eclipse.equinox.launcher@default:default,org.eclipse.equinox.p2.touchpoint.natives@default:default,org.eclipse.equinox.p2.extensionlocation@default:default,org.eclipse.ui.navigator@default:default,org.eclipse.core.resources@default:default,org.eclipse.equinox.p2.garbagecollector@default:default,org.eclipse.equinox.app@default:default,org.eclipse.jface.databinding@default:default,org.apache.commons.logging@default:default,org.apache.commons.el@default:default,org.eclipse.equinox.event@default:default,org.eclipse.equinox.p2.ql@default:default,org.mortbay.jetty.server@default:default,org.hamcrest.integration@default:default,org.eclipse.ecf.provider.filetransfer@default:default,org.eclipse.update.core.win32@default:false,org.eclipse.update.core@default:default,org.eclipse.swt@default:default,org.eclipse.update.configurator@default:default,org.eclipse.equinox.p2.ui.sdk@default:default,org.eclipse.mylyn.tasks.ui@default:default,org.eclipse.ui.console@default:default,org.eclipse.debug.ui@default:default,org.hamcrest.library@default:default,org.eclipse.equinox.security.ui@default:default,org.eclipse.equinox.registry@default:default,org.hamcrest.generator@default:default,org.eclipse.core.runtime.compatibility.registry@default:false,org.apache.commons.httpclient@default:default,org.eclipse.ui.workbench.compatibility@default:false,org.eclipse.mylyn.monitor.core@default:default,org.eclipse.ecf@default:default,org.apache.lucene.analysis@default:default,org.eclipse.team.ui@default:default,org.eclipse.equinox.p2.artifact.repository@default:default,org.eclipse.core.net.win32.x86_64@default:false,org.eclipse.mylyn.commons.repositories@default:default,org.eclipse.ui.views@default:default,org.eclipse.jsch.ui@default:default,org.eclipse.ui.ide@default:default,org.eclipse.ui.intro@default:default,org.eclipse.ui.workbench.texteditor@default:default,org.eclipse.ui@default:default,org.eclipse.compare.win32@default:default,org.eclipse.equinox.jsp.jasper@default:default,org.eclipse.equinox.p2.touchpoint.eclipse@default:default,org.eclipse.core.variables@default:default,org.eclipse.core.externaltools@default:default,javax.servlet@default:default,org.eclipse.equinox.preferences@default:default,org.eclipse.text@default:default,org.eclipse.equinox.p2.console@default:default,org.eclipse.jsch.core@default:default,org.eclipse.core.runtime.compatibility@default:default,org.eclipse.equinox.common@default:default,org.eclipse.mylyn.commons.team@default:default,org.eclipse.update.ui@default:default,org.eclipse.equinox.p2.core@default:default"/>
-<stringAttribute key="selected_workspace_plugins" value="org.eclipse.mylyn.github.ui@default:default,org.eclipse.mylyn.github.core@default:default"/>
-<booleanAttribute key="show_selected_only" value="false"/>
-<booleanAttribute key="tracing" value="false"/>
-<booleanAttribute key="useCustomFeatures" value="false"/>
-<booleanAttribute key="useDefaultConfig" value="true"/>
-<booleanAttribute key="useDefaultConfigArea" value="true"/>
-<booleanAttribute key="useProduct" value="true"/>
-<booleanAttribute key="usefeatures" value="false"/>
-</launchConfiguration>
+<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<launchConfiguration type="org.eclipse.pde.ui.RuntimeWorkbench"> +<setAttribute key="additional_plugins"/> +<booleanAttribute key="append.args" value="true"/> +<booleanAttribute key="askclear" value="true"/> +<booleanAttribute key="automaticAdd" value="true"/> +<booleanAttribute key="automaticValidate" value="false"/> +<stringAttribute key="bootstrap" value=""/> +<stringAttribute key="checked" value="[NONE]"/> +<booleanAttribute key="clearConfig" value="false"/> +<booleanAttribute key="clearws" value="false"/> +<booleanAttribute key="clearwslog" value="false"/> +<stringAttribute key="configLocation" value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/egit-github"/> +<booleanAttribute key="default" value="false"/> +<stringAttribute key="deselected_workspace_plugins" value="org.eclipse.mylyn.github.tests,org.mockito"/> +<stringAttribute key="featureDefaultLocation" value="workspace"/> +<stringAttribute key="featurePluginResolution" value="workspace"/> +<booleanAttribute key="includeOptional" value="true"/> +<stringAttribute key="location" value="${workspace_loc}/../runtime-egit-github"/> +<listAttribute key="org.eclipse.debug.ui.favoriteGroups"> +<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/> +<listEntry value="org.eclipse.debug.ui.launchGroup.run"/> +</listAttribute> +<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/> +<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog"/> +<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/> +<booleanAttribute key="pde.generated.config" value="false"/> +<stringAttribute key="pde.version" value="3.3"/> +<stringAttribute key="product" value="org.eclipse.platform.ide"/> +<setAttribute key="selected_features"> +<setEntry value="org.eclipse.cvs:default"/> +<setEntry value="org.eclipse.equinox.p2.user.ui:default"/> +<setEntry value="org.eclipse.help:default"/> +<setEntry value="org.eclipse.jdt:default"/> +<setEntry value="org.eclipse.mylyn.bugzilla_feature:default"/> +<setEntry value="org.eclipse.mylyn.commons:default"/> +<setEntry value="org.eclipse.mylyn.context_feature:default"/> +<setEntry value="org.eclipse.mylyn.github.feature:default"/> +<setEntry value="org.eclipse.mylyn.ide_feature:default"/> +<setEntry value="org.eclipse.mylyn.java_feature:default"/> +<setEntry value="org.eclipse.mylyn.pde_feature:default"/> +<setEntry value="org.eclipse.mylyn.sdk_feature:default"/> +<setEntry value="org.eclipse.mylyn.team_feature:default"/> +<setEntry value="org.eclipse.mylyn.trac_feature:default"/> +<setEntry value="org.eclipse.mylyn.wikitext.sdk:default"/> +<setEntry value="org.eclipse.mylyn.wikitext_feature:default"/> +<setEntry value="org.eclipse.mylyn_feature:default"/> +<setEntry value="org.eclipse.pde:default"/> +<setEntry value="org.eclipse.platform:default"/> +<setEntry value="org.eclipse.rcp:default"/> +</setAttribute> +<stringAttribute key="selected_target_plugins" value="org.eclipse.compare@default:default,org.objenesis@default:default,org.eclipse.ui.net@default:default,org.eclipse.equinox.p2.updatesite@default:default,org.junit*3.8.2.v3_8_2_v20100427-1100@default:default,org.eclipse.core.databinding@default:default,org.easymock@default:default,org.eclipse.ui.editors@default:default,org.eclipse.osgi.services@default:default,org.eclipse.core.runtime@default:true,org.eclipse.equinox.jsp.jasper.registry@default:default,org.mockito@default:default,org.apache.ant@default:default,org.eclipse.ui.views.properties.tabbed@default:default,org.eclipse.jface@default:default,org.eclipse.help.appserver@default:default,org.eclipse.equinox.frameworkadmin.equinox@default:default,org.eclipse.equinox.p2.director.app@default:default,org.eclipse.core.filebuffers@default:default,org.eclipse.equinox.p2.ui.sdk.scheduler@default:default,org.eclipse.equinox.util@default:default,org.eclipse.core.databinding.observable@default:default,org.eclipse.equinox.http.servlet@default:default,org.eclipse.core.commands@default:default,org.eclipse.platform@default:default,org.hamcrest.text@default:default,org.eclipse.team.core@default:default,org.eclipse.swt.win32.win32.x86_64@default:false,org.hamcrest@default:default,org.eclipse.jface.text@default:default,org.eclipse.equinox.concurrent@default:default,org.eclipse.mylyn.commons.screenshots@default:default,org.eclipse.equinox.p2.directorywatcher@default:default,org.eclipse.mylyn.context.core@default:default,org.eclipse.equinox.simpleconfigurator@default:default,org.eclipse.mylyn.discovery.core@default:default,org.eclipse.ecf.provider.filetransfer.httpclient@default:default,org.eclipse.ecf.filetransfer@default:default,org.eclipse.debug.core@default:default,org.eclipse.core.runtime.compatibility.auth@default:default,org.eclipse.help.ui@default:default,org.eclipse.ui.externaltools@default:default,org.eclipse.equinox.ds@default:true,org.eclipse.osgi,org.eclipse.equinox.p2.metadata.repository@default:default,org.eclipse.core.expressions@default:default,org.eclipse.osgi.util@default:default,org.eclipse.ant.core@default:default,org.eclipse.equinox.p2.repository.tools@default:default,org.eclipse.mylyn.monitor.ui@default:default,org.eclipse.ltk.core.refactoring@default:default,org.eclipse.equinox.security@default:default,org.eclipse.equinox.p2.director@default:default,org.junit*4.8.1.v4_8_1_v20100427-1100@default:default,org.apache.lucene@default:default,org.eclipse.compare.core@default:default,org.eclipse.ecf.identity@default:default,com.ibm.icu@default:default,org.eclipse.ui.workbench@default:default,org.eclipse.ecf.provider.filetransfer.ssl@default:false,org.eclipse.equinox.http.jetty@default:default,org.eclipse.ui.navigator.resources@default:default,org.eclipse.ui.intro.universal@default:default,org.eclipse.ui.presentations.r21@default:default,org.eclipse.update.scheduler@default:default,org.eclipse.core.databinding.property@default:default,org.eclipse.ui.ide.application@default:default,com.jcraft.jsch@default:default,org.eclipse.platform.doc.user@default:default,org.eclipse.mylyn.tasks.search@default:default,org.mortbay.jetty.util@default:default,org.eclipse.mylyn.commons.ui@default:default,org.eclipse.search@default:default,org.eclipse.equinox.p2.engine@default:default,org.eclipse.equinox.p2.metadata.generator@default:default,org.eclipse.equinox.p2.reconciler.dropins@default:default,org.eclipse.equinox.simpleconfigurator.manipulator@default:default,org.eclipse.equinox.frameworkadmin@default:default,org.eclipse.equinox.p2.ui@default:default,org.eclipse.mylyn@default:default,org.eclipse.mylyn.commons.core@default:default,org.eclipse.equinox.p2.jarprocessor@default:default,org.eclipse.platform.doc.isv@default:default,org.eclipse.core.filesystem.win32.x86_64@default:false,com.thoughtworks.qdox@default:default,org.eclipse.mylyn.discovery.ui@default:default,org.eclipse.equinox.p2.metadata@default:default,org.eclipse.equinox.p2.operations@default:default,org.eclipse.equinox.p2.publisher@default:default,org.eclipse.equinox.p2.updatechecker@default:default,org.eclipse.equinox.launcher.win32.win32.x86_64@default:false,com.google.gson@default:default,org.apache.jasper@default:default,org.eclipse.ui.cheatsheets@default:default,org.sat4j.core@default:default,org.eclipse.ui.browser@default:default,org.eclipse.ecf.ssl@default:false,org.eclipse.mylyn.tasks.core@default:default,org.eclipse.equinox.p2.repository@default:default,org.eclipse.help.webapp@default:default,org.eclipse.rcp@default:default,org.eclipse.core.net@default:default,org.eclipse.equinox.http.registry@default:default,org.sat4j.pb@default:default,org.eclipse.mylyn.commons.net@default:default,org.hamcrest.core@default:default,org.eclipse.core.databinding.beans@default:default,org.apache.commons.codec@default:default,org.eclipse.core.filesystem@default:default,javax.servlet.jsp@default:default,org.eclipse.ui.win32@default:false,org.eclipse.ecf.provider.filetransfer.httpclient.ssl@default:false,org.eclipse.ltk.ui.refactoring@default:default,org.eclipse.core.contenttype@default:default,org.apache.commons.lang@default:default,org.eclipse.core.jobs@default:default,org.eclipse.help@default:default,org.eclipse.help.base@default:default,org.eclipse.core.boot@default:default,org.eclipse.ui.forms@default:default,org.eclipse.equinox.launcher@default:default,org.eclipse.equinox.p2.touchpoint.natives@default:default,org.eclipse.equinox.p2.extensionlocation@default:default,org.eclipse.ui.navigator@default:default,org.eclipse.core.resources@default:default,org.eclipse.equinox.p2.garbagecollector@default:default,org.eclipse.equinox.app@default:default,org.eclipse.jface.databinding@default:default,org.apache.commons.logging@default:default,org.apache.commons.el@default:default,org.eclipse.equinox.event@default:default,org.eclipse.equinox.p2.ql@default:default,org.mortbay.jetty.server@default:default,org.hamcrest.integration@default:default,org.eclipse.ecf.provider.filetransfer@default:default,org.eclipse.update.core.win32@default:false,org.eclipse.update.core@default:default,org.eclipse.swt@default:default,org.eclipse.update.configurator@default:default,org.eclipse.equinox.p2.ui.sdk@default:default,org.eclipse.mylyn.tasks.ui@default:default,org.eclipse.ui.console@default:default,org.eclipse.debug.ui@default:default,org.hamcrest.library@default:default,org.eclipse.equinox.security.ui@default:default,org.eclipse.equinox.registry@default:default,org.hamcrest.generator@default:default,org.eclipse.core.runtime.compatibility.registry@default:false,org.apache.commons.httpclient@default:default,org.eclipse.ui.workbench.compatibility@default:false,org.eclipse.mylyn.monitor.core@default:default,org.eclipse.ecf@default:default,org.apache.lucene.analysis@default:default,org.eclipse.team.ui@default:default,org.eclipse.equinox.p2.artifact.repository@default:default,org.eclipse.core.net.win32.x86_64@default:false,org.eclipse.mylyn.commons.repositories@default:default,org.eclipse.ui.views@default:default,org.eclipse.jsch.ui@default:default,org.eclipse.ui.ide@default:default,org.eclipse.ui.intro@default:default,org.eclipse.ui.workbench.texteditor@default:default,org.eclipse.ui@default:default,org.eclipse.compare.win32@default:default,org.eclipse.equinox.jsp.jasper@default:default,org.eclipse.equinox.p2.touchpoint.eclipse@default:default,org.eclipse.core.variables@default:default,org.eclipse.core.externaltools@default:default,javax.servlet@default:default,org.eclipse.equinox.preferences@default:default,org.eclipse.text@default:default,org.eclipse.equinox.p2.console@default:default,org.eclipse.jsch.core@default:default,org.eclipse.core.runtime.compatibility@default:default,org.eclipse.equinox.common@default:default,org.eclipse.mylyn.commons.team@default:default,org.eclipse.update.ui@default:default,org.eclipse.equinox.p2.core@default:default"/> +<stringAttribute key="selected_workspace_plugins" value="org.eclipse.mylyn.github.ui@default:default,org.eclipse.mylyn.github.core@default:default"/> +<booleanAttribute key="show_selected_only" value="false"/> +<booleanAttribute key="tracing" value="false"/> +<booleanAttribute key="useCustomFeatures" value="false"/> +<booleanAttribute key="useDefaultConfig" value="true"/> +<booleanAttribute key="useDefaultConfigArea" value="true"/> +<booleanAttribute key="useProduct" value="true"/> +<booleanAttribute key="usefeatures" value="false"/> +</launchConfiguration> diff --git a/org.eclipse.mylyn.github.ui/.settings/org.eclipse.core.resources.prefs b/org.eclipse.mylyn.github.ui/.settings/org.eclipse.core.resources.prefs index 84f3fcc6..1a282b89 100644 --- a/org.eclipse.mylyn.github.ui/.settings/org.eclipse.core.resources.prefs +++ b/org.eclipse.mylyn.github.ui/.settings/org.eclipse.core.resources.prefs @@ -1,3 +1,3 @@ -#Tue Jun 09 20:22:15 CEST 2009
-eclipse.preferences.version=1
-encoding/<project>=UTF-8
+#Tue Jun 09 20:22:15 CEST 2009 +eclipse.preferences.version=1 +encoding/<project>=UTF-8 diff --git a/org.eclipse.mylyn.github.ui/.settings/org.eclipse.core.runtime.prefs b/org.eclipse.mylyn.github.ui/.settings/org.eclipse.core.runtime.prefs index f96d6778..e7ce3207 100644 --- a/org.eclipse.mylyn.github.ui/.settings/org.eclipse.core.runtime.prefs +++ b/org.eclipse.mylyn.github.ui/.settings/org.eclipse.core.runtime.prefs @@ -1,3 +1,3 @@ -#Tue Jun 09 20:22:15 CEST 2009
-eclipse.preferences.version=1
-line.separator=\n
+#Tue Jun 09 20:22:15 CEST 2009 +eclipse.preferences.version=1 +line.separator=\n diff --git a/org.eclipse.mylyn.github.ui/build.properties b/org.eclipse.mylyn.github.ui/build.properties index d924ee3e..bef8e620 100644 --- a/org.eclipse.mylyn.github.ui/build.properties +++ b/org.eclipse.mylyn.github.ui/build.properties @@ -1,7 +1,7 @@ -source.. = src/
-output.. = bin/
-bin.includes = META-INF/,\
- .,\
- plugin.xml,\
- plugin.properties,\
- icons/
+source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + plugin.xml,\ + plugin.properties,\ + icons/ diff --git a/org.eclipse.mylyn.github.ui/plugin.xml b/org.eclipse.mylyn.github.ui/plugin.xml index da73b429..5c02cacc 100644 --- a/org.eclipse.mylyn.github.ui/plugin.xml +++ b/org.eclipse.mylyn.github.ui/plugin.xml @@ -1,115 +1,115 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.4"?>
-<plugin>
- <extension
- point="org.eclipse.mylyn.tasks.ui.repositories">
- <connectorCore
- class="org.eclipse.mylyn.github.internal.GitHubRepositoryConnector"
- id="org.eclipse.mylyn.github.ui.internal.GitHubRepositoryConnector"
- name="%org.eclipse.mylyn.github.ui.internal.GitHubRepositoryConnector">
- </connectorCore>
- <connectorUi
- brandingIcon="icons/obj16/github.png"
- class="org.eclipse.mylyn.github.ui.internal.GitHubRepositoryConnectorUI"
- id="org.eclipse.mylyn.github.ui.internal.GitHubRepositoryConnectorUI"
- name="%org.eclipse.mylyn.github.ui.internal.GitHubRepositoryConnectorUI"
- overlayIcon="icons/obj16/github_8x8.png">
- </connectorUi>
- </extension>
- <extension
- point="org.eclipse.mylyn.tasks.ui.editors">
- <pageFactory
- class="org.eclipse.mylyn.github.ui.internal.GitHubTaskEditorPageFactory"
- id="org.eclipse.mylyn.github.ui.internal.GitHubTaskEditorPageFactory">
- </pageFactory>
- <pageFactory
- class="org.eclipse.mylyn.internal.github.ui.gist.GistTaskEditorPageFactory"
- id="org.eclipse.mylyn.internal.github.ui.gist.GistTaskEditorPageFactory">
- </pageFactory>
- </extension>
- <extension
- point="org.eclipse.ui.commands">
- <command
- description="Create Gist based on selection"
- id="org.eclipse.mylyn.github.ui.command.createGist"
- name="Create Gist">
- </command>
- <command
- description="Clone Gist into Git repository"
- id="org.eclipse.mylyn.github.ui.command.cloneGist"
- name="Clone Gist">
- </command>
- </extension>
- <extension
- point="org.eclipse.ui.menus">
- <menuContribution
- allPopups="false"
- locationURI="popup:#AbstractTextEditorContext?after=additions">
- <command
- commandId="org.eclipse.mylyn.github.ui.command.createGist"
- icon="icons/obj16/github.png"
- label="Create Gist"
- style="push">
- </command>
- </menuContribution>
- <menuContribution
- allPopups="false"
- locationURI="popup:org.eclipse.ui.popup.any">
- <command
- commandId="org.eclipse.mylyn.github.ui.command.createGist"
- icon="icons/obj16/github.png"
- label="Create Gist"
- style="push">
- <visibleWhen
- checkEnabled="false">
- <with
- variable="activeMenuSelection">
- <iterate
- ifEmpty="false">
- <adapt
- type="org.eclipse.core.resources.IFile">
- </adapt>
- </iterate>
- </with>
- </visibleWhen>
- </command>
- </menuContribution>
- </extension>
- <extension
- point="org.eclipse.ui.handlers">
- <handler
- class="org.eclipse.mylyn.github.ui.internal.CreateGistHandler"
- commandId="org.eclipse.mylyn.github.ui.command.createGist">
- </handler>
- <handler
- class="org.eclipse.mylyn.internal.github.ui.gist.CloneGistHandler"
- commandId="org.eclipse.mylyn.github.ui.command.cloneGist">
- </handler>
- </extension>
- <extension
- point="org.eclipse.mylyn.tasks.ui.repositories">
- <connectorCore
- class="org.eclipse.mylyn.internal.github.core.gist.GistConnector"
- id="org.eclipse.mylyn.internal.github.core.gist.GistConnector"
- name="%gistCoreConnectorName">
- </connectorCore>
- <connectorUi
- brandingIcon="icons/obj16/github.png"
- class="org.eclipse.mylyn.internal.github.ui.gist.GistConnectorUi"
- id="org.eclipse.mylyn.internal.github.ui.gist.GistConnectorUi"
- name="%gistUiConnectorName"
- overlayIcon="icons/obj16/github_8x8.png">
- </connectorUi>
- </extension>
- <extension
- point="org.eclipse.ui.importWizards">
- <wizard
- category="org.eclipse.mylyn.tasks.ui.wizards.import.category"
- class="org.eclipse.mylyn.github.ui.internal.ImportRepositoriesWizard"
- icon="icons/obj16/github.png"
- id="org.eclipse.mylyn.github.ui.importRepositoriesWizard"
- name="%importRepositoriesWizardName">
- </wizard>
- </extension>
-
-</plugin>
+<?xml version="1.0" encoding="UTF-8"?> +<?eclipse version="3.4"?> +<plugin> + <extension + point="org.eclipse.mylyn.tasks.ui.repositories"> + <connectorCore + class="org.eclipse.mylyn.github.internal.GitHubRepositoryConnector" + id="org.eclipse.mylyn.github.ui.internal.GitHubRepositoryConnector" + name="%org.eclipse.mylyn.github.ui.internal.GitHubRepositoryConnector"> + </connectorCore> + <connectorUi + brandingIcon="icons/obj16/github.png" + class="org.eclipse.mylyn.github.ui.internal.GitHubRepositoryConnectorUI" + id="org.eclipse.mylyn.github.ui.internal.GitHubRepositoryConnectorUI" + name="%org.eclipse.mylyn.github.ui.internal.GitHubRepositoryConnectorUI" + overlayIcon="icons/obj16/github_8x8.png"> + </connectorUi> + </extension> + <extension + point="org.eclipse.mylyn.tasks.ui.editors"> + <pageFactory + class="org.eclipse.mylyn.github.ui.internal.GitHubTaskEditorPageFactory" + id="org.eclipse.mylyn.github.ui.internal.GitHubTaskEditorPageFactory"> + </pageFactory> + <pageFactory + class="org.eclipse.mylyn.internal.github.ui.gist.GistTaskEditorPageFactory" + id="org.eclipse.mylyn.internal.github.ui.gist.GistTaskEditorPageFactory"> + </pageFactory> + </extension> + <extension + point="org.eclipse.ui.commands"> + <command + description="Create Gist based on selection" + id="org.eclipse.mylyn.github.ui.command.createGist" + name="Create Gist"> + </command> + <command + description="Clone Gist into Git repository" + id="org.eclipse.mylyn.github.ui.command.cloneGist" + name="Clone Gist"> + </command> + </extension> + <extension + point="org.eclipse.ui.menus"> + <menuContribution + allPopups="false" + locationURI="popup:#AbstractTextEditorContext?after=additions"> + <command + commandId="org.eclipse.mylyn.github.ui.command.createGist" + icon="icons/obj16/github.png" + label="Create Gist" + style="push"> + </command> + </menuContribution> + <menuContribution + allPopups="false" + locationURI="popup:org.eclipse.ui.popup.any"> + <command + commandId="org.eclipse.mylyn.github.ui.command.createGist" + icon="icons/obj16/github.png" + label="Create Gist" + style="push"> + <visibleWhen + checkEnabled="false"> + <with + variable="activeMenuSelection"> + <iterate + ifEmpty="false"> + <adapt + type="org.eclipse.core.resources.IFile"> + </adapt> + </iterate> + </with> + </visibleWhen> + </command> + </menuContribution> + </extension> + <extension + point="org.eclipse.ui.handlers"> + <handler + class="org.eclipse.mylyn.github.ui.internal.CreateGistHandler" + commandId="org.eclipse.mylyn.github.ui.command.createGist"> + </handler> + <handler + class="org.eclipse.mylyn.internal.github.ui.gist.CloneGistHandler" + commandId="org.eclipse.mylyn.github.ui.command.cloneGist"> + </handler> + </extension> + <extension + point="org.eclipse.mylyn.tasks.ui.repositories"> + <connectorCore + class="org.eclipse.mylyn.internal.github.core.gist.GistConnector" + id="org.eclipse.mylyn.internal.github.core.gist.GistConnector" + name="%gistCoreConnectorName"> + </connectorCore> + <connectorUi + brandingIcon="icons/obj16/github.png" + class="org.eclipse.mylyn.internal.github.ui.gist.GistConnectorUi" + id="org.eclipse.mylyn.internal.github.ui.gist.GistConnectorUi" + name="%gistUiConnectorName" + overlayIcon="icons/obj16/github_8x8.png"> + </connectorUi> + </extension> + <extension + point="org.eclipse.ui.importWizards"> + <wizard + category="org.eclipse.mylyn.tasks.ui.wizards.import.category" + class="org.eclipse.mylyn.github.ui.internal.ImportRepositoriesWizard" + icon="icons/obj16/github.png" + id="org.eclipse.mylyn.github.ui.importRepositoriesWizard" + name="%importRepositoriesWizardName"> + </wizard> + </extension> + +</plugin> diff --git a/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/github/ui/internal/GitHubRepositoryConnectorUI.java b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/github/ui/internal/GitHubRepositoryConnectorUI.java index 9cc52c0c..f536654d 100644 --- a/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/github/ui/internal/GitHubRepositoryConnectorUI.java +++ b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/github/ui/internal/GitHubRepositoryConnectorUI.java @@ -1,173 +1,173 @@ -/*******************************************************************************
- * Copyright (c) 2011 Red Hat and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * David Green <david.green@tasktop.com> - initial contribution
- * Christian Trutz <christian.trutz@gmail.com> - initial contribution
- * Chris Aniszczyk <caniszczyk@gmail.com> - initial contribution
- *******************************************************************************/
-package org.eclipse.mylyn.github.ui.internal;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.hyperlink.IHyperlink;
-import org.eclipse.jface.text.hyperlink.URLHyperlink;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.wizard.IWizard;
-import org.eclipse.mylyn.github.internal.GitHub;
-import org.eclipse.mylyn.github.internal.GitHubRepositoryConnector;
-import org.eclipse.mylyn.github.internal.Repository;
-import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
-import org.eclipse.mylyn.tasks.core.ITaskMapping;
-import org.eclipse.mylyn.tasks.core.TaskRepository;
-import org.eclipse.mylyn.tasks.ui.AbstractRepositoryConnectorUi;
-import org.eclipse.mylyn.tasks.ui.TaskHyperlink;
-import org.eclipse.mylyn.tasks.ui.TasksUi;
-import org.eclipse.mylyn.tasks.ui.wizards.AbstractRepositorySettingsPage;
-import org.eclipse.mylyn.tasks.ui.wizards.ITaskRepositoryPage;
-import org.eclipse.mylyn.tasks.ui.wizards.ITaskSearchPage;
-import org.eclipse.mylyn.tasks.ui.wizards.NewTaskWizard;
-import org.eclipse.mylyn.tasks.ui.wizards.RepositoryQueryWizard;
-
-/**
- * GitHub connector specific UI extensions.
- */
-public class GitHubRepositoryConnectorUI extends AbstractRepositoryConnectorUi {
-
- private final Pattern issuePattern = Pattern.compile("(?:([a-zA-Z0-9_\\.-]+)(?:/([a-zA-Z0-9_\\.-]+))?)?\\#(\\d+)");
-
- /**
- * Get core repository connector
- *
- * @return connector
- */
- public static GitHubRepositoryConnector getCoreConnector() {
- return (GitHubRepositoryConnector) TasksUi
- .getRepositoryConnector(GitHub.CONNECTOR_KIND);
- }
-
- /**
- *
- *
- * @return the unique type of the repository: "github"
- */
- @Override
- public String getConnectorKind() {
- return GitHub.CONNECTOR_KIND;
- }
-
- /**
- *
- *
- * @return {@link AbstractRepositorySettingsPage} with GitHub specific
- * parameter like user name, password, ...
- */
- @Override
- public ITaskRepositoryPage getSettingsPage(
- final TaskRepository taskRepository) {
- return new GitHubRepositorySettingsPage(taskRepository);
- }
-
- /**
- *
- *
- * @return {@link NewTaskWizard} with GitHub specific tab
- */
- @Override
- public IWizard getNewTaskWizard(final TaskRepository taskRepository,
- final ITaskMapping taskSelection) {
- return new NewTaskWizard(taskRepository, taskSelection);
- }
-
- /**
- * This {@link AbstractRepositoryConnectorUi} has search page.
- *
- * @return {@code true}
- */
- @Override
- public boolean hasSearchPage() {
- return true;
- }
-
- /**
- * Returns {@link IWizard} used in Mylyn for creating new queries. This
- * {@link IWizard} has a wizard page for creating GitHub specific task
- * queries.
- *
- * @return {@link RepositoryQueryWizard} with GitHub specific query page
- */
- @Override
- public IWizard getQueryWizard(final TaskRepository taskRepository,
- final IRepositoryQuery queryToEdit) {
- RepositoryQueryWizard wizard = new RepositoryQueryWizard(taskRepository);
- GitHubRepositoryQueryPage queryPage = new GitHubRepositoryQueryPage(
- taskRepository, queryToEdit);
- wizard.addPage(queryPage);
- return wizard;
- }
-
-
- public IHyperlink[] findHyperlinks(TaskRepository repository, String text, int index, int textOffset) {
- List<IHyperlink> hyperlinks = new ArrayList<IHyperlink>();
-
- Matcher matcher = issuePattern.matcher(text);
- while (matcher.find()) {
- if (index == -1 || (index >= matcher.start() && index <= matcher.end())) {
- String user = matcher.group(1);
- String project = matcher.group(2);
- String taskId = matcher.group(3);
-
- if (project == null && user != null) {
- // same project name, different user
- String url = repository.getUrl();
- Repository repo = GitHub.getRepository(url);
- if (repo != null)
- project = repo.getName();
- }
-
- TaskRepository taskRepository = null;
- if (user == null && project == null) {
- taskRepository = repository;
- } else if (user != null && project != null) {
- String repositoryUrl = GitHub.createGitHubUrl(user,project);
- taskRepository = TasksUi.getRepositoryManager().getRepository(GitHub.CONNECTOR_KIND, repositoryUrl);
- if (taskRepository == null) {
- repositoryUrl = GitHub.createGitHubUrlAlternate(user,project);
- taskRepository = TasksUi.getRepositoryManager().getRepository(GitHub.CONNECTOR_KIND, repositoryUrl);
- }
- }
- if (taskRepository != null) {
- Region region = createRegion(textOffset, matcher);
- hyperlinks.add(new TaskHyperlink(region, repository, taskId));
- } else if (user != null && project != null) {
- Region region = createRegion(textOffset, matcher);
- String url = GitHub.createGitHubUrl(user, project)+"/issues/issue/"+taskId;
- hyperlinks.add(new URLHyperlink(region, url));
- }
- }
- }
- return hyperlinks.toArray(new IHyperlink[hyperlinks.size()]);
- }
-
- private Region createRegion(int textOffset, Matcher matcher) {
- return new Region(matcher.start()+textOffset,matcher.end()-matcher.start());
- }
-
- /**
- * @see org.eclipse.mylyn.tasks.ui.AbstractRepositoryConnectorUi#getSearchPage(org.eclipse.mylyn.tasks.core.TaskRepository,
- * org.eclipse.jface.viewers.IStructuredSelection)
- */
- public ITaskSearchPage getSearchPage(TaskRepository repository,
- IStructuredSelection selection) {
- return new GitHubRepositoryQueryPage(repository, null);
- }
-
-}
+/******************************************************************************* + * Copyright (c) 2011 Red Hat and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * David Green <david.green@tasktop.com> - initial contribution + * Christian Trutz <christian.trutz@gmail.com> - initial contribution + * Chris Aniszczyk <caniszczyk@gmail.com> - initial contribution + *******************************************************************************/ +package org.eclipse.mylyn.github.ui.internal; + +import java.util.ArrayList; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.eclipse.jface.text.Region; +import org.eclipse.jface.text.hyperlink.IHyperlink; +import org.eclipse.jface.text.hyperlink.URLHyperlink; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.wizard.IWizard; +import org.eclipse.mylyn.github.internal.GitHub; +import org.eclipse.mylyn.github.internal.GitHubRepositoryConnector; +import org.eclipse.mylyn.github.internal.Repository; +import org.eclipse.mylyn.tasks.core.IRepositoryQuery; +import org.eclipse.mylyn.tasks.core.ITaskMapping; +import org.eclipse.mylyn.tasks.core.TaskRepository; +import org.eclipse.mylyn.tasks.ui.AbstractRepositoryConnectorUi; +import org.eclipse.mylyn.tasks.ui.TaskHyperlink; +import org.eclipse.mylyn.tasks.ui.TasksUi; +import org.eclipse.mylyn.tasks.ui.wizards.AbstractRepositorySettingsPage; +import org.eclipse.mylyn.tasks.ui.wizards.ITaskRepositoryPage; +import org.eclipse.mylyn.tasks.ui.wizards.ITaskSearchPage; +import org.eclipse.mylyn.tasks.ui.wizards.NewTaskWizard; +import org.eclipse.mylyn.tasks.ui.wizards.RepositoryQueryWizard; + +/** + * GitHub connector specific UI extensions. + */ +public class GitHubRepositoryConnectorUI extends AbstractRepositoryConnectorUi { + + private final Pattern issuePattern = Pattern.compile("(?:([a-zA-Z0-9_\\.-]+)(?:/([a-zA-Z0-9_\\.-]+))?)?\\#(\\d+)"); + + /** + * Get core repository connector + * + * @return connector + */ + public static GitHubRepositoryConnector getCoreConnector() { + return (GitHubRepositoryConnector) TasksUi + .getRepositoryConnector(GitHub.CONNECTOR_KIND); + } + + /** + * + * + * @return the unique type of the repository: "github" + */ + @Override + public String getConnectorKind() { + return GitHub.CONNECTOR_KIND; + } + + /** + * + * + * @return {@link AbstractRepositorySettingsPage} with GitHub specific + * parameter like user name, password, ... + */ + @Override + public ITaskRepositoryPage getSettingsPage( + final TaskRepository taskRepository) { + return new GitHubRepositorySettingsPage(taskRepository); + } + + /** + * + * + * @return {@link NewTaskWizard} with GitHub specific tab + */ + @Override + public IWizard getNewTaskWizard(final TaskRepository taskRepository, + final ITaskMapping taskSelection) { + return new NewTaskWizard(taskRepository, taskSelection); + } + + /** + * This {@link AbstractRepositoryConnectorUi} has search page. + * + * @return {@code true} + */ + @Override + public boolean hasSearchPage() { + return true; + } + + /** + * Returns {@link IWizard} used in Mylyn for creating new queries. This + * {@link IWizard} has a wizard page for creating GitHub specific task + * queries. + * + * @return {@link RepositoryQueryWizard} with GitHub specific query page + */ + @Override + public IWizard getQueryWizard(final TaskRepository taskRepository, + final IRepositoryQuery queryToEdit) { + RepositoryQueryWizard wizard = new RepositoryQueryWizard(taskRepository); + GitHubRepositoryQueryPage queryPage = new GitHubRepositoryQueryPage( + taskRepository, queryToEdit); + wizard.addPage(queryPage); + return wizard; + } + + + public IHyperlink[] findHyperlinks(TaskRepository repository, String text, int index, int textOffset) { + List<IHyperlink> hyperlinks = new ArrayList<IHyperlink>(); + + Matcher matcher = issuePattern.matcher(text); + while (matcher.find()) { + if (index == -1 || (index >= matcher.start() && index <= matcher.end())) { + String user = matcher.group(1); + String project = matcher.group(2); + String taskId = matcher.group(3); + + if (project == null && user != null) { + // same project name, different user + String url = repository.getUrl(); + Repository repo = GitHub.getRepository(url); + if (repo != null) + project = repo.getName(); + } + + TaskRepository taskRepository = null; + if (user == null && project == null) { + taskRepository = repository; + } else if (user != null && project != null) { + String repositoryUrl = GitHub.createGitHubUrl(user,project); + taskRepository = TasksUi.getRepositoryManager().getRepository(GitHub.CONNECTOR_KIND, repositoryUrl); + if (taskRepository == null) { + repositoryUrl = GitHub.createGitHubUrlAlternate(user,project); + taskRepository = TasksUi.getRepositoryManager().getRepository(GitHub.CONNECTOR_KIND, repositoryUrl); + } + } + if (taskRepository != null) { + Region region = createRegion(textOffset, matcher); + hyperlinks.add(new TaskHyperlink(region, repository, taskId)); + } else if (user != null && project != null) { + Region region = createRegion(textOffset, matcher); + String url = GitHub.createGitHubUrl(user, project)+"/issues/issue/"+taskId; + hyperlinks.add(new URLHyperlink(region, url)); + } + } + } + return hyperlinks.toArray(new IHyperlink[hyperlinks.size()]); + } + + private Region createRegion(int textOffset, Matcher matcher) { + return new Region(matcher.start()+textOffset,matcher.end()-matcher.start()); + } + + /** + * @see org.eclipse.mylyn.tasks.ui.AbstractRepositoryConnectorUi#getSearchPage(org.eclipse.mylyn.tasks.core.TaskRepository, + * org.eclipse.jface.viewers.IStructuredSelection) + */ + public ITaskSearchPage getSearchPage(TaskRepository repository, + IStructuredSelection selection) { + return new GitHubRepositoryQueryPage(repository, null); + } + +} |