]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.browsing.ui.swt/src/org/simantics/browsing/ui/swt/ImageLoaderJob.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.browsing.ui.swt / src / org / simantics / browsing / ui / swt / ImageLoaderJob.java
index 5f5d26b3ab8a32b7b8d636ba2d42f94d062d9ae0..86edc928cffcaf075f18ff1b767b6f55cb3af339 100644 (file)
@@ -1,79 +1,79 @@
-/*******************************************************************************\r
- * Copyright (c) 2013 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
- *     Semantum Oy - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.browsing.ui.swt;\r
-\r
-import java.util.concurrent.atomic.AtomicBoolean;\r
-\r
-import org.eclipse.core.runtime.IProgressMonitor;\r
-import org.eclipse.core.runtime.IStatus;\r
-import org.eclipse.core.runtime.Status;\r
-import org.eclipse.core.runtime.jobs.Job;\r
-import org.eclipse.ui.progress.IProgressConstants;\r
-import org.simantics.DatabaseJob;\r
-\r
-/**\r
- * @author Tuukka Lehtonen\r
- */\r
-public class ImageLoaderJob extends DatabaseJob {\r
-\r
-       private GraphExplorerImplBase ge;\r
-       private AtomicBoolean isScheduled = new AtomicBoolean();\r
-\r
-       public ImageLoaderJob(GraphExplorerImplBase ge) {\r
-               super("Image Loader");\r
-               this.ge = ge;\r
-               setSystem(true);\r
-               setUser(false);\r
-               setPriority(Job.DECORATE);\r
-               setProperty(IProgressConstants.NO_IMMEDIATE_ERROR_PROMPT_PROPERTY, Boolean.TRUE);\r
-       }\r
-\r
-       /**\r
-        * Schedules the job with {@link Job#schedule()} if necessary, i.e. if\r
-        * not already scheduled. This method avoids some unnecessary overhead\r
-        * caused by repeatedly invoking {@link Job#schedule()}.\r
-        * \r
-        * @return <code>true</code> if scheduled, <code>false</code> otherwise\r
-        */\r
-       public boolean scheduleIfNecessary(long delay) {\r
-               if (isScheduled.compareAndSet(false, true)) {\r
-                       schedule(delay);\r
-                       return true;\r
-               }\r
-               return false;\r
-       }\r
-\r
-       @Override\r
-       public boolean shouldRun() {\r
-               return ge != null;\r
-       }\r
-\r
-       @Override\r
-       public boolean shouldSchedule() {\r
-               return ge != null;\r
-       }\r
-\r
-       @Override\r
-       protected IStatus run(IProgressMonitor monitor) {\r
-               try {\r
-                       isScheduled.set(false);\r
-                       GraphExplorerImplBase ge = this.ge;\r
-                       return (ge != null) ? ge.setPendingImages(monitor) : Status.CANCEL_STATUS;\r
-               } finally {\r
-                       monitor.done();\r
-               }\r
-       }\r
-\r
-       public void dispose() {\r
-               ge = null;\r
-       }\r
+/*******************************************************************************
+ * Copyright (c) 2013 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:
+ *     Semantum Oy - initial API and implementation
+ *******************************************************************************/
+package org.simantics.browsing.ui.swt;
+
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.ui.progress.IProgressConstants;
+import org.simantics.DatabaseJob;
+
+/**
+ * @author Tuukka Lehtonen
+ */
+public class ImageLoaderJob extends DatabaseJob {
+
+       private GraphExplorerImplBase ge;
+       private AtomicBoolean isScheduled = new AtomicBoolean();
+
+       public ImageLoaderJob(GraphExplorerImplBase ge) {
+               super("Image Loader");
+               this.ge = ge;
+               setSystem(true);
+               setUser(false);
+               setPriority(Job.DECORATE);
+               setProperty(IProgressConstants.NO_IMMEDIATE_ERROR_PROMPT_PROPERTY, Boolean.TRUE);
+       }
+
+       /**
+        * Schedules the job with {@link Job#schedule()} if necessary, i.e. if
+        * not already scheduled. This method avoids some unnecessary overhead
+        * caused by repeatedly invoking {@link Job#schedule()}.
+        * 
+        * @return <code>true</code> if scheduled, <code>false</code> otherwise
+        */
+       public boolean scheduleIfNecessary(long delay) {
+               if (isScheduled.compareAndSet(false, true)) {
+                       schedule(delay);
+                       return true;
+               }
+               return false;
+       }
+
+       @Override
+       public boolean shouldRun() {
+               return ge != null;
+       }
+
+       @Override
+       public boolean shouldSchedule() {
+               return ge != null;
+       }
+
+       @Override
+       protected IStatus run(IProgressMonitor monitor) {
+               try {
+                       isScheduled.set(false);
+                       GraphExplorerImplBase ge = this.ge;
+                       return (ge != null) ? ge.setPendingImages(monitor) : Status.CANCEL_STATUS;
+               } finally {
+                       monitor.done();
+               }
+       }
+
+       public void dispose() {
+               ge = null;
+       }
 }
\ No newline at end of file
 }
\ No newline at end of file