use of org.eclipse.ecf.sync.IModelChangeMessage in project ecf by eclipse.
the class Initiator method run.
public void run() {
for (int i = 0; i < 10; i++) {
String text = fDocument.get();
String newText = ">";
text = text.concat(newText);
fDocument.set(text);
IModelChange change = new DocumentChangeMessage(i + 150, newText.length(), newText);
IModelChangeMessage[] changes = initiator.registerLocalChange(change);
getReceiverQueue().put(changes);
}
}
use of org.eclipse.ecf.sync.IModelChangeMessage in project ecf by eclipse.
the class Message method deserialize.
/**
* Deserialize in to message
* @param bytes
* @return IModelChangeMessage
* @throws SerializationException
*/
public static IModelChangeMessage deserialize(byte[] bytes) throws SerializationException {
try {
final ByteArrayInputStream bins = new ByteArrayInputStream(bytes);
final ObjectInputStream oins = new ObjectInputStream(bins);
return (IModelChangeMessage) oins.readObject();
} catch (final Exception e) {
throw new SerializationException(Messages.DocShare_EXCEPTION_DESERIALIZING_MESSAGE0, e);
}
}
use of org.eclipse.ecf.sync.IModelChangeMessage in project ecf by eclipse.
the class ResourcesShare method sendResourceChangeMessage.
void sendResourceChangeMessage(IResource resource, int kind) {
try {
IModelChange change = ResourceChangeMessage.createResourceChange(resource, kind);
IModelChangeMessage[] messages = ResourcesSynchronizationStrategy.getInstance().registerLocalChange(change);
for (int i = 0; i < messages.length; i++) {
send(messages[i].serialize());
}
} catch (ECFException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
use of org.eclipse.ecf.sync.IModelChangeMessage in project ecf by eclipse.
the class DocShare method handleMessage.
protected void handleMessage(ID fromContainerID, byte[] data) {
try {
IModelChangeMessage message = Message.deserialize(data);
Assert.isNotNull(message);
if (message instanceof SelectionMessage) {
handleSelectionMessage((SelectionMessage) message);
} else if (message instanceof FileSystemDocumentChangeMessage) {
handleFileSystemDocumentChangeMessage((FileSystemDocumentChangeMessage) message);
} else if (message instanceof StartMessage) {
handleStartMessage((StartMessage) message);
} else if (message instanceof StopMessage) {
handleStopMessage((StopMessage) message);
}
} catch (SerializationException e) {
// $NON-NLS-1$
DocShareActivator.log(new Status(IStatus.ERROR, DocShareActivator.PLUGIN_ID, "Could not deserialize message from " + fromContainerID, e));
} catch (CoreException e) {
// $NON-NLS-1$
DocShareActivator.log(new Status(IStatus.ERROR, DocShareActivator.PLUGIN_ID, "Could not connect to file buffer", e));
} catch (RuntimeException e) {
// $NON-NLS-1$
DocShareActivator.log(new Status(IStatus.ERROR, DocShareActivator.PLUGIN_ID, "Runtime exception has occurred while handling message from " + fromContainerID, e));
}
}
use of org.eclipse.ecf.sync.IModelChangeMessage in project ecf by eclipse.
the class Message method deserialize.
/**
* Deserialize in to message
* @param bytes
* @return IModelChangeMessage
* @throws SerializationException
*/
public static IModelChangeMessage deserialize(byte[] bytes) throws SerializationException {
try {
final ByteArrayInputStream bins = new ByteArrayInputStream(bytes);
final ObjectInputStream oins = new ObjectInputStream(bins);
return (IModelChangeMessage) oins.readObject();
} catch (final Exception e) {
throw new SerializationException(Messages.DocShare_EXCEPTION_DESERIALIZING_MESSAGE0, e);
}
}
Aggregations