Skip to content

Commit 7d43c4b

Browse files
author
saharmehrpour
committed
relevant rules are only shown, minor bugs are fixed.
1 parent 6353e97 commit 7d43c4b

19 files changed

Lines changed: 1125 additions & 1039 deletions

.idea/workspace.xml

Lines changed: 288 additions & 338 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
272 Bytes
Binary file not shown.
153 Bytes
Binary file not shown.
110 Bytes
Binary file not shown.

src/FileChangeManager.java

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,11 @@ private void setRules(String rules) {
5959
s.sendToAll(MessageProcessor.encodeData(new Object[]{"IDEA", "WEB", "VERIFY_RULES", ""}).toString());
6060
}
6161

62-
private void updateSrcml() {
63-
//public void setSrcml(SRCMLxml srcml) {
64-
//this.srcml = srcml;
65-
//s.sendToAll(MessageProcessor.encodeData(new Object[]{"IDEA", "WEB", "XML", srcml.xml}).toString());
66-
//s.sendToAll(MessageProcessor.encodeData(new Object[]{"IDEA", "WEB", "UPDATE_RULE_TABLE_AND_CONTAINER", this.getRules()}).toString());
67-
//s.sendToAll(MessageProcessor.encodeData(new Object[]{"IDEA", "WEB", "VERIFY_RULES", ""}).toString());
68-
s.sendToAll(MessageProcessor.encodeData(new Object[]{"IDEA", "WEB", "CHECK_RULES", ""}).toString());
62+
private void updateSrcml(String filePath, String newXml) {
63+
s.sendToAll(MessageProcessor.encodeData(new Object[]{"IDEA", "WEB", "UPDATE_XML",
64+
MessageProcessor.encodeNewXMLData(new Object[]{filePath, newXml})
65+
}).toString());
66+
s.sendToAll(MessageProcessor.encodeData(new Object[]{"IDEA", "WEB", "CHECK_RULES", filePath}).toString());
6967
}
7068

7169
public void initComponent() {
@@ -215,10 +213,9 @@ private void handleVFileChangeEvent(VFileEvent event) {
215213
}
216214

217215
System.out.println("CHANGE");
218-
SRCMLHandler.updateXMLForProject(this.getSrcml(), file.getPath());
219-
this.updateSrcml();
216+
String newXml = SRCMLHandler.updateXMLForProject(this.getSrcml(), file.getPath());
217+
this.updateSrcml(file.getPath(), newXml);
220218

221-
//this.setSrcml(SRCMLHandler.updateXMLForProject(this.getSrcml(), file.getPath()));
222219
}
223220

224221
// when a file is created
@@ -238,8 +235,8 @@ private void handleVFileCreateEvent(VFileEvent event) {
238235
}
239236

240237
System.out.println("CREATE");
241-
SRCMLHandler.addXMLForProject(this.getSrcml(), file.getPath());
242-
this.updateSrcml();
238+
String newXml = SRCMLHandler.addXMLForProject(this.getSrcml(), file.getPath());
239+
this.updateSrcml(file.getPath(), newXml);
243240
//this.setSrcml(SRCMLHandler.addXMLForProject(this.getSrcml(), file.getPath()));
244241

245242
}
@@ -255,13 +252,9 @@ private void handleVFilePropertyChangeEvent(VFileEvent event) {
255252
for (String path : srcml.getPaths()) {
256253
if (!newPaths.contains(path)) {
257254

258-
// SRCMLxml newsrcML = SRCMLHandler.removeXMLForProject(srcml, path);
259-
// newsrcML = SRCMLHandler.addXMLForProject(newsrcML, file.getPath());
260-
// this.setSrcml(newsrcML);
261-
262255
SRCMLHandler.removeXMLForProject(srcml, path);
263-
SRCMLHandler.addXMLForProject(srcml, file.getPath());
264-
this.updateSrcml();
256+
String newXml = SRCMLHandler.addXMLForProject(srcml, file.getPath());
257+
this.updateSrcml(file.getPath(), newXml);
265258
break;
266259
}
267260
}
@@ -279,10 +272,9 @@ private void handleVFileDeleteEvent(VFileEvent event) {
279272
}
280273

281274
System.out.println("DELETE");
282-
//this.setSrcml(SRCMLHandler.removeXMLForProject(this.getSrcml(), file.getPath()));
283275

284276
SRCMLHandler.removeXMLForProject(srcml, file.getPath());
285-
this.updateSrcml();
277+
this.updateSrcml(file.getPath(), "");
286278

287279
}
288280

