Skip to content

Commit 6252b1f

Browse files
UI/UX Improvements (#100)
* Object log added, pull action added, feature improvements * icons changed * Object log added for clone action * User/Password fix for UI * Message text added, code refactoring * general cleanup before merge * Codacy check fixes Nr.1
1 parent c5501b1 commit 6252b1f

18 files changed

+1004
-105
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package org.abapgit.adt.backend;
2+
3+
import java.util.List;
4+
5+
public interface IObject {
6+
7+
public String getObjType();
8+
9+
public String getObjName();
10+
11+
public String getObjStatus();
12+
13+
public String getPackage();
14+
15+
public String getMsgType();
16+
17+
public String getMsgText();
18+
19+
public List<IObject> listMessages();
20+
21+
public Object getMsgParent();
22+
23+
public void setObjType(String type);
24+
25+
public void setObjName(String name);
26+
27+
public void setObjStatus(String status);
28+
29+
public void setPackage(String pckg);
30+
31+
public void setMsgType(String msg_type);
32+
33+
public void setMsgText(String msg_text);
34+
35+
public void addChild(IObject abapLogObject);
36+
37+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package org.abapgit.adt.backend;
2+
3+
import java.util.List;
4+
5+
public interface IObjects {
6+
List<IObject> getObjects();
7+
}

org.abapgit.adt.backend/src/org/abapgit/adt/backend/IRepositoryService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ public interface IRepositoryService {
88

99
IRepositories getRepositories(IProgressMonitor monitor);
1010

11-
void cloneRepository(String url, String branch, String targetPackage, String transportRequest, String user,
11+
IObjects cloneRepository(String url, String branch, String targetPackage, String transportRequest, String user,
1212
String password, IProgressMonitor monitor);
1313

1414
void unlinkRepository(String key, IProgressMonitor monitor);
1515

16-
void pullRepository(IRepository existingRepository, String branch, String transportRequest, String user, String password,
16+
IObjects pullRepository(IRepository existingRepository, String branch, String transportRequest, String user, String password,
1717
IProgressMonitor monitor);
1818

1919
}
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
package org.abapgit.adt.backend.internal;
2+
3+
//import java.net.URI;
4+
import java.util.ArrayList;
5+
//import java.util.HashMap;
6+
import java.util.List;
7+
//import java.util.Map;
8+
9+
import org.abapgit.adt.backend.IObject;
10+
11+
public class AbapObject implements IObject {
12+
13+
private String type;
14+
private String name;
15+
private String status;
16+
private String pckg;
17+
private String msg_type;
18+
private String msg_text;
19+
// private final Map<String, URI> links = new HashMap<>();
20+
21+
private final List<IObject> abapLogObjectChildren = new ArrayList<IObject>();
22+
23+
@Override
24+
public void addChild(IObject abapLogObject) {
25+
this.abapLogObjectChildren.add(abapLogObject);
26+
}
27+
28+
@Override
29+
public String getObjType() {
30+
return this.type;
31+
}
32+
33+
@Override
34+
public String getObjName() {
35+
return this.name;
36+
}
37+
38+
@Override
39+
public String getObjStatus() {
40+
return this.status;
41+
}
42+
43+
@Override
44+
public String getPackage() {
45+
return this.pckg;
46+
}
47+
48+
@Override
49+
public String getMsgType() {
50+
return this.msg_type;
51+
}
52+
53+
@Override
54+
public String getMsgText() {
55+
return this.msg_text;
56+
}
57+
58+
@Override
59+
public void setObjType(String type) {
60+
this.type = type;
61+
}
62+
63+
@Override
64+
public void setObjName(String name) {
65+
this.name = name;
66+
}
67+
68+
@Override
69+
public void setObjStatus(String status) {
70+
this.status = status;
71+
}
72+
73+
@Override
74+
public void setPackage(String pckg) {
75+
this.pckg = pckg;
76+
}
77+
78+
@Override
79+
public void setMsgType(String msg_type) {
80+
this.msg_type = msg_type;
81+
}
82+
83+
84+
@Override
85+
public void setMsgText(String msg_text) {
86+
this.msg_text = msg_text;
87+
}
88+
89+
@Override
90+
public List<IObject> listMessages() {
91+
return this.abapLogObjectChildren;
92+
}
93+
94+
@Override
95+
public Object getMsgParent() {
96+
// TODO Auto-generated method stub
97+
return null;
98+
}
99+
100+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package org.abapgit.adt.backend.internal;
2+
3+
import java.io.IOException;
4+
import java.nio.charset.Charset;
5+
6+
import javax.xml.stream.XMLInputFactory;
7+
import javax.xml.stream.XMLStreamException;
8+
import javax.xml.stream.XMLStreamReader;
9+
10+
import org.abapgit.adt.backend.IObjects;
11+
12+
import com.sap.adt.communication.content.ContentHandlerException;
13+
import com.sap.adt.communication.content.IContentHandler;
14+
import com.sap.adt.communication.message.IMessageBody;
15+
16+
public class AbapObjectContentHandlerV1 implements IContentHandler<IObjects> {
17+
private static final String CONTENT_TYPE_V1 = "application/abapgit.adt.repo.object.v1+xml"; //$NON-NLS-1$
18+
19+
@Override
20+
public IObjects deserialize(IMessageBody body, Class<? extends IObjects> dataType) {
21+
try {
22+
XMLInputFactory xmlInputFactory = XMLInputFactory.newInstance();
23+
XMLStreamReader xmlStreamReader = xmlInputFactory.createXMLStreamReader(body.getContent());
24+
return new AbapObjectsSerializer().deserializeAbapObjects(xmlStreamReader, getSupportedContentType());
25+
} catch (IOException | XMLStreamException e) {
26+
throw new ContentHandlerException("Error parsing repositories", e); //$NON-NLS-1$
27+
}
28+
}
29+
30+
@Override
31+
public String getSupportedContentType() {
32+
return CONTENT_TYPE_V1;
33+
}
34+
35+
@Override
36+
public Class<IObjects> getSupportedDataType() {
37+
return IObjects.class;
38+
}
39+
40+
@Override
41+
public IMessageBody serialize(IObjects arg0, Charset arg1) {
42+
return null;
43+
}
44+
45+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
package org.abapgit.adt.backend.internal;
2+
3+
import javax.xml.stream.XMLStreamConstants;
4+
import javax.xml.stream.XMLStreamException;
5+
import javax.xml.stream.XMLStreamReader;
6+
7+
import org.abapgit.adt.backend.IObject;
8+
9+
public class AbapObjectSerializer {
10+
public IObject deserializeAbapObject(XMLStreamReader xmlReader, String contentType) throws XMLStreamException {
11+
IObject object = new AbapObject();
12+
IObject object_msg = new AbapObject();
13+
boolean message_exists = false;
14+
15+
int depth = 0;
16+
loop: while (xmlReader.hasNext()) {
17+
int next = xmlReader.next();
18+
switch (next) {
19+
case XMLStreamConstants.START_ELEMENT:
20+
switch (xmlReader.getLocalName()) {
21+
case "obj_type": //$NON-NLS-1$
22+
object.setObjType(xmlReader.getElementText());
23+
object_msg.setObjType("Message"); //$NON-NLS-1$
24+
message_exists = false;
25+
break;
26+
case "obj_name": //$NON-NLS-1$
27+
object.setObjName(xmlReader.getElementText());
28+
break;
29+
case "obj_status": //$NON-NLS-1$
30+
object.setObjStatus(xmlReader.getElementText());
31+
break;
32+
case "package": //$NON-NLS-1$
33+
object.setPackage(xmlReader.getElementText());
34+
break;
35+
case "msg_type": //$NON-NLS-1$
36+
// object.setMsgType(xmlReader.getElementText());
37+
object_msg.setMsgType(xmlReader.getElementText());
38+
message_exists = true;
39+
break;
40+
case "msg_text": //$NON-NLS-1$
41+
// object.setMsgText(xmlReader.getElementText());
42+
object_msg.setMsgText(xmlReader.getElementText());
43+
if (message_exists) {
44+
object.addChild(object_msg);
45+
}
46+
break;
47+
default:
48+
depth++;
49+
break;
50+
}
51+
break;
52+
case XMLStreamConstants.END_ELEMENT:
53+
if (depth == 0) {
54+
break loop;
55+
}
56+
depth--;
57+
break;
58+
default:
59+
break;
60+
}
61+
}
62+
63+
return object;
64+
}
65+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package org.abapgit.adt.backend.internal;
2+
3+
import java.util.Collections;
4+
import java.util.LinkedList;
5+
import java.util.List;
6+
7+
import org.abapgit.adt.backend.IObject;
8+
import org.abapgit.adt.backend.IObjects;
9+
10+
public class AbapObjects implements IObjects {
11+
12+
private final List<IObject> objects = new LinkedList<>();
13+
14+
public void addList(List<IObject> objects) {
15+
this.objects.addAll(objects);
16+
}
17+
18+
@Override
19+
public List<IObject> getObjects() {
20+
return Collections.unmodifiableList(this.objects);
21+
}
22+
23+
public void add(IObject object) {
24+
this.objects.add(object);
25+
}
26+
27+
@Override
28+
public String toString() {
29+
StringBuilder builder = new StringBuilder();
30+
builder.append("Objects [objects="); //$NON-NLS-1$
31+
builder.append(this.objects);
32+
builder.append("]"); //$NON-NLS-1$
33+
return builder.toString();
34+
}
35+
36+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package org.abapgit.adt.backend.internal;
2+
3+
import javax.xml.stream.XMLStreamConstants;
4+
import javax.xml.stream.XMLStreamException;
5+
import javax.xml.stream.XMLStreamReader;
6+
7+
import org.abapgit.adt.backend.IObjects;
8+
9+
public class AbapObjectsSerializer {
10+
public IObjects deserializeAbapObjects(XMLStreamReader xmlReader, String contentType) throws XMLStreamException {
11+
AbapObjects objects = new AbapObjects();
12+
13+
while (xmlReader.hasNext()) {
14+
int next = xmlReader.next();
15+
switch (next) {
16+
case XMLStreamConstants.START_ELEMENT:
17+
switch (xmlReader.getLocalName()) {
18+
case "object": //$NON-NLS-1$
19+
objects.add(new AbapObjectSerializer().deserializeAbapObject(xmlReader, contentType));
20+
break;
21+
default:
22+
break;
23+
}
24+
break;
25+
default:
26+
break;
27+
}
28+
}
29+
30+
return objects;
31+
}
32+
}

org.abapgit.adt.backend/src/org/abapgit/adt/backend/internal/RepositorySerializer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public IRepository deserializeRepository(XMLStreamReader xmlReader, String conte
4040
repository.setPackage(xmlReader.getElementText());
4141
break;
4242
case "link": //$NON-NLS-1$
43-
repository.addLink(xmlReader.getAttributeValue(null, "rel"), URI.create(xmlReader.getAttributeValue(null, "href")));
43+
repository.addLink(xmlReader.getAttributeValue(null, "rel"), URI.create(xmlReader.getAttributeValue(null, "href"))); //$NON-NLS-1$ //$NON-NLS-2$
4444
break;
4545
default:
4646
depth++;

0 commit comments

Comments
 (0)