-/*******************************************************************************\r
- * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
- * in Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- * VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.g2d.canvas.impl;\r
-\r
-import java.lang.reflect.Method;\r
-\r
-import org.simantics.g2d.canvas.IContentContext;\r
-import org.simantics.utils.datastructures.ListenerList;\r
-import org.simantics.utils.threads.CurrentThread;\r
-import org.simantics.utils.threads.IThreadWorkQueue;\r
-import org.simantics.utils.threads.SyncListenerList;\r
-\r
-/**\r
- * \r
- * @See {@link IContentContext}\r
- * \r
- * @author Toni Kalajainen\r
- */\r
-public class PaintableContextImpl implements IContentContext {\r
-\r
- @Override\r
- public void setDirty() {\r
- fireSetDirty(); \r
- }\r
- \r
- protected ListenerList<IContentListener> list =\r
- new ListenerList<IContentListener>(IContentListener.class);\r
- protected SyncListenerList<IContentListener> list2 =\r
- new SyncListenerList<IContentListener>(IContentListener.class);\r
-\r
- @Override\r
- public void addPaintableContextListener(IContentListener listener) {\r
- list.add(listener);\r
- }\r
- @Override\r
- public void addPaintableContextListener(IContentListener listener, IThreadWorkQueue thread) {\r
- if (thread==CurrentThread.getThreadAccess()) \r
- addPaintableContextListener(listener);\r
- else\r
- list2.add(thread, listener);\r
- } \r
- @Override\r
- public void removePaintableContextListener(IContentListener listener) {\r
- list.remove(listener);\r
- }\r
- @Override\r
- public void removePaintableContextListener(IContentListener listener, IThreadWorkQueue thread) {\r
- if (thread==CurrentThread.getThreadAccess()) \r
- addPaintableContextListener(listener);\r
- else\r
- list2.remove(thread, listener);\r
- }\r
- private final static Method onDirty = SyncListenerList.getMethod(IContentListener.class, "onDirty");\r
- protected void fireSetDirty() {\r
- for (IContentListener l : list.getListeners())\r
- l.onDirty(this);\r
- list2.fireEventSync(onDirty, this);\r
- }\r
- protected void fireAsyncSetDirty() {\r
- list2.fireEventAsync(onDirty, this);\r
- }\r
-\r
- \r
- \r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management
+ * in Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
+package org.simantics.g2d.canvas.impl;
+
+import java.lang.reflect.Method;
+
+import org.simantics.g2d.canvas.IContentContext;
+import org.simantics.utils.datastructures.ListenerList;
+import org.simantics.utils.threads.CurrentThread;
+import org.simantics.utils.threads.IThreadWorkQueue;
+import org.simantics.utils.threads.SyncListenerList;
+
+/**
+ *
+ * @See {@link IContentContext}
+ *
+ * @author Toni Kalajainen
+ */
+public class PaintableContextImpl implements IContentContext {
+
+ @Override
+ public void setDirty() {
+ fireSetDirty();
+ }
+
+ protected ListenerList<IContentListener> list =
+ new ListenerList<IContentListener>(IContentListener.class);
+ protected SyncListenerList<IContentListener> list2 =
+ new SyncListenerList<IContentListener>(IContentListener.class);
+
+ @Override
+ public void addPaintableContextListener(IContentListener listener) {
+ list.add(listener);
+ }
+ @Override
+ public void addPaintableContextListener(IContentListener listener, IThreadWorkQueue thread) {
+ if (thread==CurrentThread.getThreadAccess())
+ addPaintableContextListener(listener);
+ else
+ list2.add(thread, listener);
+ }
+ @Override
+ public void removePaintableContextListener(IContentListener listener) {
+ list.remove(listener);
+ }
+ @Override
+ public void removePaintableContextListener(IContentListener listener, IThreadWorkQueue thread) {
+ if (thread==CurrentThread.getThreadAccess())
+ addPaintableContextListener(listener);
+ else
+ list2.remove(thread, listener);
+ }
+ private final static Method onDirty = SyncListenerList.getMethod(IContentListener.class, "onDirty");
+ protected void fireSetDirty() {
+ for (IContentListener l : list.getListeners())
+ l.onDirty(this);
+ list2.fireEventSync(onDirty, this);
+ }
+ protected void fireAsyncSetDirty() {
+ list2.fireEventAsync(onDirty, this);
+ }
+
+
+
+}