// Path: tda-visualvm-module/logfile-visualvm-module/src/net/java/dev/tda/visualvm/logfile/Logfile.java
// public class Logfile extends Snapshot {
//     
//     public Logfile(File file) throws IOException {
//         this(file, null);
//     }
//     
//     public Logfile(File file, DataSource master) throws IOException {
//         super(file, LogfileSupport.getCategory(), master);
//         
//         if (!file.exists() || !file.isFile())
//             throw new IOException("File " + file.getAbsolutePath() + " does not exist");    // NOI18N        
//     }
//         
//     @Override
//     public boolean supportsSaveAs() {
//         return false;
//     }
// }


import java.util.HashMap;
import java.util.Map;
import net.java.dev.tda.visualvm.logfile.Logfile;
import org.graalvm.visualvm.core.datasource.DataSource;
import org.graalvm.visualvm.core.snapshot.Snapshot;
import org.graalvm.visualvm.core.ui.DataSourceView;
import org.graalvm.visualvm.core.ui.DataSourceViewProvider;
import org.graalvm.visualvm.core.ui.DataSourceViewsManager;
import org.graalvm.visualvm.threaddump.ThreadDump;
/*
 * This file is part of TDA - Thread Dump Analysis Tool.
 *
 * TDA is free software; you can redistribute it and/or modify
 * it under the terms of the Lesser GNU General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or
 * (at your option) any later version.
 *
 * TDA is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * Lesser GNU General Public License for more details.
 *
 * You should have received a copy of the Lesser GNU General Public License
 * along with TDA; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */
package net.java.dev.tda.visualvm;


/**
 * provides a tda view.
 * 
 * @author irockel
 */
public class TDAViewProvider extends DataSourceViewProvider<DataSource> {
    /*
     * FIXME: this is just a hack to add newly added thread dumps to an existing thread dump view.
     */
    private final Map<DataSource, TDAView> views = new HashMap<>();
    
    static void initialize() {
        DataSourceViewsManager.sharedInstance().addViewProvider(new TDAViewProvider(), DataSource.class);
    }

    @Override
    protected boolean supportsViewFor(DataSource logContent) {
// Path: tda-visualvm-module/logfile-visualvm-module/src/net/java/dev/tda/visualvm/logfile/Logfile.java
// public class Logfile extends Snapshot {
//     
//     public Logfile(File file) throws IOException {
//         this(file, null);
//     }
//     
//     public Logfile(File file, DataSource master) throws IOException {
//         super(file, LogfileSupport.getCategory(), master);
//         
//         if (!file.exists() || !file.isFile())
//             throw new IOException("File " + file.getAbsolutePath() + " does not exist");    // NOI18N        
//     }
//         
//     @Override
//     public boolean supportsSaveAs() {
//         return false;
//     }
// }


// Path: tda-visualvm-module/tda-visualvm-module/src/net/java/dev/tda/visualvm/TDAViewProvider.java
import java.util.HashMap;
import java.util.Map;
import net.java.dev.tda.visualvm.logfile.Logfile;
import org.graalvm.visualvm.core.datasource.DataSource;
import org.graalvm.visualvm.core.snapshot.Snapshot;
import org.graalvm.visualvm.core.ui.DataSourceView;
import org.graalvm.visualvm.core.ui.DataSourceViewProvider;
import org.graalvm.visualvm.core.ui.DataSourceViewsManager;
import org.graalvm.visualvm.threaddump.ThreadDump;

/*
 * This file is part of TDA - Thread Dump Analysis Tool.
 *
 * TDA is free software; you can redistribute it and/or modify
 * it under the terms of the Lesser GNU General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or
 * (at your option) any later version.
 *
 * TDA is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * Lesser GNU General Public License for more details.
 *
 * You should have received a copy of the Lesser GNU General Public License
 * along with TDA; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */
package net.java.dev.tda.visualvm;


/**
 * provides a tda view.
 * 
 * @author irockel
 */
public class TDAViewProvider extends DataSourceViewProvider<DataSource> {
    /*
     * FIXME: this is just a hack to add newly added thread dumps to an existing thread dump view.
     */
    private final Map<DataSource, TDAView> views = new HashMap<>();
    
    static void initialize() {
        DataSourceViewsManager.sharedInstance().addViewProvider(new TDAViewProvider(), DataSource.class);
    }

    @Override
    protected boolean supportsViewFor(DataSource logContent) {
        return ((logContent instanceof ThreadDump) || (logContent instanceof Logfile));