]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.message.ui/src/org/simantics/message/ui/LogFilesManager.java
Fixed multiple issues causing dangling references to discarded queries
[simantics/platform.git] / bundles / org.simantics.message.ui / src / org / simantics / message / ui / LogFilesManager.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
3  * in Industry THTH ry.
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
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.message.ui;
13
14 import java.io.File;
15 import java.util.*;
16
17 /**
18  * Manages the log file providers.
19  * One adds log file provider to let Log View know where to find log files.
20  */
21 public class LogFilesManager {
22
23         private static List<ILogFileProvider> logFileProviders = new ArrayList<ILogFileProvider>();
24
25         /**
26          * Adds log file provider.
27          * Has no effect if an identical provider is already registered. 
28          */
29         public static void addLogFileProvider(ILogFileProvider provider) {
30                 if (!logFileProviders.contains(provider)) {
31                         logFileProviders.add(provider);
32                 }
33         }
34
35         /**
36          * Removes log file provider.
37          * Has no effect if an identical provider is already removed.
38          */
39         public static void removeLogFileProvider(ILogFileProvider provider) {
40                 logFileProviders.remove(provider);
41         }
42
43         /**
44          * Returns the list of logs.
45          */
46     static Map<String, File> getLogSources() {
47                 ILogFileProvider[] providers = (ILogFileProvider[]) logFileProviders.toArray(new ILogFileProvider[logFileProviders.size()]);
48                 Map<String, File> result = new HashMap<String, File>();
49
50                 for (int i = 0; i < providers.length; i++) {
51                         ILogFileProvider provider = providers[i];
52
53                         Map<String, File> sources = provider.getLogSources();
54                         result.putAll(sources);
55                 }
56
57                 return result;
58         }
59 }