1 /*******************************************************************************
2 * Copyright (c) 2010 Association for Decentralized Information Management in
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.databoard.accessor.event;
14 import java.io.IOException;
16 import org.simantics.databoard.Bindings;
17 import org.simantics.databoard.accessor.reference.ChildReference;
18 import org.simantics.databoard.annotations.Optional;
19 import org.simantics.databoard.annotations.Union;
20 import org.simantics.databoard.binding.Binding;
21 import org.simantics.databoard.binding.error.BindingConstructionException;
22 import org.simantics.databoard.binding.error.BindingException;
25 ArrayElementAdded.class,
26 ArrayElementRemoved.class,
28 MapEntryRemoved.class,
29 UnionValueAssigned.class,
30 OptionalValueAssigned.class,
31 OptionalValueRemoved.class,
33 InvalidatedEvent.class//,
36 public abstract class Event {
38 /** Path from the listened Object to the composite, null if same */
39 public @Optional ChildReference reference;
42 * Create a clone with new reference
44 * @return clone with a new reference
46 public abstract Event clone(ChildReference newReference);
49 public String toString() {
51 Binding b = Bindings.getBinding(Event.class);
52 return b.printValueDefinition(this, true);
53 } catch (BindingConstructionException e) {
54 return e.getClass().getName()+" "+e.getMessage();
55 } catch (IOException e) {
56 return e.getClass().getName()+" "+e.getMessage();
57 } catch (BindingException e) {
58 return e.getClass().getName()+" "+e.getMessage();
62 protected String toRef() {
63 if (reference==null) return "[] ";
64 return "["+reference+"] ";