Преглед изворни кода

Test implementation of repository and type

matthias пре 4 година
родитељ
комит
3a7f669e33

+ 40 - 4
src/main/java/com/armstrongconsulting/acprotasks/AcproRepository.java

@@ -3,19 +3,55 @@ package com.armstrongconsulting.acprotasks;
3 3
 import org.jetbrains.annotations.NotNull;
4 4
 import org.jetbrains.annotations.Nullable;
5 5
 
6
+import com.intellij.openapi.progress.ProgressIndicator;
6 7
 import com.intellij.tasks.Task;
8
+import com.intellij.tasks.TaskRepositoryType;
7 9
 import com.intellij.tasks.impl.BaseRepository;
10
+import com.intellij.util.xmlb.annotations.Tag;
8 11
 
12
+@Tag(AcproRepositoryType.NAME)
9 13
 public class AcproRepository extends BaseRepository
10 14
 {
11 15
 
12
-    @Override public @Nullable Task findTask(@NotNull String id) throws Exception
16
+    public AcproRepository(TaskRepositoryType type)
13 17
     {
14
-        return null;
18
+        super(type);
15 19
     }
16 20
 
17
-    @Override public @NotNull BaseRepository clone()
21
+    public AcproRepository(BaseRepository other)
18 22
     {
19
-        return null;
23
+        super(other);
24
+    }
25
+
26
+    public AcproRepository()
27
+    {
28
+    }
29
+
30
+    @Override
31
+    public @Nullable Task findTask(@NotNull String id) throws Exception
32
+    {
33
+        return new AcproTask();
34
+    }
35
+
36
+    @Override
37
+    public @NotNull BaseRepository clone()
38
+    {
39
+        return new AcproRepository(this);
40
+    }
41
+
42
+    @Override
43
+    public Task[] getIssues(@Nullable String query, int offset, int limit, boolean withClosed)
44
+        throws Exception
45
+    {
46
+        System.out.println("Searching for issues (1): " + query);
47
+        return new Task[]{new AcproTask()};
48
+    }
49
+
50
+    @Override
51
+    public Task[] getIssues(@Nullable String query, int offset, int limit, boolean withClosed,
52
+        @NotNull ProgressIndicator cancelled) throws Exception
53
+    {
54
+        System.out.println("Searching for issues (2): " + query);
55
+        return new Task[]{new AcproTask()};
20 56
     }
21 57
 }

+ 13 - 8
src/main/java/com/armstrongconsulting/acprotasks/AcproRepositoryType.java

@@ -9,24 +9,29 @@ import com.intellij.tasks.impl.BaseRepositoryType;
9 9
 
10 10
 public class AcproRepositoryType extends BaseRepositoryType<AcproRepository>
11 11
 {
12
+    public static final String NAME = "AcproTasks";
12 13
 
13
-    @Override public @NotNull String getName()
14
+    @Override
15
+    public @NotNull String getName()
14 16
     {
15
-        return null;
17
+        return NAME;
16 18
     }
17 19
 
18
-    @Override public @NotNull Icon getIcon()
20
+    @Override
21
+    public @NotNull Icon getIcon()
19 22
     {
20
-        return null;
23
+        return new ImageIcon(getClass().getClassLoader().getResource("img/ac-logo-16.png"), "icon");
21 24
     }
22 25
 
23
-    @Override public @NotNull TaskRepository createRepository()
26
+    @Override
27
+    public @NotNull TaskRepository createRepository()
24 28
     {
25
-        return null;
29
+        return new AcproRepository(this);
26 30
     }
27 31
 
28
-    @Override public Class<AcproRepository> getRepositoryClass()
32
+    @Override
33
+    public Class<AcproRepository> getRepositoryClass()
29 34
     {
30
-        return null;
35
+        return AcproRepository.class;
31 36
     }
32 37
 }

+ 83 - 0
src/main/java/com/armstrongconsulting/acprotasks/AcproTask.java

@@ -0,0 +1,83 @@
1
+package com.armstrongconsulting.acprotasks;
2
+
3
+import java.util.Date;
4
+
5
+import javax.swing.*;
6
+
7
+import org.jetbrains.annotations.NotNull;
8
+import org.jetbrains.annotations.Nullable;
9
+
10
+import com.intellij.tasks.Comment;
11
+import com.intellij.tasks.Task;
12
+import com.intellij.tasks.TaskType;
13
+
14
+import icons.TasksIcons;
15
+
16
+public class AcproTask extends Task
17
+{
18
+    @Override
19
+    public @NotNull String getId()
20
+    {
21
+        return "ID 123";
22
+    }
23
+
24
+    @Override
25
+    public @NotNull String getSummary()
26
+    {
27
+        return "A new a.c.pro task";
28
+    }
29
+
30
+    @Override
31
+    public @Nullable String getDescription()
32
+    {
33
+        return "a.c.pro task description";
34
+    }
35
+
36
+    @Override
37
+    public @NotNull Comment[] getComments()
38
+    {
39
+        return new Comment[0];
40
+    }
41
+
42
+    @Override
43
+    public @NotNull Icon getIcon()
44
+    {
45
+        return TasksIcons.Bug;
46
+    }
47
+
48
+    @Override
49
+    public @NotNull TaskType getType()
50
+    {
51
+        return TaskType.BUG;
52
+    }
53
+
54
+    @Override
55
+    public @Nullable Date getUpdated()
56
+    {
57
+        return null;
58
+    }
59
+
60
+    @Override
61
+    public @Nullable Date getCreated()
62
+    {
63
+        return null;
64
+    }
65
+
66
+    @Override
67
+    public boolean isClosed()
68
+    {
69
+        return false;
70
+    }
71
+
72
+    @Override
73
+    public boolean isIssue()
74
+    {
75
+        return false;
76
+    }
77
+
78
+    @Override
79
+    public @Nullable String getIssueUrl()
80
+    {
81
+        return null;
82
+    }
83
+}

+ 1 - 3
src/main/resources/META-INF/plugin.xml

@@ -1,9 +1,7 @@
1 1
 <idea-plugin>
2 2
   <id>com.armstrongconsulting.AcproTasks</id>
3 3
   <name>a.c.pro Tasks</name>
4
-  <vendor email="matthias@armstrongconsulting.net" url="http://www.armstrongconsulting.com">Armstrong Consulting
5
-    Services GmbH
6
-  </vendor>
4
+  <vendor email="matthias@armstrongconsulting.net" url="http://www.armstrongconsulting.com">Armstrong Consulting Services GmbH</vendor>
7 5
 
8 6
   <description><![CDATA[
9 7
     Integrates a.c.pro to the tasks api and allows to search for a.c.pro items.

BIN
src/main/resources/img/ac-logo-16.png