001/* 002 * Copyright (c) 2010 The Regents of the University of California. 003 * All rights reserved. 004 * 005 * '$Author: berkley $' 006 * '$Date: 2010-04-28 00:12:36 +0000 (Wed, 28 Apr 2010) $' 007 * '$Revision: 24000 $' 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 030/** 031 * 032 */ 033package org.kepler.gui; 034 035import java.awt.BorderLayout; 036 037import javax.swing.JLabel; 038import javax.swing.JPanel; 039 040import ptolemy.actor.gui.TableauFrame; 041import ptolemy.kernel.util.IllegalActionException; 042import ptolemy.kernel.util.NameDuplicationException; 043import ptolemy.kernel.util.NamedObj; 044 045/** 046 * This is an example template for extending the TabPane extension in Kepler. 047 * 048 * @author Aaron Schultz 049 * 050 */ 051public class TabPaneExtensionExample extends JPanel implements TabPane { 052 053 private TableauFrame _frame; 054 private String _tabName; 055 056 /* 057 * (non-Javadoc) 058 * 059 * @see org.kepler.gui.TabPane#getParentFrame() 060 */ 061 public TableauFrame getParentFrame() { 062 return _frame; 063 } 064 065 /* 066 * (non-Javadoc) 067 * 068 * @see org.kepler.gui.TabPane#getTabName() 069 */ 070 public String getTabName() { 071 return _tabName; 072 } 073 074 public void setTabName(String name) { 075 _tabName = name; 076 } 077 078 /* 079 * (non-Javadoc) 080 * 081 * @see org.kepler.gui.TabPane#initializeTab() 082 */ 083 public void initializeTab() throws Exception { 084 // Add components to the JPanel here. 085 JLabel jl = new JLabel("This is an example of implementing an extension to the TabPane extension point."); 086 this.setLayout(new BorderLayout()); 087 this.add(jl, BorderLayout.NORTH); 088 } 089 090 /* 091 * (non-Javadoc) 092 * 093 * @see 094 * org.kepler.gui.TabPane#setParentFrame(ptolemy.actor.gui.TableauFrame) 095 */ 096 public void setParentFrame(TableauFrame parent) { 097 _frame = parent; 098 } 099 100 /** 101 * A factory that creates a TabPane. 102 * 103 *@author Aaron Schultz 104 */ 105 public static class Factory extends TabPaneFactory { 106 /** 107 * Create a factory with the given name and container. 108 * 109 *@param container 110 * The container. 111 *@param name 112 * The name of the entity. 113 *@exception IllegalActionException 114 * If the container is incompatible with this attribute. 115 *@exception NameDuplicationException 116 * If the name coincides with an attribute already in the 117 * container. 118 */ 119 public Factory(NamedObj container, String name) 120 throws IllegalActionException, NameDuplicationException { 121 super(container, name); 122 } 123 124 /** 125 * Create a library pane that displays the given library of actors. 126 * 127 * @return A new LibraryPaneTab that displays the library 128 */ 129 public TabPane createTabPane(TableauFrame parent) { 130 TabPaneExtensionExample tpee = new TabPaneExtensionExample(); 131 132 /* 133 * Optionally you can create a method called setTabName and use the 134 * "name" value from the configuration.xml file by calling 135 * this.getName(). For Example if you have <property 136 * name="randomTestTab" 137 * class="org.kepler.gui.TabPaneExtensionExample$Factory" /> in 138 * configuration.xml then the name of the tab in the GUI becomes 139 * randomTestTab 140 */ 141 tpee.setTabName(this.getName()); 142 143 return tpee; 144 } 145 } 146 147}