use of org.eclipse.ecf.sync.IModelChangeMessage in project ecf by eclipse.
the class SyncResourcesCore method distributeChanges.
private void distributeChanges() {
for (Iterator it = resourceChanges.entrySet().iterator(); it.hasNext(); ) {
Entry entry = (Entry) it.next();
ResourcesShare share = (ResourcesShare) entry.getKey();
List changes = (List) entry.getValue();
List messages = new ArrayList();
for (int i = 0; i < changes.size(); i++) {
ResourceChangeMessage change = (ResourceChangeMessage) changes.get(i);
switch(change.getKind()) {
case IResourceDelta.ADDED:
if (getInt(PreferenceConstants.LOCAL_RESOURCE_ADDITION) == PreferenceConstants.IGNORE_VALUE) {
change.setIgnored(true);
continue;
}
break;
case IResourceDelta.CHANGED:
if (getInt(PreferenceConstants.LOCAL_RESOURCE_CHANGE) == PreferenceConstants.IGNORE_VALUE) {
change.setIgnored(true);
continue;
}
break;
case IResourceDelta.REMOVED:
if (getInt(PreferenceConstants.LOCAL_RESOURCE_DELETION) == PreferenceConstants.IGNORE_VALUE) {
change.setIgnored(true);
continue;
}
break;
}
IModelChangeMessage[] changeMessages = ResourcesSynchronizationStrategy.getInstance().registerLocalChange(change);
messages.addAll(Arrays.asList(changeMessages));
}
try {
if (!messages.isEmpty()) {
IModelChangeMessage[] messagesArray = (IModelChangeMessage[]) messages.toArray(new IModelChangeMessage[messages.size()]);
BatchModelChange batchChange = new BatchModelChange(messagesArray);
share.send(Message.serialize(batchChange));
add(batchChange);
}
} catch (ECFException e) {
getDefault().getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, "Could not send resource change message", // $NON-NLS-1$
e));
}
}
}
Aggregations