001/* 002 * Copyright (c) 2010 The Regents of the University of California. 003 * All rights reserved. 004 * 005 * '$Author: welker $' 006 * '$Date: 2010-05-06 05:21:26 +0000 (Thu, 06 May 2010) $' 007 * '$Revision: 24234 $' 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.gui; 031 032import java.awt.BorderLayout; 033import java.awt.Component; 034 035import javax.swing.JPanel; 036 037import ptolemy.actor.gui.TableauFrame; 038import ptolemy.kernel.util.NamedObj; 039 040public abstract class AbstractDialogTab extends JPanel { 041 042 /** 043 * Construct a new instance of this object - to be called from implementing 044 * class like this: <code> 045 * public MyImplementationNameHere(NamedObj target) { 046 * super(target); 047 * } 048 * </code> 049 * 050 * @param target 051 * NamedObj the object to be configured (actor, director etc) 052 * 053 * @param targetType 054 * the string representing this type of target, to be used in the 055 * resourcebundle keys. - such as "actor", "director" etc. 056 */ 057 public AbstractDialogTab(NamedObj target, String targetType, 058 TableauFrame frame) { 059 super(); 060 this._target = target; 061 this._targetType = targetType; 062 this._frame = frame; 063 this.setLayout(new BorderLayout()); 064 this.setBorder(TabbedDialog.tabPanePadding); 065 this.setOpaque(true); 066 this.add(getTopPanel(), BorderLayout.NORTH); 067 this.add(getCenterPanel(), BorderLayout.CENTER); 068 this.add(getBottomPanel(), BorderLayout.SOUTH); 069 } 070 071 // //////////////////////////////////////////////////////////////////////////// 072 // protected methods // 073 // //////////////////////////////////////////////////////////////////////////// 074 075 /** 076 * get the Component that will be displayed in the NORTH section of the 077 * BorderLayout. Note that if the dialog is resizable, this Component will 078 * need to stretch along the x axis, while retaining its aesthetic qualities 079 * 080 * @return Component 081 */ 082 protected abstract Component getTopPanel(); 083 084 /** 085 * get the Component that will be displayed in the CENTER section of the 086 * BorderLayout. Note that if the dialog is resizable, this Component will 087 * need to stretch along both the x <em>and</em> y axes, while retaining its 088 * aesthetic qualities 089 * 090 * @return Component 091 */ 092 protected abstract Component getCenterPanel(); 093 094 /** 095 * get the Component that will be displayed in the SOUTH section of the 096 * BorderLayout. Note that if the dialog is resizable, this Component will 097 * need to stretch along the x axis, while retaining its aesthetic qualities 098 * 099 * @return Component 100 */ 101 protected abstract Component getBottomPanel(); 102 103 /** 104 * check the user input for errors/omissions. Return true if everything is 105 * OK and we can proceed with a save(). Return false if there are problems 106 * that need to be corrected, and preferably request focus for the "problem" 107 * UI component 108 * 109 * @return boolean true if everything is OK and we can proceed with a 110 * save(). Return false if there are problems that need to be 111 * corrected, and preferably request focus for the "problem" UI 112 * component 113 */ 114 protected abstract boolean validateInput(); 115 116 /** 117 * Save the user-editable values associated with this tab. The container 118 * should probably call validateInput() on each tab before saving 119 */ 120 protected abstract void save(); 121 122 /** 123 * get the string representing this type of target, to be used in the 124 * resourcebundle keys. For example, all the resourcebundle keys for actors 125 * are of the form: 126 * 127 * dialogs.actor.general.id 128 * 129 * and for directors, of the form: 130 * 131 * dialogs.director.general.id 132 * 133 * ...etc - thus, the value returned by this method if implemented in an 134 * actor dialog should be "actor"; for a director dialog, it should be 135 * "director", etc, so it can be used to generate the above example keys as 136 * follows: 137 * 138 * key = "dialogs." + getTargetType() + ".general.id" 139 * 140 * @return String representing this type of target - such as "actor", 141 * "director" etc 142 */ 143 protected String setTargetType(String targetType) { 144 return _targetType; 145 } 146 147 // //////////////////////////////////////////////////////////////////////////// 148 // protected variables // 149 // //////////////////////////////////////////////////////////////////////////// 150 151 protected final NamedObj _target; 152 protected final TableauFrame _frame; 153 protected final String _targetType; 154 155 protected static final String ACTOR_TARGET_TYPE = "actor"; 156 protected static final String DIRECTOR_TARGET_TYPE = "director"; 157 protected static final String WORKFLOW_TARGET_TYPE = "workflow"; 158 159 // //////////////////////////////////////////////////////////////////////////// 160 // private methods // 161 // //////////////////////////////////////////////////////////////////////////// 162 163}