001/* 002 * Copyright (c) 2014 The Regents of the University of California. 003 * All rights reserved. 004 * 005 * '$Author: crawl $' 006 * '$Date: 2013-09-18 16:45:59 -0700 (Wed, 18 Sep 2013) $' 007 * '$Revision: 32484 $' 008 * 009 * Permission is hereby granted, without written agreement and without 010 * license or royalty fees, to use, copy, modify, and distribute this 011 * software and its documentation for any purpose, provided that the above 012 * copyright notice and the following two paragraphs appear in all copies 013 * of this software. 014 * 015 * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY 016 * FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES 017 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF 018 * THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF 019 * SUCH DAMAGE. 020 * 021 * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, 022 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 023 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE 024 * PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF 025 * CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, 026 * ENHANCEMENTS, OR MODIFICATIONS. 027 * 028 */ 029package org.kepler.module.cloudsharing; 030 031 032import javax.swing.JButton; 033import javax.swing.JToolBar; 034 035import org.kepler.cloudsharing.gui.CloudSharingConfigureAction; 036import org.kepler.gui.KeplerGraphFrame; 037import org.kepler.gui.KeplerGraphFrameUpdater; 038import org.kepler.module.ModuleInitializer; 039 040 041/** 042 * Perform initialization for the cloud-sharing module. This class adds itself 043 * as a updater to KeplerGraphFrame so that can add the Upload to Cloud button 044 * to the toolbar. 045 * 046 * @author Daniel Crawl 047 * @version $Id$ 048 * 049 */ 050 051public class Initialize implements KeplerGraphFrameUpdater, ModuleInitializer { 052 053 /** Compares this object with the specified object for order. */ 054 @Override 055 public int compareTo(KeplerGraphFrameUpdater o) { 056 // always return less than 057 return -1; 058 } 059 060 @Override 061 public boolean equals(Object o) { 062 return this == o; 063 } 064 065 /** Perform any module-specific initializations. */ 066 @Override 067 public void initializeModule() { 068 069 // add ourself as an updater so we can add a button 070 KeplerGraphFrame.addUpdater(this); 071 072 // the recorder filter adds the recorder to workflows 073 //BackwardCompatibility.addFilter(new TopProvenanceRecorderFilter()); 074 } 075 076 /** Update the components. */ 077 @Override 078 public void updateFrameComponents(KeplerGraphFrame.Components components) { 079 CloudSharingConfigureAction action = new CloudSharingConfigureAction( 080 components.getFrame()); 081 JToolBar toolbar = components.getToolBar(); 082 JButton button = diva.gui.GUIUtilities 083 .addToolBarButton(toolbar, action); 084 button.setToolTipText("Cloud Sharing"); 085 086 // tell the action about its button so it can change the icon 087 action.setButton(button); 088 } 089 090 @Override 091 public void dispose(KeplerGraphFrame frame) { 092 093 /* 094 NamedObj model = frame.getModel(); 095 // clean up any provenance recorders contained in this model 096 List<?> recorderList = model.attributeList(ProvenanceRecorder.class); 097 for(Object recorder : recorderList) 098 { 099 try { 100 ((ProvenanceRecorder)recorder).setContainer(null); 101 } catch (Exception e) { 102 MessageHandler.error("Error disposing provenance recorder.", e); 103 } 104 } 105 */ 106 } 107}