Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
afa3ed0
#362 - Propagate message child flag (+icon) to parents
elena-posea Jul 29, 2014
f35b3a3
#362 - finished propagation + icon (provider and setter), started to
elena-posea Jul 30, 2014
aa7b65f
#362 - solved bugs + changed CodeSyncPropertySetter to extend
elena-posea Jul 31, 2014
91598d6
Merge remote-tracking branch 'origin/master' into
elena-posea Jul 31, 2014
15cdf35
#362 - tests for SYNC and CONTAINS_COMMENT flag propagation
elena-posea Aug 5, 2014
2aa7453
#362 - renamed codesync test files and cretaed function for ssubscribing
elena-posea Aug 5, 2014
ba0790f
Merge branch 'master' into GH362-comment-icon-propagation
elena-posea Aug 5, 2014
2f78c02
Merge remote-tracking branch 'origin/master' into
elena-posea Aug 5, 2014
a865fb9
#36 - solved merge problems; now both custom flags and codesync flag
elena-posea Aug 6, 2014
c01cce9
Merge remote-tracking branch 'origin/master' into
elena-posea Aug 7, 2014
63adede
#362 - solved minor bugs due to merge
elena-posea Aug 7, 2014
a911fad
#362 - removed class CodeSyncControllerUtils
elena-posea Aug 7, 2014
b161afb
#362 - added @author to my classes/methods
elena-posea Aug 7, 2014
87c102f
#362 - solved review problems
elena-posea Aug 26, 2014
f22583d
Merge remote-tracking branch 'origin/master' into
elena-posea Aug 26, 2014
c5cb498
#362 - changed some doc messages
elena-posea Aug 26, 2014
d950226
Merge remote-tracking branch 'origin/master' into
elena-posea Aug 26, 2014
3c4d8e5
Merge remote-tracking branch 'origin/GH362-comment-icon-propagation' …
elena-posea Aug 26, 2014
482367c
Merge remote-tracking branch 'origin/master' into
elena-posea Sep 9, 2014
cea2a8f
#362 - merge with master complete
elena-posea Sep 9, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import static org.eclipse.jdt.core.dom.Modifier.isSynchronized;
import static org.eclipse.jdt.core.dom.Modifier.isTransient;
import static org.eclipse.jdt.core.dom.Modifier.isVolatile;
import static org.flowerplatform.codesync.CodeSyncConstants.REMOVED;
import static org.flowerplatform.codesync.code.java.CodeSyncJavaConstants.DECORATOR_ABSTRACT;
import static org.flowerplatform.codesync.code.java.CodeSyncJavaConstants.DECORATOR_FINAL;
import static org.flowerplatform.codesync.code.java.CodeSyncJavaConstants.DECORATOR_NATIVE;
Expand All @@ -44,7 +45,6 @@
import org.eclipse.jdt.core.dom.Modifier.ModifierKeyword;
import org.flowerplatform.codesync.code.java.CodeSyncJavaConstants;
import org.flowerplatform.codesync.code.java.CodeSyncJavaPlugin;
import org.flowerplatform.codesync.controller.CodeSyncControllerUtils;
import org.flowerplatform.core.CoreConstants;
import org.flowerplatform.core.node.NodeService;
import org.flowerplatform.core.node.controller.ConstantValuePropertyProvider;
Expand Down Expand Up @@ -118,7 +118,7 @@ private String append(String icon, String decorator) {
protected int getModifiersFlags(Node node, ServiceContext<NodeService> context) {
int flags = 0;
for (Node modifier : getModifiers(node, context)) {
if (CodeSyncControllerUtils.isRemoved(modifier)) {
if (isRemoved(modifier)) {
// don't decorate if the modifier was marked removed
continue;
}
Expand All @@ -141,6 +141,15 @@ protected List<Node> getModifiers(Node node, ServiceContext<NodeService> context
return modifiers;
}

public boolean isRemoved(Node node) {
return hasFlagTrue(node, REMOVED);
}

private boolean hasFlagTrue(Node node, String flag) {
Boolean b = (Boolean) node.getPropertyValue(flag);
return b != null && b;
}

protected String getVisibilityPrivate() {
return getIconWithVisibility(VISIBILITY_PRIVATE);
}
Expand Down
8 changes: 4 additions & 4 deletions org.flowerplatform.codesync.regex/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/bin
/bin
/bin
/bin
/bin
/bin
/bin
/bin
24 changes: 12 additions & 12 deletions org.flowerplatform.codesync.regex/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Regex
Bundle-SymbolicName: org.flowerplatform.codesync.regex;singleton:=true
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Bundle-Version: 0.1.1.qualifier
Require-Bundle: org.eclipse.osgi,
org.flowerplatform.core,
org.flowerplatform.resources,
org.flowerplatform.util
Bundle-ActivationPolicy: lazy
Bundle-Activator: org.flowerplatform.codesync.regex.CodeSyncRegexPlugin
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Regex
Bundle-SymbolicName: org.flowerplatform.codesync.regex;singleton:=true
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Bundle-Version: 0.1.1.qualifier
Require-Bundle: org.eclipse.osgi,
org.flowerplatform.core,
org.flowerplatform.resources,
org.flowerplatform.util
Bundle-ActivationPolicy: lazy
Bundle-Activator: org.flowerplatform.codesync.regex.CodeSyncRegexPlugin
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
package org.flowerplatform.codesync.sdiff;

import org.flowerplatform.util.UtilConstants;

public class CodeSyncSdiffConstants {

//////////////////////////////////
Expand All @@ -33,6 +35,8 @@ public class CodeSyncSdiffConstants {
public static final String MODIFIED_BODY = "bodyModified";
public static final String MODIFIED_CHILDREN = "childrenModified";
public static final String ADDED_COMMENT = "comment";
public static final String CONTAINS_COMMENT = "containsComment";
public static final String CATEGORY_CAN_CONTAIN_COMMENT = UtilConstants.CATEGORY_PREFIX + "canContainComment";

// relative to repository
public static final String STRUCTURE_DIFFS_FOLDER = "sdiffs";
Expand All @@ -48,10 +52,24 @@ public class CodeSyncSdiffConstants {
public static final String MATCH_COLOR_CHILDREN_MODIFIED = "#FFCC00";
public static final String MATCH_COLOR_COMMENT = "#FFFF00";

// dirty marker for comments
public static final String NODE_URI_TO_BE_IGNORED = "nodeURIToBeIgnored";

// flag so CanContainCommentPropertyProvider won't loop while trying to set CODESYNC_ICONS property
public static final String ALREADY_BEEN_IN_THIS_SETTER = "alreadyBeenInThisSetter";


//////////////////////////////////
// Service context options
//////////////////////////////////

public static final String SKIP_MATCH_CHILDREN_PROVIDER = "skipMatchChildrenProvider";

/////////////////////////////////
// Images
////////////////////////////////

public static final String IMG_TYPE_COMMENTS = "comments.png";
public static final String IMG_TYPE_COMMENT = "comment.png";

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,25 @@
*/
package org.flowerplatform.codesync.sdiff;

import static org.flowerplatform.codesync.CodeSyncConstants.CATEGORY_CAN_HOLD_CUSTOM_ICON;
import static org.flowerplatform.codesync.CodeSyncConstants.MATCH;
import static org.flowerplatform.codesync.sdiff.CodeSyncSdiffConstants.CATEGORY_CAN_CONTAIN_COMMENT;
import static org.flowerplatform.codesync.sdiff.CodeSyncSdiffConstants.COMMENT;
import static org.flowerplatform.codesync.sdiff.CodeSyncSdiffConstants.STRUCTURE_DIFF;
import static org.flowerplatform.codesync.sdiff.CodeSyncSdiffConstants.STRUCTURE_DIFF_EXTENSION;
import static org.flowerplatform.codesync.sdiff.CodeSyncSdiffConstants.STRUCTURE_DIFF_LEGEND;
import static org.flowerplatform.codesync.sdiff.CodeSyncSdiffConstants.STRUCTURE_DIFF_LEGEND_CHILD;
import static org.flowerplatform.core.CoreConstants.ADD_CHILD_DESCRIPTOR;
import static org.flowerplatform.core.CoreConstants.ADD_NODE_CONTROLLER;
import static org.flowerplatform.core.CoreConstants.CHILDREN_PROVIDER;
import static org.flowerplatform.core.CoreConstants.FILE_NODE_TYPE;
import static org.flowerplatform.core.CoreConstants.PROPERTIES_PROVIDER;
import static org.flowerplatform.core.CoreConstants.PROPERTY_FOR_TITLE_DESCRIPTOR;
import static org.flowerplatform.core.CoreConstants.PROPERTY_SETTER;
import static org.flowerplatform.mindmap.MindMapConstants.TEXT;
import static org.flowerplatform.core.CoreConstants.REMOVE_NODE_CONTROLLER;

import org.flowerplatform.codesync.sdiff.controller.CanContainCommentAddNodeListener;
import org.flowerplatform.codesync.sdiff.controller.CanContainCommentPropertyProvider;
import org.flowerplatform.codesync.sdiff.controller.CanContainCommentRemoveNodeListener;
import org.flowerplatform.codesync.sdiff.controller.StructureDiffCommentController;
import org.flowerplatform.codesync.sdiff.controller.StructureDiffLegendChildrenPropertiesProvider;
import org.flowerplatform.codesync.sdiff.controller.StructureDiffLegendController;
Expand All @@ -38,7 +43,7 @@
import org.flowerplatform.core.CorePlugin;
import org.flowerplatform.core.file.FileSubscribableProvider;
import org.flowerplatform.core.node.remote.AddChildDescriptor;
import org.flowerplatform.core.node.remote.GenericValueDescriptor;
import org.flowerplatform.resources.ResourcesPlugin;
import org.flowerplatform.util.plugin.AbstractFlowerJavaPlugin;
import org.osgi.framework.BundleContext;

Expand All @@ -48,26 +53,26 @@
public class CodeSyncSdiffPlugin extends AbstractFlowerJavaPlugin {

protected static CodeSyncSdiffPlugin INSTANCE;

private StructureDiffService sDiffService = new StructureDiffService();

public static CodeSyncSdiffPlugin getInstance() {
return INSTANCE;
}

public StructureDiffService getSDiffService() {
return sDiffService;
}

public void start(BundleContext bundleContext) throws Exception {
super.start(bundleContext);
INSTANCE = this;

CorePlugin.getInstance().getServiceRegistry().registerService("structureDiffService", sDiffService);

CorePlugin.getInstance().getNodeTypeDescriptorRegistry().getOrCreateTypeDescriptor(STRUCTURE_DIFF_LEGEND_CHILD)
.addAdditiveController(PROPERTIES_PROVIDER, new StructureDiffLegendChildrenPropertiesProvider());

CorePlugin.getInstance().getNodeTypeDescriptorRegistry().getOrCreateTypeDescriptor(STRUCTURE_DIFF_LEGEND)
.addAdditiveController(PROPERTIES_PROVIDER, new StructureDiffLegendController())
.addAdditiveController(CHILDREN_PROVIDER, new StructureDiffLegendController());
Expand All @@ -76,24 +81,38 @@ public void start(BundleContext bundleContext) throws Exception {
CorePlugin.getInstance().getVirtualNodeResourceHandler().addVirtualNodeType(STRUCTURE_DIFF_LEGEND);

CorePlugin.getInstance().getNodeTypeDescriptorRegistry().getOrCreateTypeDescriptor(STRUCTURE_DIFF)
.addAdditiveController(CHILDREN_PROVIDER, new StructureDiffNodeLegendController());
.addAdditiveController(CHILDREN_PROVIDER, new StructureDiffNodeLegendController())
.addCategory(CATEGORY_CAN_CONTAIN_COMMENT);

CorePlugin.getInstance().getNodeTypeDescriptorRegistry().getOrCreateTypeDescriptor(FILE_NODE_TYPE)
.addAdditiveController(PROPERTIES_PROVIDER, new FileSubscribableProvider(STRUCTURE_DIFF_EXTENSION, "fpp", "mindmap", true));

StructureDiffMatchPropertiesProvider structureDiffMatchPropertiesController = new StructureDiffMatchPropertiesProvider();

CorePlugin.getInstance().getNodeTypeDescriptorRegistry().getOrCreateTypeDescriptor(MATCH)
.addAdditiveController(PROPERTIES_PROVIDER, structureDiffMatchPropertiesController)
.addAdditiveController(PROPERTY_SETTER, structureDiffMatchPropertiesController)
.addAdditiveController(CHILDREN_PROVIDER, new StructureDiffMatchChildrenProvider())
.addAdditiveController(ADD_CHILD_DESCRIPTOR, new AddChildDescriptor().setChildTypeAs(COMMENT))
.addSingleController(PROPERTY_FOR_TITLE_DESCRIPTOR, new GenericValueDescriptor(TEXT).setOrderIndexAs(-10000));

.addAdditiveController(ADD_CHILD_DESCRIPTOR, new AddChildDescriptor().setChildTypeAs(COMMENT).setLabelAs(ResourcesPlugin.getInstance().getMessage("codesync.sdiff.newlyAddedElement")))
.addCategory(CATEGORY_CAN_CONTAIN_COMMENT);

StructureDiffCommentController commentController = (StructureDiffCommentController) new StructureDiffCommentController().setOrderIndexAs(5000);
CorePlugin.getInstance().getNodeTypeDescriptorRegistry().getOrCreateTypeDescriptor(COMMENT)
.addAdditiveController(PROPERTIES_PROVIDER, new StructureDiffCommentController());
.addAdditiveController(PROPERTIES_PROVIDER, commentController)
.addAdditiveController(PROPERTY_SETTER, commentController)
.addCategory(CATEGORY_CAN_CONTAIN_COMMENT)
.addCategory(CATEGORY_CAN_HOLD_CUSTOM_ICON);

CanContainCommentPropertyProvider commentPropertyProvider = new CanContainCommentPropertyProvider();
CorePlugin.getInstance().getNodeTypeDescriptorRegistry().getOrCreateCategoryTypeDescriptor(CATEGORY_CAN_CONTAIN_COMMENT)
.addAdditiveController(PROPERTIES_PROVIDER, commentPropertyProvider)
.addAdditiveController(PROPERTY_SETTER, commentPropertyProvider)
.addAdditiveController(ADD_NODE_CONTROLLER, new CanContainCommentAddNodeListener().setOrderIndexAs(10000))
.addAdditiveController(REMOVE_NODE_CONTROLLER, new CanContainCommentRemoveNodeListener().setOrderIndexAs(-10000))
.addAdditiveController(ADD_CHILD_DESCRIPTOR,
new AddChildDescriptor().setChildTypeAs(COMMENT).setLabelAs(ResourcesPlugin.getInstance().getMessage("codesync.sdiff.comment")));
}

public void stop(BundleContext bundleContext) throws Exception {
super.stop(bundleContext);
INSTANCE = null;
Expand All @@ -103,5 +122,9 @@ public void stop(BundleContext bundleContext) throws Exception {
public void registerMessageBundle() throws Exception {
// nothing to do yet
}

}

public String getImagePath(String img) {
return ResourcesPlugin.getInstance().getResourceUrl("/images/codesync.sdiff/comment-marker/" + img);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package org.flowerplatform.codesync.sdiff.controller;

import static org.flowerplatform.codesync.sdiff.CodeSyncSdiffConstants.COMMENT;
import static org.flowerplatform.codesync.sdiff.CodeSyncSdiffConstants.NODE_URI_TO_BE_IGNORED;

import org.flowerplatform.core.node.NodeService;
import org.flowerplatform.core.node.controller.IAddNodeController;
import org.flowerplatform.core.node.remote.Node;
import org.flowerplatform.core.node.remote.ServiceContext;

/**
* Whenever you add a new node of type comment, that new node has to be marked as dirty,
* and this flag has to be propagated to parents.
*
* @author Elena Posea
*/
public class CanContainCommentAddNodeListener extends ContainsCommentPropagator implements IAddNodeController {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add some doc: what does this class do? What is the order index?

Doc for the other classes as well.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DONE for: CanContainCommentAddNodeListener, CanContainCommentPropertyProvider, CanContainCommentRemoveNodeListener, ContainsCommentPropagator, DirtyPropagatorController


@Override
public void addNode(Node node, Node child, ServiceContext<NodeService> serviceContext) {
if (child.getType().equals(COMMENT)) {
setDirtyAndPropagateToParents(child, serviceContext.add(NODE_URI_TO_BE_IGNORED, child.getNodeUri()));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
package org.flowerplatform.codesync.sdiff.controller;

import static org.flowerplatform.codesync.sdiff.CodeSyncSdiffConstants.CONTAINS_COMMENT;
import static org.flowerplatform.codesync.sdiff.CodeSyncSdiffConstants.ALREADY_BEEN_IN_THIS_SETTER;
import static org.flowerplatform.codesync.sdiff.CodeSyncSdiffConstants.IMG_TYPE_COMMENTS;
import static org.flowerplatform.core.CoreConstants.CODESYNC_ICONS;
import static org.flowerplatform.core.CoreConstants.EXECUTE_ONLY_FOR_UPDATER;
import static org.flowerplatform.core.CoreConstants.DONT_PROCESS_OTHER_CONTROLLERS;

import java.util.regex.Matcher;

import org.flowerplatform.codesync.sdiff.CodeSyncSdiffPlugin;
import org.flowerplatform.core.CoreConstants;
import org.flowerplatform.core.node.NodeService;
import org.flowerplatform.core.node.controller.IPropertiesProvider;
import org.flowerplatform.core.node.controller.IPropertySetter;
import org.flowerplatform.core.node.remote.Node;
import org.flowerplatform.core.node.remote.ServiceContext;
import org.flowerplatform.util.controller.AbstractController;

/**
* @author Elena Posea
*/
public class CanContainCommentPropertyProvider extends AbstractController implements IPropertySetter, IPropertiesProvider {

/**
* Order index has to be higher than CanContainCommentAddNodeListener's
* order index. First add the node, then set/provide properties.
* Order index must also be higher than StructureDiffMatchPropertiesProvider's order index.
* For nodes of type Match, you should first invoke StructureDifffMatchPropertiesProvider,
* then this provider. It should also be higher than StructureDiffCommentController.
*/
public CanContainCommentPropertyProvider() {
setOrderIndex(11000);
}

@Override
public void populateWithProperties(Node node, ServiceContext<NodeService> context) {
node.getProperties().put(CODESYNC_ICONS, getCodeSyncIcon(node, context));
}

@Override
public void setProperty(Node node, String property, Object value, ServiceContext<NodeService> context) {
if (context.get(ALREADY_BEEN_IN_THIS_SETTER) != null)
return;
if ((property.equals(CONTAINS_COMMENT) && (Boolean) value == true)) {
ServiceContext<NodeService> newContext = new ServiceContext<NodeService>(context.getService());
newContext.getContext().put(EXECUTE_ONLY_FOR_UPDATER, true);
newContext.getContext().put(ALREADY_BEEN_IN_THIS_SETTER, true);
// here I set only the codesync icons, that are not to be persisted;
// in order not to cycle/infinitely recourse in this setProperty
// function, I use the ALREADY_BEEN_IN_THIS_SETTER flag, in context
context.getService().setProperty(node, CODESYNC_ICONS, getCodeSyncIcon(node, context), newContext);
} else {
if (property.equals(CODESYNC_ICONS)) {
ServiceContext<NodeService> newContext = new ServiceContext<NodeService>(context.getService());
// otherwise, the next controller for MATCH is
// CanContainCommentPropertyProvider + Updater (we don't want
// this)
context.getContext().put(DONT_PROCESS_OTHER_CONTROLLERS, true);
newContext.getContext().put(ALREADY_BEEN_IN_THIS_SETTER, true);
context.getService().setProperty(node, CODESYNC_ICONS, getCodeSyncIcon(node, context), newContext);
}
}
}

private String getCodeSyncIcon(Node node, ServiceContext<NodeService> context) {
Boolean containsCommentFlag = (Boolean) node.getProperties().get(CONTAINS_COMMENT);
Object codesyncListOfIcons = node.getProperties().get(CODESYNC_ICONS);
String icon = "";
if (codesyncListOfIcons != null) {
icon = (String) codesyncListOfIcons;
}
// icon = current icon list
String newIcon = CodeSyncSdiffPlugin.getInstance().getImagePath(IMG_TYPE_COMMENTS);
// newIcon = the icon that I would like to add
if (containsCommentFlag != null && containsCommentFlag == true) {
if (icon.indexOf(newIcon) == -1) { // this node doesn't already
// contain this icon
icon = icon + (!icon.isEmpty() ? CoreConstants.ICONS_SEPARATOR : "") + newIcon;
}
return icon;
} else {
// remove property
int index = icon.indexOf(newIcon);
if (index != -1) { // this node contains the icon; remove it
icon = icon.replaceAll(",?" + Matcher.quoteReplacement(newIcon), "");
}
return icon;
}
}

@Override
public void unsetProperty(Node node, String property, ServiceContext<NodeService> context) {
if (property.equals(CONTAINS_COMMENT)) {
ServiceContext<NodeService> newContext = new ServiceContext<NodeService>();
newContext.getContext().put(EXECUTE_ONLY_FOR_UPDATER, true);
newContext.getContext().put(ALREADY_BEEN_IN_THIS_SETTER, true);
context.getService().setProperty(node, CODESYNC_ICONS, getCodeSyncIcon(node, context), newContext);
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package org.flowerplatform.codesync.sdiff.controller;

import org.flowerplatform.core.node.NodeService;
import org.flowerplatform.core.node.controller.IRemoveNodeController;
import org.flowerplatform.core.node.remote.Node;
import org.flowerplatform.core.node.remote.ServiceContext;

/**
* After the removal of some node of type CanContainComment, attempt to clean/
* propagate clean (whether this was the last dirty child or not, is tested by
* unsetDirtyAndPropagateToParents() method itself)
*
* @author Elena Posea
*/
public class CanContainCommentRemoveNodeListener extends ContainsCommentPropagator implements IRemoveNodeController {

@Override
public void removeNode(Node node, Node child, ServiceContext<NodeService> serviceContext) {
unsetDirtyAndPropagateToParents(child, serviceContext);
}

}
Loading