001/* 002 * Copyright (c) 2009-2010 The Regents of the University of California. 003 * All rights reserved. 004 * 005 * '$Author: crawl $' 006 * '$Date: 2015-08-24 22:44:14 +0000 (Mon, 24 Aug 2015) $' 007 * '$Revision: 33630 $' 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 */ 029 030package org.kepler.module.gui; 031 032import java.awt.BorderLayout; 033import java.awt.Component; 034 035import javax.swing.JComponent; 036import javax.swing.JPanel; 037import javax.swing.JToolBar; 038 039import org.kepler.gui.KeplerGraphFrame; 040import org.kepler.gui.KeplerGraphFrameUpdater; 041import org.kepler.gui.ViewManager; 042import org.kepler.module.ModuleInitializer; 043import org.kepler.moml.filter.KeplerBackwardCompatibility; 044 045/** Perform initialization for the GUI module. 046 * 047 * This class implements KeplerGraphFrameUpdater so that it can add 048 * a view selector to the toolbar. 049 * 050 * Additionally, it initializes the moml filters for actors in the 051 * util module. 052 * 053 * @author Daniel Crawl 054 * @version $Id: Initialize.java 33630 2015-08-24 22:44:14Z crawl $ 055 * 056 */ 057 058public class Initialize implements KeplerGraphFrameUpdater, 059 ModuleInitializer { 060 /** 061 * Compares this object with the specified object for order. 062 */ 063 public int compareTo(KeplerGraphFrameUpdater updater) { 064 // we want our toolbar modifications on the right end, i.e. 065 // applied last, so we're always greater 066 return 1; 067 } 068 069 /** 070 * Perform any module-specific initializations. 071 */ 072 public void initializeModule() { 073 074 075 // ***************** 076 // ANY CHANGES IN THIS CLASS LIKELY MUST ALSO BE MADE IN TAGGING MODULE'S 077 // OVERRIDE 078 // ************ 079 080 // add ourself as an updater so we can add the view selector 081 KeplerGraphFrame.addUpdater(this); 082 083 // initialize the backwards-compatibility moml filters. 084 KeplerBackwardCompatibility.initialize(); 085 } 086 087 /** 088 * Update the components. 089 */ 090 public void updateFrameComponents(KeplerGraphFrame.Components components) 091 { 092 KeplerGraphFrame frame = components.getFrame(); 093 JToolBar toolbar = components.getToolBar(); 094 095 JPanel ddHolder = new JPanel(new BorderLayout()); 096 ViewManager vman = ViewManager.getInstance(); 097 JComponent vsel = vman.getViewSelector(frame); 098 ddHolder.add(vsel, BorderLayout.EAST); 099 toolbar.add(ddHolder); 100 101 102 //remove the full screen button for the 2.0 release. 103 //this is a kind of lame way to do this, but since the name 104 //of each component in the toolbar has not been set, there is no 105 //good way to figure out which component we're looking at. If 106 //components are added before the 4th item then this will break. 107 108 Component[] comps = toolbar.getComponents(); 109 comps[4].setVisible(false); 110 111 //ALSO IMPORTANT Note: This is overridden in this module and 112 // several others. As of 02/10/10 the classes where the full screen 113 // button was hidden are as follows: 114 115 // org.kepler.module.util.Initialize 116 // org.kepler.module.tagging.Initialize 117 // org.kepler.module.provenance.Initialize 118 // org.kepler.module.reporting.Initialize 119 // org.kepler.module.workflowrunmanager.Initialize 120 // org.kepler.module.wrp.Initialize 121 122 123 } 124 125 public void dispose(KeplerGraphFrame frame) { 126 127 } 128}