-
Notifications
You must be signed in to change notification settings - Fork 3
Gh362 comment icon propagation #445
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
elena-posea
wants to merge
20
commits into
master
Choose a base branch
from
GH362-comment-icon-propagation
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
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 f35b3a3
#362 - finished propagation + icon (provider and setter), started to
elena-posea aa7b65f
#362 - solved bugs + changed CodeSyncPropertySetter to extend
elena-posea 91598d6
Merge remote-tracking branch 'origin/master' into
elena-posea 15cdf35
#362 - tests for SYNC and CONTAINS_COMMENT flag propagation
elena-posea 2aa7453
#362 - renamed codesync test files and cretaed function for ssubscribing
elena-posea ba0790f
Merge branch 'master' into GH362-comment-icon-propagation
elena-posea 2f78c02
Merge remote-tracking branch 'origin/master' into
elena-posea a865fb9
#36 - solved merge problems; now both custom flags and codesync flag
elena-posea c01cce9
Merge remote-tracking branch 'origin/master' into
elena-posea 63adede
#362 - solved minor bugs due to merge
elena-posea a911fad
#362 - removed class CodeSyncControllerUtils
elena-posea b161afb
#362 - added @author to my classes/methods
elena-posea 87c102f
#362 - solved review problems
elena-posea f22583d
Merge remote-tracking branch 'origin/master' into
elena-posea c5cb498
#362 - changed some doc messages
elena-posea d950226
Merge remote-tracking branch 'origin/master' into
elena-posea 3c4d8e5
Merge remote-tracking branch 'origin/GH362-comment-icon-propagation' …
elena-posea 482367c
Merge remote-tracking branch 'origin/master' into
elena-posea cea2a8f
#362 - merge with master complete
elena-posea File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| /bin | ||
| /bin | ||
| /bin | ||
| /bin | ||
| /bin | ||
| /bin | ||
| /bin | ||
| /bin |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
...ff/src/org/flowerplatform/codesync/sdiff/controller/CanContainCommentAddNodeListener.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 { | ||
|
|
||
| @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())); | ||
| } | ||
| } | ||
| } | ||
103 changes: 103 additions & 0 deletions
103
...f/src/org/flowerplatform/codesync/sdiff/controller/CanContainCommentPropertyProvider.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | ||
| } | ||
| } | ||
|
|
||
| } |
22 changes: 22 additions & 0 deletions
22
...src/org/flowerplatform/codesync/sdiff/controller/CanContainCommentRemoveNodeListener.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | ||
| } | ||
|
|
||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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