summaryrefslogtreecommitdiff
path: root/plugins/tasks/tasks-core/src
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/tasks/tasks-core/src')
-rw-r--r--plugins/tasks/tasks-core/src/META-INF/plugin.xml2
-rw-r--r--plugins/tasks/tasks-core/src/com/intellij/tasks/trello/TrelloRepository.java30
-rw-r--r--plugins/tasks/tasks-core/src/com/intellij/tasks/trello/model/TrelloCard.java3
3 files changed, 23 insertions, 12 deletions
diff --git a/plugins/tasks/tasks-core/src/META-INF/plugin.xml b/plugins/tasks/tasks-core/src/META-INF/plugin.xml
index 36268b408073..6f3ac82f463a 100644
--- a/plugins/tasks/tasks-core/src/META-INF/plugin.xml
+++ b/plugins/tasks/tasks-core/src/META-INF/plugin.xml
@@ -103,7 +103,7 @@
<extensions defaultExtensionNs="com.intellij">
<errorHandler implementation="com.intellij.diagnostic.ITNReporter"/>
- <projectConfigurable instance="com.intellij.tasks.config.TaskConfigurable" id="tasks" displayName="Tasks" nonDefaultProject="true">
+ <projectConfigurable groupId="tools" instance="com.intellij.tasks.config.TaskConfigurable" id="tasks" displayName="Tasks" nonDefaultProject="true">
<configurable instance="com.intellij.tasks.config.TaskRepositoriesConfigurable" displayName="Servers" id="tasks.servers"/>
</projectConfigurable>
diff --git a/plugins/tasks/tasks-core/src/com/intellij/tasks/trello/TrelloRepository.java b/plugins/tasks/tasks-core/src/com/intellij/tasks/trello/TrelloRepository.java
index f7723a9f96fa..eafe341d3989 100644
--- a/plugins/tasks/tasks-core/src/com/intellij/tasks/trello/TrelloRepository.java
+++ b/plugins/tasks/tasks-core/src/com/intellij/tasks/trello/TrelloRepository.java
@@ -107,8 +107,8 @@ public final class TrelloRepository extends BaseRepositoryImpl {
}
@Override
- public Task[] getIssues(@Nullable String query, int max, long since) throws Exception {
- List<TrelloCard> cards = fetchCards();
+ public Task[] getIssues(@Nullable String query, int offset, int limit, boolean withClosed) throws Exception {
+ List<TrelloCard> cards = fetchCards(offset + limit, withClosed);
return ContainerUtil.map2Array(cards, Task.class, new Function<TrelloCard, Task>() {
@Override
public Task fun(TrelloCard card) {
@@ -120,17 +120,24 @@ public final class TrelloRepository extends BaseRepositoryImpl {
@Nullable
@Override
public Task findTask(@NotNull String id) throws Exception {
- String url = TRELLO_API_BASE_URL + "/cards/" + id + "?actions=commentCard&fields=" + encodeUrl(TrelloCard.REQUIRED_FIELDS) ;
+ TrelloCard card = fetchCardById(id);
+ return card != null ? new TrelloTask(card, this) : null;
+ }
+
+ @Nullable
+ public TrelloCard fetchCardById(@NotNull String id) throws Exception {
+ String url = TRELLO_API_BASE_URL + "/cards/" + id + "?actions=commentCard&fields=" + encodeUrl(TrelloCard.REQUIRED_FIELDS);
try {
- return new TrelloTask(makeRequestAndDeserializeJsonResponse(url, TrelloCard.class), this);
+ return makeRequestAndDeserializeJsonResponse(url, TrelloCard.class);
}
// Trello returns string "The requested resource was not found." or "invalid id"
- // if card can't be found
+ // if card can't be found, which not only cannot be deserialized, but also not valid JSON at all.
catch (JsonParseException e) {
return null;
}
}
+
@Nullable
public TrelloUser getCurrentUser() {
return myCurrentUser;
@@ -241,7 +248,7 @@ public final class TrelloRepository extends BaseRepositoryImpl {
}
@NotNull
- private List<TrelloCard> fetchCards() throws Exception {
+ public List<TrelloCard> fetchCards(int limit, boolean withClosed) throws Exception {
boolean fromList = false;
// choose most appropriate card provider
String baseUrl;
@@ -258,8 +265,10 @@ public final class TrelloRepository extends BaseRepositoryImpl {
else {
throw new IllegalStateException("Not configured");
}
- String allCardsUrl = baseUrl + "?filter=all&fields=" + encodeUrl(TrelloCard.REQUIRED_FIELDS);
- List<TrelloCard> cards = makeRequestAndDeserializeJsonResponse(allCardsUrl, TrelloUtil.LIST_OF_CARDS_TYPE);
+ String fetchCardsUrl = baseUrl + "?fields=" + encodeUrl(TrelloCard.REQUIRED_FIELDS) + "&limit" + limit;
+ // 'visible' filter for some reason is not supported for lists
+ fetchCardsUrl += withClosed || fromList ? "&filter=all" : "&filter=visible";
+ List<TrelloCard> cards = makeRequestAndDeserializeJsonResponse(fetchCardsUrl, TrelloUtil.LIST_OF_CARDS_TYPE);
LOG.debug("Total " + cards.size() + " cards downloaded");
if (!myIncludeAllCards) {
cards = ContainerUtil.filter(cards, new Condition<TrelloCard>() {
@@ -270,7 +279,10 @@ public final class TrelloRepository extends BaseRepositoryImpl {
});
LOG.debug("Total " + cards.size() + " cards after filtering");
}
- if (!fromList) {
+ if (!cards.isEmpty()) {
+ if (fromList) {
+ baseUrl = TRELLO_API_BASE_URL + "/boards/" + cards.get(0).getIdBoard() + "/cards";
+ }
// fix for IDEA-111470 and IDEA-111475
// Select IDs of visible cards, e.d. cards that either archived explicitly, belong to archived list or closed board.
// This information can't be extracted from single card description, because its 'closed' field
diff --git a/plugins/tasks/tasks-core/src/com/intellij/tasks/trello/model/TrelloCard.java b/plugins/tasks/tasks-core/src/com/intellij/tasks/trello/model/TrelloCard.java
index f4fc18d42500..4aebd6a67385 100644
--- a/plugins/tasks/tasks-core/src/com/intellij/tasks/trello/model/TrelloCard.java
+++ b/plugins/tasks/tasks-core/src/com/intellij/tasks/trello/model/TrelloCard.java
@@ -44,7 +44,6 @@ public class TrelloCard extends TrelloModel {
@SerializedName("desc")
private String description;
private String url;
- @SerializedName("due")
private boolean closed;
private Date dateLastActivity;
private List<TrelloLabel> labels;
@@ -91,7 +90,7 @@ public class TrelloCard extends TrelloModel {
}
@Override
- public void setName(String name) {
+ public void setName(@NotNull String name) {
this.name = name;
}