001/*
002 * This file is part of McIDAS-V
003 *
004 * Copyright 2007-2023
005 * Space Science and Engineering Center (SSEC)
006 * University of Wisconsin - Madison
007 * 1225 W. Dayton Street, Madison, WI 53706, USA
008 * https://www.ssec.wisc.edu/mcidas
009 * 
010 * All Rights Reserved
011 * 
012 * McIDAS-V is built on Unidata's IDV and SSEC's VisAD libraries, and
013 * some McIDAS-V source code is based on IDV and VisAD source code.  
014 * 
015 * McIDAS-V is free software; you can redistribute it and/or modify
016 * it under the terms of the GNU Lesser Public License as published by
017 * the Free Software Foundation; either version 3 of the License, or
018 * (at your option) any later version.
019 * 
020 * McIDAS-V is distributed in the hope that it will be useful,
021 * but WITHOUT ANY WARRANTY; without even the implied warranty of
022 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
023 * GNU Lesser Public License for more details.
024 * 
025 * You should have received a copy of the GNU Lesser Public License
026 * along with this program.  If not, see http://www.gnu.org/licenses.
027 */
028
029package edu.wisc.ssec.mcidasv.collaboration;
030
031import ucar.unidata.collab.Sharable;
032import ucar.unidata.idv.IntegratedDataViewer;
033import ucar.unidata.idv.ViewManager;
034import ucar.unidata.idv.collab.CollabManager;
035import ucar.unidata.idv.collab.CollabMsgType;
036
037import edu.wisc.ssec.mcidasv.McIDASV;
038import org.slf4j.Logger;
039import org.slf4j.LoggerFactory;
040
041public class CollaborationManager extends CollabManager {
042    
043    private static final Logger logger = LoggerFactory.getLogger(CollaborationManager.class);
044    
045    private ViewManager recordingFrom;
046    
047    public CollaborationManager(IntegratedDataViewer idv) {
048        super(idv);
049    }
050    
051//    public void startRecording(ViewManager vm) {
052//        recordingFrom = vm;
053//    }
054//    
055//    public void stopRecording(ViewManager vm) {
056//        recordingFrom = null;
057//    }
058//    
059//    @Override public void write(CollabMsgType type, String message) {
060//        super.write(type, message);
061//    }
062//    
063//    @Override protected String makeMsg(CollabMsgType type, String body) {
064//        logger.trace("type: {}, body: {}", type, body);
065//        return super.makeMsg(type, body);
066//    }
067    
068    @Override protected Sharable findSharable(String id) {
069        Sharable sharable = super.findSharable(id);
070        if (sharable == null) {
071            if (id.startsWith("view_")) {
072                if (recordingFrom == null) {
073                    sharable = ((McIDASV) getIdv()).getVMManager().getLastActiveViewManager();
074                } else {
075                    return recordingFrom;
076                }
077            }
078        }
079        return sharable;
080    }
081    
082
083}