src/MessageProcessor.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ public class MessageProcessor {
99

1010
private static final String[] dataKeys = {"source", "destination", "command", "data"};
1111
private static final String[] xmlKeys = {"filePath", "xml"};
12+
private static final String[] newXmlKeys = {"filePath", "xml"};
1213

1314
static JsonObject encodeData(Object[] source_Destination_Protocol_Data_Array) {
1415
return createJsonObject(source_Destination_Protocol_Data_Array, dataKeys);
@@ -18,6 +19,10 @@ static JsonObject encodeXMLData(Object[] filepath_xml_Array) {
1819
return createJsonObject(filepath_xml_Array, xmlKeys);
1920
}
2021

22+
static JsonObject encodeNewXMLData(Object[] filepath_newXml) {
23+
return createJsonObject(filepath_newXml, newXmlKeys);
24+
}
25+
2126
private static JsonObject createJsonObject(Object[] data_Array, String[] keys) {
2227
JsonObject jsonObject = new JsonObject();
2328
for (int i = 0; i < keys.length; i++) {

src/core/model/SRCMLHandler.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,17 @@ public static void createXMLForProject(SRCMLxml srcml) {
3333
*
3434
* @param srcml object
3535
* @param filePath of the modified file
36-
// * @return srcml
36+
* @return String new xml
3737
*/
38-
public static void/*SRCMLxml*/ updateXMLForProject(SRCMLxml srcml, String filePath) {
38+
public static String updateXMLForProject(SRCMLxml srcml, String filePath) {
3939

4040
for (int index = 0; index < srcml.fileNumber; index++) {
41-
if (srcml.paths.get(index).equals(filePath))
41+
if (srcml.paths.get(index).equals(filePath)) {
4242
srcml.xmls.set(index, createXMLForFile(srcml.paths.get(index)));
43+
return srcml.xmls.get(index);
44+
}
4345
}
44-
// srcml.attachXmls();
45-
// return srcml;
46+
return "";
4647
}
4748

4849

@@ -71,12 +72,12 @@ public static void createXMLForProject(SRCMLxml srcml) {
7172
* @param srcml
7273
* @param filePath
7374
*/
74-
public static void/*SRCMLxml*/ addXMLForProject(SRCMLxml srcml, String filePath) {
75+
public static String addXMLForProject(SRCMLxml srcml, String filePath) {
7576
srcml.paths.add(filePath);
76-
srcml.xmls.add(createXMLForFile(filePath));
77+
String newXml = createXMLForFile(filePath);
78+
srcml.xmls.add(newXml);
7779
srcml.fileNumber += 1;
78-
// srcml.attachXmls();
79-
// return srcml;
80+
return newXml;
8081
}
8182

8283

website-client/chat.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@
4040

4141
<div id="tableOfContent" class="main">
4242
<div class="container">
43-
<div style="border-bottom: 1px solid #ddd;">
44-
<h4>Rules</h4>
45-
</div>
46-
<ul id="rules_list"></ul>
4743
<div style="border-bottom: 1px solid #ddd;">
4844
<h4>Tags</h4>
4945
</div>
5046
<ul id="tags_list"></ul>
47+
<div style="border-bottom: 1px solid #ddd;">
48+
<h4>Rules</h4>
49+
</div>
50+
<ul id="rules_list"></ul>
5151
</div>
5252
</div>
5353

0 commit comments

Comments
 (0)