Skip to content

Commit

Permalink
Merge branch 'nb81'
Browse files Browse the repository at this point in the history
  • Loading branch information
junichi11 committed Aug 12, 2017
2 parents 06cc50e + 1f5917b commit 4e8ca0c
Show file tree
Hide file tree
Showing 44 changed files with 2,615 additions and 472 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This plugin provides support for [backlog](http://backlogtool.com/?lang=1).

## Requirements

- NetBeans 8.0+
- NetBeans 8.1+

## Features

Expand All @@ -18,6 +18,7 @@ This plugin provides support for [backlog](http://backlogtool.com/?lang=1).
- Create queries
- Find issues
- Schedules
- Notification (only comment)

## Add Backlog repository

Expand Down Expand Up @@ -46,7 +47,6 @@ If you don't want to use thses, you can disable these in Options (Tools > Option
## Resources

- [Backlog4j](https://github.com/nulab/backlog4j)
- [yenta](https://bitbucket.org/jglick/yenta)

## License

Expand Down
5 changes: 3 additions & 2 deletions README_ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

## 必要条件

- NetBeans 8.0+
- NetBeans 8.1+

## 機能

Expand All @@ -17,6 +17,7 @@
- 問合せの作成
- 課題の検索
- スケジュール
- お知らせ (コメントのみ)

## Backlogリポジトリの追加

Expand All @@ -33,6 +34,7 @@

- 担当
- 登録
- お知らせ

完了以外の状態の課題が表示されます。
もしこれらの問合せを使いたくなければ、オプションで無効に設定できます。(ツール > オプション > チーム > Backlog)
Expand All @@ -44,7 +46,6 @@
## リソース

- [Backlog4j](https://github.com/nulab/backlog4j)
- [yenta](https://bitbucket.org/jglick/yenta)

## ライセンス

Expand Down
48 changes: 32 additions & 16 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.junichi11</groupId>
<artifactId>netbeans-backlog-plugin</artifactId>
<version>0.3.5</version>
<version>0.4.0</version>
<packaging>nbm</packaging>
<build>
<plugins>
Expand Down Expand Up @@ -54,18 +54,23 @@
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-netbeans-api-annotations-common</artifactId>
<version>RELEASE80</version>
<version>${netbeans.api.version}</version>
</dependency>
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-netbeans-modules-bugtracking</artifactId>
<version>RELEASE80</version>
<version>${netbeans.api.version}</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-openide-util</artifactId>
<version>RELEASE80</version>
<version>${netbeans.api.version}</version>
</dependency>
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-openide-util-ui</artifactId>
<version>${netbeans.api.version}</version>
</dependency>
<dependency>
<groupId>org.netbeans.external</groupId>
Expand All @@ -75,43 +80,53 @@
<dependency>
<groupId>org.netbeans.modules</groupId>
<artifactId>org-netbeans-modules-bugtracking-commons</artifactId>
<version>RELEASE80</version>
<version>${netbeans.api.version}</version>
</dependency>
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-netbeans-api-progress</artifactId>
<version>RELEASE80</version>
<version>${netbeans.api.version}</version>
</dependency>
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-netbeans-api-progress-nb</artifactId>
<version>${netbeans.api.version}</version>
</dependency>
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-openide-filesystems</artifactId>
<version>RELEASE80</version>
<version>${netbeans.api.version}</version>
</dependency>
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-openide-filesystems-nb</artifactId>
<version>${netbeans.api.version}</version>
</dependency>
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-openide-dialogs</artifactId>
<version>RELEASE80</version>
<version>${netbeans.api.version}</version>
</dependency>
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-openide-awt</artifactId>
<version>RELEASE80</version>
<version>${netbeans.api.version}</version>
</dependency>
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-openide-nodes</artifactId>
<version>RELEASE80</version>
<version>${netbeans.api.version}</version>
</dependency>
<dependency>
<groupId>org.netbeans.modules</groupId>
<artifactId>org-netbeans-modules-team-commons</artifactId>
<version>RELEASE80</version>
<version>${netbeans.api.version}</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.netbeans.external</groupId>
<artifactId>org-apache-commons-io</artifactId>
<version>RELEASE80</version>
<version>${netbeans.api.version}</version>
</dependency>
<dependency>
<groupId>com.nulab-inc</groupId>
Expand All @@ -121,17 +136,17 @@
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-openide-modules</artifactId>
<version>RELEASE80</version>
<version>${netbeans.api.version}</version>
</dependency>
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-openide-util-lookup</artifactId>
<version>RELEASE80</version>
<version>${netbeans.api.version}</version>
</dependency>
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-netbeans-modules-options-api</artifactId>
<version>RELEASE80</version>
<version>${netbeans.api.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
Expand All @@ -142,6 +157,7 @@
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<netbeans.api.version>RELEASE81-BETA</netbeans.api.version>
</properties>
<name>Backlog</name>
<description>This plugin provides support for &lt;a href ="http://backlogtool.com/?lang=1"&gt;backlog&lt;/a&gt;.
Expand All @@ -159,4 +175,4 @@
&lt;li&gt;&lt;a href="https://github.com/junichi11/netbeans-backlog-plugin"&gt;https://github.com/junichi11/netbeans-backlog-plugin&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/nulab/backlog4j"&gt;Backlog4j&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description>
</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,16 @@
*/
package com.junichi11.netbeans.modules.backlog;

import com.junichi11.netbeans.modules.backlog.issue.BacklogIssue;
import com.junichi11.netbeans.modules.backlog.query.BacklogQuery;
import com.junichi11.netbeans.modules.backlog.repository.BacklogRepository;
import com.junichi11.netbeans.modules.backlog.utils.StringUtils;
import java.util.ArrayList;
import java.util.prefs.BackingStoreException;
import java.util.prefs.Preferences;
import org.netbeans.modules.bugtracking.spi.IssueStatusProvider.Status;
import org.openide.util.Exceptions;
import org.openide.util.NbBundle;
import org.openide.util.NbPreferences;

/**
Expand All @@ -56,8 +60,21 @@
public final class BacklogConfig {

private static final BacklogConfig INSTANCE = new BacklogConfig();

// query
private static final String QUERY = "query"; // NOI18N
private static final String QUERY_PARAMS = "query.params"; // NOI18N

// status
private static final String STATUS = "status"; // NOI18N
// [status]::[last updated]
private static final String STATUS_FORMAT = "%s::%s"; // NOI18N
private static final String STATUS_DELIMITER = "::"; // NOI18N

// template
private static final String TEMPLATE = "template"; // NOI18N
private static final String DEFAULT_TEMPLATE_NAME = "default"; // NOI18N

private static final String QUERY_MAX_ISSUE_COUNT = "query.max.issue.count"; // NOI18N

private BacklogConfig() {
Expand All @@ -67,6 +84,43 @@ public static BacklogConfig getInstance() {
return INSTANCE;
}

public Status getStatus(BacklogIssue issue) {
BacklogRepository repository = issue.getRepository();
Preferences preferences = getPreferences().node(repository.getID()).node(STATUS);
String statusTime = preferences.get(issue.getKeyId(), null);
if (statusTime == null) {
return Status.INCOMING_NEW;
}

String[] split = statusTime.split(STATUS_DELIMITER);
if (split.length != 2) {
return Status.INCOMING_NEW;
}

// TODO CONFLICT, OUTGOING_NEW, OUTGOING_MODIFIED
Status status = Status.valueOf(split[0]);
long lastUpdated = Long.parseLong(split[1]);
if (status == Status.SEEN) {
long lastUpdatedTime = issue.getLastUpdatedTime();
if (lastUpdatedTime != -1L) {
if (lastUpdated < lastUpdatedTime) {
setStatus(issue, Status.INCOMING_MODIFIED);
return Status.INCOMING_MODIFIED;
}
}
}
return status;
}

public void setStatus(BacklogIssue issue, Status status) {
long lastUpdatedTime = issue.getLastUpdatedTime();
if (lastUpdatedTime != -1L) {
BacklogRepository repository = issue.getRepository();
Preferences preferences = getPreferences().node(repository.getID()).node(STATUS);
preferences.put(issue.getKeyId(), String.format(STATUS_FORMAT, status.name(), lastUpdatedTime));
}
}

/**
* Return saved query names.
*
Expand Down Expand Up @@ -151,6 +205,73 @@ public void setMaxIssueCount(BacklogRepository repository, BacklogQuery query) {
preferences.putInt(QUERY_MAX_ISSUE_COUNT, query.getMaxIssueCount());
}

/**
* Get the template for specified name.
*
* @param name the template name
* @return the template
*/
@NbBundle.Messages("BacklogConfig.default.template=#### Overview description\n"
+ "\n"
+ "#### Steps to reproduce\n"
+ "\n"
+ "1. \n"
+ "2. \n"
+ "3. \n"
+ "\n"
+ "#### Actual results\n"
+ "\n"
+ "#### Expected results\n")
public String getTemplate(String name) {
return getPreferences().node(TEMPLATE).get(name, Bundle.BacklogConfig_default_template());
}

/**
* Set template.
*
* @param name the template name
* @param template the template
*/
public void setTemplate(String name, String template) {
getPreferences().node(TEMPLATE).put(name, template);
}

/**
* Remove a template. <b>NOTE:</b> Can't remove the default template. But
* default template will be initialized.
*
* @param name the template name
*/
public void removeTemplate(String name) {
getPreferences().node(TEMPLATE).remove(name);
}

/**
* Get all template names.
*
* @return all template names
*/
public String[] getTemplateNames() {
ArrayList<String> names = new ArrayList<>();
names.add(DEFAULT_TEMPLATE_NAME);
Preferences preferences = getPreferences().node(TEMPLATE);
try {
// contains the default template if it was edited
String[] childrenNames = preferences.keys();
int count = 1; // default template
for (String childName : childrenNames) {
if (!childName.equals(DEFAULT_TEMPLATE_NAME)) {
names.add(childName);
count++;
}
}
return names.toArray(new String[count]);
} catch (BackingStoreException ex) {
Exceptions.printStackTrace(ex);
}
return names.toArray(new String[1]);
}

private Preferences getPreferences() {
return NbPreferences.forModule(BacklogConfig.class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,12 @@ public List<IssueType> getIssueTypes(boolean isForce) {
}

/**
* Get Users.
* Get project Users.
*
* @return Users
*/
public List<User> getUsers() {
return getUsers(false);
public List<User> getProjectUsers() {
return getProjectUsers(false);
}

/**
Expand All @@ -175,6 +175,9 @@ public List<User> getUsers() {
*/
@CheckForNull
public Icon getUserIcon(User user) {
if (user == null) {
return null;
}
Icon icon = userIcons.get(user);
if (icon != null) {
return icon;
Expand Down Expand Up @@ -203,13 +206,13 @@ public Icon getUserIcon(User user) {
}

/**
* Get Users.
* Get project Users.
*
* @param isForce {@code true} if you want to reload data, {@code false} if
* you want to use cache data
* @return Users
*/
public List<User> getUsers(boolean isForce) {
public List<User> getProjectUsers(boolean isForce) {
BacklogClient backlogClient = repository.createBacklogClient();
if (backlogClient == null) {
return Collections.emptyList();
Expand Down
Loading

0 comments on commit 4e8ca0c

Please sign in to comment.