]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.message.ui/src/org/simantics/message/ui/LogFilesManager.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.message.ui / src / org / simantics / message / ui / LogFilesManager.java
diff --git a/bundles/org.simantics.message.ui/src/org/simantics/message/ui/LogFilesManager.java b/bundles/org.simantics.message.ui/src/org/simantics/message/ui/LogFilesManager.java
new file mode 100644 (file)
index 0000000..9dd55a4
--- /dev/null
@@ -0,0 +1,59 @@
+/*******************************************************************************\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.message.ui;
+
+import java.io.File;
+import java.util.*;
+
+/**
+ * Manages the log file providers.
+ * One adds log file provider to let Log View know where to find log files.
+ */
+public class LogFilesManager {
+
+       private static List<ILogFileProvider> logFileProviders = new ArrayList<ILogFileProvider>();
+
+       /**
+        * Adds log file provider.
+        * Has no effect if an identical provider is already registered. 
+        */
+       public static void addLogFileProvider(ILogFileProvider provider) {
+               if (!logFileProviders.contains(provider)) {
+                       logFileProviders.add(provider);
+               }
+       }
+
+       /**
+        * Removes log file provider.
+        * Has no effect if an identical provider is already removed.
+        */
+       public static void removeLogFileProvider(ILogFileProvider provider) {
+               logFileProviders.remove(provider);
+       }
+
+       /**
+        * Returns the list of logs.
+        */
+    static Map<String, File> getLogSources() {
+               ILogFileProvider[] providers = (ILogFileProvider[]) logFileProviders.toArray(new ILogFileProvider[logFileProviders.size()]);
+               Map<String, File> result = new HashMap<String, File>();
+
+               for (int i = 0; i < providers.length; i++) {
+                       ILogFileProvider provider = providers[i];
+
+                       Map<String, File> sources = provider.getLogSources();
+                       result.putAll(sources);
+               }
+
+               return result;
+       }
+}